-
Notifications
You must be signed in to change notification settings - Fork 24
ci: skip tests/clippy/udeps for docs-only changes #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
1437f3f
a8149fd
e9e03a6
5a8fe95
7a55a40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: 'Check Docs Only Changes' | ||
| description: 'Check if only documentation files were changed' | ||
| outputs: | ||
| docs-only: | ||
| description: "True if only documentation files were changed" | ||
| value: ${{ steps.check.outputs.docs_only }} | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Check if only docs changed | ||
| id: check | ||
| shell: bash | ||
| run: | | ||
| # Determine the base SHA for comparison | ||
| if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
| # For PRs, compare against the base branch | ||
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | ||
| FILES_CHANGED=$(git diff --name-only "${BASE_SHA}"...HEAD) | ||
| else | ||
| # For pushes, compare with previous commit | ||
| FILES_CHANGED=$(git diff --name-only HEAD~1...HEAD 2>/dev/null || echo "") | ||
| fi | ||
| # Check if all changed files are in docs/ directory | ||
| if [ -z "$FILES_CHANGED" ]; then | ||
| echo "docs_only=false" >> $GITHUB_OUTPUT | ||
| echo "No files changed" | ||
| elif echo "$FILES_CHANGED" | grep -vE '^docs/' > /dev/null; then | ||
| echo "docs_only=false" >> $GITHUB_OUTPUT | ||
| echo "Non-documentation files changed" | ||
| else | ||
| echo "docs_only=true" >> $GITHUB_OUTPUT | ||
| echo "All changes are in docs/ folder, checks will pass automatically" | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,31 +19,54 @@ jobs: | |
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check for docs-only changes | ||
| id: docs-check | ||
| uses: ./.github/actions/check-docs-only | ||
|
|
||
| - name: Install Rust | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| toolchain: stable | ||
|
|
||
| - name: Setup Rust cache | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| shared-key: ${{ runner.os }} | ||
|
|
||
| - name: Install nextest | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: taiki-e/install-action@nextest | ||
| with: | ||
| tool: nextest | ||
|
|
||
| - name: Run all tests | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: cargo nextest run --profile ci | ||
|
|
||
| - name: Skip tests for docs-only changes | ||
| if: steps.docs-check.outputs.docs-only == 'true' | ||
| run: echo "✅ Skipping tests - only documentation changed" | ||
|
|
||
| test-linux: | ||
| name: Linux Tests | ||
| runs-on: [self-hosted, linux] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check for docs-only changes | ||
| id: docs-check | ||
| uses: ./.github/actions/check-docs-only | ||
|
|
||
| - name: Fix permissions from previous runs | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: | | ||
| # Clean up any files left from previous sudo runs before checkout | ||
| # Use GITHUB_WORKSPACE parent directory or current working directory | ||
|
||
|
|
@@ -55,14 +78,15 @@ jobs: | |
| if [ -d /home/ci/.cargo ]; then | ||
| sudo chown -R ci:ci /home/ci/.cargo || true | ||
| fi | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| toolchain: stable | ||
|
|
||
| - name: Fix permissions on current directory | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: | | ||
| # Clean up any files left from previous sudo runs | ||
| if [ -d target ]; then | ||
|
|
@@ -78,45 +102,57 @@ jobs: | |
| fi | ||
|
|
||
| - name: Setup Rust cache | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| shared-key: ${{ runner.os }} | ||
|
|
||
| - name: Setup Rust environment | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: | | ||
| source ~/.cargo/env | ||
| rustup default stable | ||
|
|
||
| - name: Install nextest | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: taiki-e/install-action@nextest | ||
| with: | ||
| tool: nextest | ||
|
|
||
| - name: Fix target directory permissions from previous runs | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: | | ||
| if [ -d target ]; then | ||
| sudo chown -R ci:ci target || true | ||
| fi | ||
|
|
||
| - name: Run all tests (non-root) | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: | | ||
| source ~/.cargo/env | ||
| cargo nextest run --profile ci --verbose -E 'not (binary(linux_integration) or binary(weak_integration))' | ||
|
|
||
| - name: Install dependencies for weak mode (curl) | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: sudo apt-get update && sudo apt-get install -y curl | ||
|
|
||
| - name: Run weak mode integration tests (Linux) | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: | | ||
| source ~/.cargo/env | ||
| cargo nextest run --profile ci --test weak_integration | ||
|
|
||
| - name: Run Linux jail integration tests (sudo) | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: | | ||
| source ~/.cargo/env | ||
| # Run Linux-specific jail tests with sudo to satisfy root requirements | ||
| sudo -E $(which cargo) nextest run --profile ci --test linux_integration --verbose | ||
|
|
||
| - name: Skip tests for docs-only changes | ||
| if: steps.docs-check.outputs.docs-only == 'true' | ||
| run: echo "✅ Skipping tests - only documentation changed" | ||
|
|
||
| clippy: | ||
| name: Clippy (${{ matrix.os }}) | ||
| runs-on: ${{ matrix.os }} | ||
|
|
@@ -126,21 +162,34 @@ jobs: | |
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check for docs-only changes | ||
| id: docs-check | ||
| uses: ./.github/actions/check-docs-only | ||
|
|
||
| - name: Install Rust | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| toolchain: stable | ||
| components: clippy | ||
|
|
||
| - name: Setup Rust cache | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| shared-key: ${{ runner.os }} | ||
|
|
||
| - name: Run clippy | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: cargo clippy --all-targets -- -D warnings | ||
|
|
||
| - name: Skip clippy for docs-only changes | ||
| if: steps.docs-check.outputs.docs-only == 'true' | ||
| run: echo "✅ Skipping clippy - only documentation changed" | ||
|
|
||
| fmt: | ||
| name: Format | ||
| runs-on: ubuntu-latest-8-cores | ||
|
|
@@ -168,21 +217,31 @@ jobs: | |
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check for docs-only changes | ||
| id: docs-check | ||
| uses: ./.github/actions/check-docs-only | ||
|
|
||
| - name: Install Rust (nightly for cargo-udeps) | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| toolchain: nightly | ||
|
|
||
| - name: Setup Rust cache | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| shared-key: ${{ runner.os }} | ||
|
|
||
| - name: Install cargo-udeps | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| uses: taiki-e/install-action@cargo-udeps | ||
|
|
||
| - name: Check for unused dependencies | ||
| if: steps.docs-check.outputs.docs-only != 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| # Run with nightly; capture output without failing the step | ||
|
|
@@ -206,3 +265,7 @@ jobs: | |
| echo "Unused dependencies detected" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Skip udeps for docs-only changes | ||
| if: steps.docs-check.outputs.docs-only == 'true' | ||
| run: echo "✅ Skipping unused dependency check - only documentation changed" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Diff all commits when skipping checks on push
The composite action only compares
HEAD~1...HEADfor push events, so a push containing multiple commits will examine only the last commit. If a developer pushes a code change followed by a documentation change in the same push, the workflow reportsdocs_only=truebased solely on the final commit and all test/clippy/udeps jobs are skipped even though code was modified in the earlier commit. To cover the whole push you need to diffgithub.event.before(or the merge base) againstgithub.sha.Useful? React with 👍 / 👎.