From b62671233cfd79aae3aba6f48c63167b21c3b88c Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Mon, 28 Oct 2024 14:58:46 +0100 Subject: [PATCH 1/2] Skip integration tests on docs-only changes --- .github/workflows/integration-tests.yml | 31 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index b92be6da5..ea24918f3 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -9,8 +9,27 @@ on: jobs: - trigger-tests: + check-integration-test-changes: if: github.event_name == 'pull_request' + name: Check if changes require integration tests to be triggered + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Check if all changes are in docs/ directory + id: check-integration-tests-required + run: | + changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) + if echo "$changed_files" | grep -qv '^docs/'; then + echo "integration_tests_required=true" >> $GITHUB_ENV + else + echo "integration_tests_required=false" >> $GITHUB_ENV + fi + + trigger-tests: + needs: check-integration-test-changes + if: '{{ env.integration_tests_required == "true" }}' name: Trigger Tests runs-on: ubuntu-latest environment: "test-trigger-is" @@ -36,8 +55,6 @@ jobs: -f pull_request_number=${{ github.event.pull_request.number }} \ -f commit_sha=${{ github.event.pull_request.head.sha }} - - # Statuses and checks apply to specific commits (by hash). # Enforcement of required checks is done both at the PR level and the merge queue level. # In case of multiple commits in a single PR, the hash of the squashed commit @@ -45,8 +62,9 @@ jobs: # We auto approve the check for the merge queue for two reasons: # * Queue times out due to duration of tests. # * Avoid running integration tests twice, since it was already run at the tip of the branch before squashing. + # Additionally, integration tests are not run on docs-only changes. auto-approve: - if: github.event_name == 'merge_group' + if: '{{ github.event_name == "merge_group" || env.integration_tests_required == "false" }}' runs-on: ubuntu-latest steps: - name: Mark Check @@ -54,6 +72,11 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash run: | + if [ "${{ github.event_name }}" == "merge_group" ]; then + echo "Auto-approving check for merge queue" + else + echo "Auto-approving check for docs-only changes" + fi gh api -X POST -H "Accept: application/vnd.github+json" \ -H "X-GitHub-Api-Version: 2022-11-28" \ /repos/${{ github.repository }}/statuses/${{ github.sha }} \ From c79b37dffbd6df79ae1b28fae4f1c0dadc23dcd1 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Mon, 28 Oct 2024 16:36:26 +0100 Subject: [PATCH 2/2] fix --- .github/workflows/integration-tests.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index ea24918f3..5d7305142 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -16,16 +16,13 @@ jobs: steps: - uses: actions/checkout@v3 - - - name: Check if all changes are in docs/ directory - id: check-integration-tests-required - run: | - changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) - if echo "$changed_files" | grep -qv '^docs/'; then - echo "integration_tests_required=true" >> $GITHUB_ENV - else - echo "integration_tests_required=false" >> $GITHUB_ENV - fi + - uses: dorny/paths-filter@v3 + with: + # integration_tests_required should be true if integration tests should be run. + # - Any PRs that only modify documentation should not require integration tests to run. + filters: | + integration_tests_required: + - '!**/*.md' trigger-tests: needs: check-integration-test-changes @@ -64,6 +61,7 @@ jobs: # * Avoid running integration tests twice, since it was already run at the tip of the branch before squashing. # Additionally, integration tests are not run on docs-only changes. auto-approve: + needs: check-integration-test-changes if: '{{ github.event_name == "merge_group" || env.integration_tests_required == "false" }}' runs-on: ubuntu-latest steps: