From c686cbd531e594d4693495c6663aa68c97a1efa5 Mon Sep 17 00:00:00 2001 From: Irakli Kourtis Date: Tue, 13 Oct 2026 19:43:36 -0400 Subject: [PATCH] ci: skip the build jobs for pull requests that only change Markdown or docs/ (#34) docs/features.md still counts as code (a test checks it against the catalogue). Pushes to main and manual runs always run every job. Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ab0d3b..7dadf72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,45 @@ env: CARGO_TERM_COLOR: always jobs: + # Pull requests that only touch Markdown or docs/ skip the build jobs (they still report, as + # skipped). Pushes to main and manual runs always run everything. + changes: + name: Select checks + runs-on: ubuntu-24.04 + outputs: + code: ${{ steps.paths.outputs.code }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + - id: paths + name: Detect code changes + env: + EVENT_NAME: ${{ github.event_name }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + if [ "$EVENT_NAME" != "pull_request" ]; then + echo "code=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + changed=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA") + code=false + while IFS= read -r f; do + case "$f" in + docs/features.md) code=true ;; + *.md|docs/*) ;; + "") ;; + *) code=true ;; + esac + done <<< "$changed" + echo "code=$code" >> "$GITHUB_OUTPUT" + echo "code changes: $code" + ci: name: cargo xtask ci + needs: changes + if: needs.changes.outputs.code == 'true' runs-on: ubuntu-24.04 timeout-minutes: 60 steps: @@ -32,6 +69,8 @@ jobs: advisories: name: Dependency advisories and sources + needs: changes + if: needs.changes.outputs.code == 'true' runs-on: ubuntu-24.04 timeout-minutes: 20 steps: