# Copyright 2026 The OpenXLA Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
name: PR Size Check
permissions:
  pull-requests: write
on:
  # zizmor: ignore[dangerous-triggers]
  pull_request_target:
    branches:
      - main

jobs:
  check-size:
    runs-on: ubuntu-22.04
    defaults:
      run:
        shell: bash
    env:
      GH_TOKEN: ${{ github.token }}
      PR_NUMBER: ${{ github.event.pull_request.number }}
      ADDITIONS: ${{ github.event.pull_request.additions }}
      DELETIONS: ${{ github.event.pull_request.deletions }}
    timeout-minutes: 5
    if: |
      github.repository == 'openxla/xla' && (
        github.event.sender.type == 'User' ||
        contains(github.event.pull_request.body, 'FORCE_TEST_ACTIONS')
      )
    steps:
      - name: "Checking out repository"
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - name: "Check PR Size"
        run: python3 .github/workflows/pr_size_check.py
