Skip to content

Conversation

@ammario
Copy link
Member

@ammario ammario commented Sep 23, 2025

Summary

This PR optimizes CI performance for documentation-only changes by implementing a DRY solution that makes tests, clippy, and unused dependency checks pass immediately when only docs are modified.

Changes

  • Created a reusable composite action .github/actions/check-docs-only that detects documentation-only changes
  • Modified the test workflow to use this action and conditionally skip expensive checks
  • All CI checks still appear green (return success) but skip execution for docs-only changes

Benefits

  • Faster CI for docs PRs: No need to wait for tests/clippy/udeps when only documentation changes
  • DRY implementation: Single source of truth for docs detection logic
  • Maintainable: Easy to update detection logic in one place
  • All checks remain green: Required status checks still pass

Test Plan

This PR itself serves as a test - it contains only documentation changes in previous commits, so the CI should demonstrate the optimization working correctly.

🤖 Generated with Claude Code

Implemented a DRY approach using a composite action that detects when
only documentation files have changed. This speeds up CI for docs-only
PRs while keeping all checks green.

- Created reusable composite action '.github/actions/check-docs-only'
- Refactored workflow to use the composite action across all jobs
- Tests, clippy, and udeps checks now pass immediately for docs-only changes
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines +14 to +21
# 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 "")

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 👍 / 👎.

Comment on lines 60 to 72
- 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 👍 / 👎.

Refactored the workflow to use a cleaner pattern with:
- Single 'detect-docs-only' job that runs first
- Job-level conditions (single if per job) instead of step-level
- Placeholder jobs for skipped checks to ensure status remains green
- No more repetitive if statements on every step

This approach is more maintainable and follows GitHub Actions best practices
for conditional job execution.
Jobs must run (not be skipped) to satisfy GitHub's required status checks.
This approach:
- Keeps all job names the same (satisfies required checks)
- Uses conditional steps instead of skipping entire jobs
- Jobs run but complete quickly when docs-only changes detected
- All required status checks will show as passed, not pending
Implemented the 'all-checks-pass' pattern using re-actors/alls-green action.
This approach:
- Uses a single required status check 'All checks pass'
- Allows jobs to be genuinely skipped for docs-only changes
- Eliminates repetitive if conditions on every step
- Provides cleaner workflow with job-level conditions only
- Better GitHub UI experience showing skipped vs passed

Branch protection should be updated to only require 'All checks pass' status
instead of individual job statuses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant