|
11 | 11 | - '[5-9]+.[0-9]+.x' |
12 | 12 |
|
13 | 13 | jobs: |
| 14 | + # Detect whether source files (modules/, pom.xml, bin/) changed. |
| 15 | + # When only samples/ changed, the unit tests and doc checks are skipped — they are |
| 16 | + # not affected by sample-only changes and the samples job still runs to verify freshness. |
| 17 | + setup: |
| 18 | + name: Detect source changes |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + source-changed: ${{ steps.check.outputs.source-changed }} |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v5 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + - id: check |
| 27 | + shell: bash |
| 28 | + env: |
| 29 | + BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }} |
| 30 | + HEAD_SHA: ${{ github.sha }} |
| 31 | + run: | |
| 32 | + if [[ "$BASE_SHA" == "0000000000000000000000000000000000000000" ]] || [[ -z "$BASE_SHA" ]]; then |
| 33 | + BASE_SHA=$(git rev-parse HEAD~1 2>/dev/null || echo "") |
| 34 | + fi |
| 35 | + if [[ -n "$BASE_SHA" ]]; then |
| 36 | + CHANGED=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" 2>/dev/null || git diff --name-only HEAD~1 HEAD) |
| 37 | + else |
| 38 | + CHANGED=$(git diff --name-only HEAD~1 HEAD) |
| 39 | + fi |
| 40 | + if echo "$CHANGED" | grep -qE '^(modules/|pom\.xml|bin/|\.mvn/)'; then |
| 41 | + echo "source-changed=true" >> "$GITHUB_OUTPUT" |
| 42 | + else |
| 43 | + echo "source-changed=false" >> "$GITHUB_OUTPUT" |
| 44 | + fi |
| 45 | +
|
14 | 46 | build: |
15 | 47 | name: Build |
16 | 48 | runs-on: ubuntu-latest |
|
52 | 84 | name: Unit tests |
53 | 85 | runs-on: ubuntu-latest |
54 | 86 | needs: |
| 87 | + - setup |
55 | 88 | - build |
| 89 | + # Unit tests are not affected by sample-only changes — skip to save CI time. |
| 90 | + if: needs.setup.outputs.source-changed == 'true' |
56 | 91 | steps: |
57 | 92 | - uses: actions/checkout@v5 |
58 | 93 | - name: Set up JDK 11 |
@@ -90,7 +125,10 @@ jobs: |
90 | 125 | name: Docs up-to-date |
91 | 126 | runs-on: ubuntu-latest |
92 | 127 | needs: |
| 128 | + - setup |
93 | 129 | - build |
| 130 | + # Docs are generated from codegen metadata — skipped when only samples changed. |
| 131 | + if: needs.setup.outputs.source-changed == 'true' |
94 | 132 | steps: |
95 | 133 | - uses: actions/checkout@v5 |
96 | 134 | - name: Set up JDK 11 |
|
0 commit comments