gha: Skip non-relevant checks on pr or merge_group (#4684) #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Geti Tune Lib checks | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| tags: | |
| - "v*" | |
| pull_request: | |
| merge_group: | |
| branches: | |
| - develop | |
| - releases/** | |
| workflow_dispatch: # run on request (no need for PR) | |
| permissions: {} # No permissions by default | |
| concurrency: | |
| group: ${{ github.workflow }}-PreMerge-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check_paths: | |
| name: Check if workflow should run | |
| runs-on: ubuntu-latest | |
| outputs: | |
| test_any_changed: ${{ steps.changed-files-yaml.outputs.test_any_changed }} | |
| steps: | |
| - name: Get all paths that should trigger the workflow | |
| id: changed-files-yaml | |
| uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 | |
| with: | |
| files_yaml: | | |
| test: | |
| - lib/** | |
| - .github/** | |
| Code-Quality-Checks: | |
| runs-on: ubuntu-24.04 | |
| needs: check_paths | |
| if: needs.check_paths.outputs.test_any_changed == 'true' | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
| with: | |
| python-version: "3.12" | |
| - name: Install tox | |
| working-directory: lib | |
| run: | | |
| pip install '.[dev]' | |
| - name: Code quality checks | |
| working-directory: lib | |
| run: tox r -vv -e pre-commit | |
| Unit-Test: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| needs: | |
| - Code-Quality-Checks | |
| - check_paths | |
| if: needs.check_paths.outputs.test_any_changed == 'true' | |
| timeout-minutes: 120 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - python-version: "3.12" | |
| tox-env: "py312" | |
| - python-version: "3.11" | |
| tox-env: "py311" | |
| name: Unit-Test-with-Python${{ matrix.python-version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - name: Install Python | |
| uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install tox | |
| working-directory: lib | |
| run: | | |
| pip install '.[dev]' | |
| - name: Run unit test | |
| working-directory: lib | |
| run: tox r -vv -e unit-test-${{ matrix.tox-env }} | |
| - name: Upload coverage reports to Codecov | |
| working-directory: lib | |
| run: | | |
| # If the workflow is triggered from PR then it gets the commit id from the PR. | |
| # else it uses the commit id of the latest commit. This is because the commit | |
| # of the checked-out branch/commit does not exist in the tree as it is grafted. | |
| # Also note: GitHub does not pass secrets to pipelines triggered from a fork. | |
| # This means that upload will fail for PRs from forks. | |
| if [ -n "${{ github.event.pull_request.head.sha }}" ] | |
| then | |
| COMMIT_ID=${{ github.event.pull_request.head.sha }} | |
| else | |
| COMMIT_ID=${{ github.sha }} | |
| fi | |
| # current version of codecov-action does not support uploading reports through the proxy | |
| # so we use the latest version of codecov uploader binary | |
| curl -Os https://uploader.codecov.io/latest/linux/codecov | |
| chmod +x codecov | |
| ./codecov -t ${{ secrets.CODECOV_TOKEN }} --sha $COMMIT_ID -U $HTTP_PROXY -f .tox/coverage_unit-test-${{ matrix.tox-env }}.xml -F ${{ matrix.tox-env }} | |
| Integration-Test: | |
| if: | | |
| github.event.pull_request.draft == false && | |
| !(startsWith(github.event.pull_request.title, '[WIP]')) && | |
| needs.check_paths.outputs.test_any_changed == 'true' | |
| runs-on: [self-hosted, linux, x64, dev, dmount] | |
| permissions: | |
| contents: read | |
| needs: | |
| - Unit-Test | |
| - check_paths | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - task: "multi_class_cls" | |
| - task: "multi_label_cls" | |
| - task: "h_label_cls" | |
| - task: "anomaly" | |
| - task: "keypoint_detection" | |
| - task: "detection" | |
| - task: "instance_segmentation" | |
| - task: "semantic_segmentation" | |
| name: Integration-Test-${{ matrix.task }}-py312 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - name: Install Python | |
| uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | |
| with: | |
| python-version: "3.12" | |
| - name: Install tox | |
| working-directory: lib | |
| run: | | |
| pip install '.[dev]' | |
| - name: Run Integration Test | |
| working-directory: lib | |
| run: tox r -vv -e integration-test-${{ matrix.task }} -- --task ${{ matrix.task }} --run-category-only | |
| required_check: | |
| name: Required Check lib-lint-and-test | |
| needs: | |
| - check_paths | |
| - Code-Quality-Checks | |
| - Unit-Test | |
| - Integration-Test | |
| runs-on: ubuntu-latest | |
| env: | |
| CHECKS: ${{ join(needs.*.result, ' ') }} | |
| if: always() && !cancelled() | |
| steps: | |
| - name: Check jobs results | |
| run: | | |
| for check in ${CHECKS}; do | |
| echo "::notice::check=${check}" | |
| if [[ "$check" != "success" && "$check" != "skipped" ]]; then | |
| echo "::error ::Required status checks failed. They must succeed before this pull request can be merged." | |
| exit 1 | |
| fi | |
| done |