Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/actions/check-docs-only/action.yml
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 "")
Comment on lines +14 to +21

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...HEAD for 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 reports docs_only=true based 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 diff github.event.before (or the merge base) against github.sha.

Useful? React with 👍 / 👎.

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
65 changes: 64 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Run Linux permission fix before checkout

The Linux job now checks out the repository before running the Fix permissions from previous runs step and the cleanup only runs when docs_only is false. On the self‑hosted runner the checkout frequently fails unless the workspace and cargo caches are chowned back to the ci user before the repository is fetched. When a previous run leaves root‑owned files (e.g., after the sudo integration tests) a docs‑only push will now skip the permission fix entirely, allowing the next run’s checkout to fail. Move the permission cleanup ahead of checkout and run it regardless of the docs‑only result to keep the runner usable.

Useful? React with 👍 / 👎.

Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"