Skip to content

Commit 8117135

Browse files
committed
skip unit tests and doc check for sample-only changes in openapi-generator.yaml
1 parent eab54b1 commit 8117135

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

.github/workflows/openapi-generator.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,38 @@ on:
1111
- '[5-9]+.[0-9]+.x'
1212

1313
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+
1446
build:
1547
name: Build
1648
runs-on: ubuntu-latest
@@ -52,7 +84,10 @@ jobs:
5284
name: Unit tests
5385
runs-on: ubuntu-latest
5486
needs:
87+
- setup
5588
- build
89+
# Unit tests are not affected by sample-only changes — skip to save CI time.
90+
if: needs.setup.outputs.source-changed == 'true'
5691
steps:
5792
- uses: actions/checkout@v5
5893
- name: Set up JDK 11
@@ -90,7 +125,10 @@ jobs:
90125
name: Docs up-to-date
91126
runs-on: ubuntu-latest
92127
needs:
128+
- setup
93129
- build
130+
# Docs are generated from codegen metadata — skipped when only samples changed.
131+
if: needs.setup.outputs.source-changed == 'true'
94132
steps:
95133
- uses: actions/checkout@v5
96134
- name: Set up JDK 11

0 commit comments

Comments
 (0)