diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3978ef5f7..b75f96b96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,10 +51,39 @@ jobs: continue-on-error: true steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + fetch-depth: 0 + + # Detect whether this PR only touches documentation files. + # If so, skip the expensive pytest run while still reporting a passing check. + - name: Check for docs-only changes + id: docs-check + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + BASE="${{ github.event.pull_request.base.sha }}" + HEAD="${{ github.event.pull_request.head.sha }}" + else + BASE="${{ github.event.before }}" + HEAD="${{ github.sha }}" + fi + # List all changed files; if every file matches docs/markdown patterns, skip pytest. + changed=$(git diff --name-only "$BASE" "$HEAD" 2>/dev/null || git diff --name-only HEAD~1 HEAD) + non_docs=$(echo "$changed" | grep -Ev '^(docs/|.*\.md$|\.github/[^/]+\.md$)' || true) + if [ -z "$non_docs" ]; then + echo "docs_only=true" >> "$GITHUB_OUTPUT" + echo "Docs-only change detected — skipping pytest." + else + echo "docs_only=false" >> "$GITHUB_OUTPUT" + fi + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 + if: steps.docs-check.outputs.docs_only != 'true' with: python-version: "3.11" cache: pip - run: pip install -r requirements.txt + if: steps.docs-check.outputs.docs_only != 'true' - run: mkdir -p data # sqlite DB lives at ./data/app.db + if: steps.docs-check.outputs.docs_only != 'true' - run: python -m pytest -q + if: steps.docs-check.outputs.docs_only != 'true'