From 696086076030d3a97f706f1a48a29061dff7bafb Mon Sep 17 00:00:00 2001 From: Talha Date: Tue, 28 Jul 2026 15:29:37 +0500 Subject: [PATCH] fix(ci): prevent redundant dependency update runs --- .github/dependabot.yml | 9 +------ .github/workflows/ci.yml | 55 +++++++++++++++++++++++++++------------- changes/19.bugfix.md | 1 + 3 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 changes/19.bugfix.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1c55fbc..7b0420f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,14 +1,7 @@ version: 2 updates: - package-ecosystem: pip - directories: - - "/" - - "/src/vidxp/requirements" - - "/src/vidxp/capabilities/dialogue" - - "/src/vidxp/capabilities/scene" - - "/src/vidxp/capabilities/actor" - - "/src/vidxp/benchmarks" - - "/utils" + directory: "/" schedule: interval: cron cronjob: "0 9 1,15 * *" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41c3545..a22e29b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,8 +6,6 @@ on: - opened - synchronize - reopened - - labeled - - unlabeled concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -15,6 +13,7 @@ concurrency: permissions: contents: read + pull-requests: read jobs: validate: @@ -24,27 +23,14 @@ jobs: with: fetch-depth: 0 - - uses: actions/setup-python@v7 - with: - python-version: "3.11" - cache: pip - - - name: Install repository tooling - run: | - python -m pip install --upgrade pip - python -m pip install -r utils/build-requirements.txt - - - name: Require a changelog fragment - if: >- - github.event_name == 'pull_request' && - !contains(github.event.pull_request.labels.*.name, 'skip-changelog') - run: towncrier check --compare-with "${{ github.event.pull_request.base.sha }}" - - name: Determine validation scope id: scope shell: bash env: BASE_SHA: ${{ github.event.pull_request.base.sha }} + GH_TOKEN: ${{ github.token }} + PR_ACTOR: ${{ github.actor }} + PR_NUMBER: ${{ github.event.pull_request.number }} run: | changed_files="$(git diff --name-only "$BASE_SHA" HEAD)" if grep -Eq '^(\.github/workflows/ci\.yml$|src/|tests/|utils/|LICENSE$|MANIFEST\.in$|pyproject\.toml$)' <<< "$changed_files"; then @@ -57,8 +43,41 @@ jobs: else run_container=false fi + + if [[ "$PR_ACTOR" == "dependabot[bot]" ]] || + gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/labels" \ + --jq '.[].name' | grep -Fxq 'skip-changelog'; then + require_changelog=false + else + require_changelog=true + fi + + if [[ "$run_suite" == "true" || "$require_changelog" == "true" ]]; then + needs_python=true + else + needs_python=false + fi + echo "run_suite=$run_suite" >> "$GITHUB_OUTPUT" echo "run_container=$run_container" >> "$GITHUB_OUTPUT" + echo "require_changelog=$require_changelog" >> "$GITHUB_OUTPUT" + echo "needs_python=$needs_python" >> "$GITHUB_OUTPUT" + + - uses: actions/setup-python@v7 + if: steps.scope.outputs.needs_python == 'true' + with: + python-version: "3.11" + cache: pip + + - name: Install repository tooling + if: steps.scope.outputs.needs_python == 'true' + run: | + python -m pip install --upgrade pip + python -m pip install -r utils/build-requirements.txt + + - name: Require a changelog fragment + if: steps.scope.outputs.require_changelog == 'true' + run: towncrier check --compare-with "${{ github.event.pull_request.base.sha }}" - name: Install test surface if: steps.scope.outputs.run_suite == 'true' diff --git a/changes/19.bugfix.md b/changes/19.bugfix.md new file mode 100644 index 0000000..2c79f5a --- /dev/null +++ b/changes/19.bugfix.md @@ -0,0 +1 @@ +Prevent dependency updates and label changes from spawning redundant CI runs.