Skip to content

Commit 83dc287

Browse files
authored
ci: improve workflow with two-stage build/test pipeline (#692)
- Split into build and test jobs (test depends on build) - Add Java 17/21 test matrix - Add Maven dependency caching - Add concurrency control to cancel stale runs - Add publish test results via EnricoMi/publish-unit-test-result-action - Upload surefire reports as artifacts on failure - Add least-privilege permissions - Expand paths-ignore for docs
1 parent ae30941 commit 83dc287

1 file changed

Lines changed: 63 additions & 1 deletion

File tree

.github/workflows/main.yml

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,21 @@ on:
2828
- '.asf.yml'
2929
- 'LICENSE'
3030
- 'NOTICE'
31+
- '**/*.md'
32+
- 'docs/**'
33+
34+
permissions:
35+
contents: read
36+
checks: write
37+
38+
concurrency:
39+
group: ${{ github.workflow }}-${{ github.ref }}
40+
cancel-in-progress: true
3141

3242
jobs:
3343
build:
3444
runs-on: ubuntu-latest
45+
name: Build
3546
steps:
3647
- name: Free disk space
3748
run: |
@@ -45,4 +56,55 @@ jobs:
4556
with:
4657
java-version: 17
4758
distribution: zulu
48-
- run: ./mvnw -V --no-transfer-progress clean install -Ddump.logs.on.failure=true
59+
cache: maven
60+
- run: ./mvnw -V --no-transfer-progress clean install -DskipTests
61+
- name: Upload build artifacts
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: build-artifacts
65+
path: |
66+
**/target/*.jar
67+
**/target/classes/
68+
**/target/test-classes/
69+
retention-days: 1
70+
71+
test:
72+
runs-on: ubuntu-latest
73+
needs: build
74+
strategy:
75+
fail-fast: false
76+
matrix:
77+
java-version: ['17', '21']
78+
name: Test (Java ${{ matrix.java-version }})
79+
steps:
80+
- name: Free disk space
81+
run: |
82+
sudo rm -rf /usr/share/dotnet \
83+
/opt/ghc \
84+
"/usr/local/share/boost" \
85+
"$AGENT_TOOLSDIRECTORY"
86+
docker system prune -af
87+
- uses: actions/checkout@v4
88+
- uses: actions/setup-java@v4
89+
with:
90+
java-version: ${{ matrix.java-version }}
91+
distribution: zulu
92+
cache: maven
93+
- name: Download build artifacts
94+
uses: actions/download-artifact@v4
95+
with:
96+
name: build-artifacts
97+
- run: ./mvnw -V --no-transfer-progress verify -Ddump.logs.on.failure=true
98+
- name: Publish test results
99+
if: always()
100+
uses: EnricoMi/publish-unit-test-result-action@v2
101+
with:
102+
files: '**/target/surefire-reports/*.xml'
103+
check_name: Test Results (Java ${{ matrix.java-version }})
104+
- name: Upload test reports
105+
if: failure()
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: test-reports-java-${{ matrix.java-version }}
109+
path: '**/target/surefire-reports/'
110+
retention-days: 7

0 commit comments

Comments
 (0)