diff --git a/.github/actions/check-docs-only/action.yml b/.github/actions/check-docs-only/action.yml new file mode 100644 index 00000000..a980674e --- /dev/null +++ b/.github/actions/check-docs-only/action.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c1daec97..7c30a630 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,10 +13,34 @@ env: RUST_BACKTRACE: 1 jobs: + # Detection job that runs first and determines if only docs changed + detect-docs-only: + name: Detect docs-only changes + runs-on: ubuntu-latest + outputs: + docs-only: ${{ steps.docs-check.outputs.docs-only }} + 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: Display detection result + run: | + if [[ "${{ steps.docs-check.outputs.docs-only }}" == "true" ]]; then + echo "📚 Documentation-only changes detected - expensive checks will be skipped" + else + echo "🔧 Code changes detected - all checks will run" + fi + test-macos: name: macOS Integration Tests runs-on: macos-15-xlarge - + needs: detect-docs-only + if: needs.detect-docs-only.outputs.docs-only != 'true' steps: - uses: actions/checkout@v4 @@ -41,7 +65,8 @@ jobs: test-linux: name: Linux Tests runs-on: [self-hosted, linux] - + needs: detect-docs-only + if: needs.detect-docs-only.outputs.docs-only != 'true' steps: - name: Fix permissions from previous runs run: | @@ -55,6 +80,7 @@ jobs: if [ -d /home/ci/.cargo ]; then sudo chown -R ci:ci /home/ci/.cargo || true fi + - uses: actions/checkout@v4 - name: Install Rust @@ -120,10 +146,11 @@ jobs: clippy: name: Clippy (${{ matrix.os }}) runs-on: ${{ matrix.os }} + needs: detect-docs-only + if: needs.detect-docs-only.outputs.docs-only != 'true' strategy: matrix: os: [ubuntu-latest-8-cores, macos-latest] - steps: - uses: actions/checkout@v4 @@ -144,7 +171,7 @@ jobs: fmt: name: Format runs-on: ubuntu-latest-8-cores - + # Format always runs - even for docs changes we want consistent formatting steps: - uses: actions/checkout@v4 @@ -165,7 +192,8 @@ jobs: udeps: name: Unused dependency check runs-on: ubuntu-latest-8-cores - + needs: detect-docs-only + if: needs.detect-docs-only.outputs.docs-only != 'true' steps: - uses: actions/checkout@v4 @@ -206,3 +234,21 @@ jobs: echo "Unused dependencies detected" exit 1 fi + + # Single required job that depends on all others + # This should be the ONLY required status check in branch protection + all-checks-pass: + name: All checks pass + if: always() + needs: + - test-macos + - test-linux + - clippy + - fmt + - udeps + runs-on: ubuntu-latest + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} \ No newline at end of file