Skip to content

Commit fd60d92

Browse files
committed
ci: update workflows to improve JaCoCo coverage reporting and deployment conditions
1 parent c1856bb commit fd60d92

2 files changed

Lines changed: 39 additions & 27 deletions

File tree

.github/workflows/build-test.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,14 @@ jobs:
7171
COPILOT_CLI_PATH: ${{ steps.setup-copilot.outputs.path }}
7272
run: mvn verify
7373

74-
- name: Generate Test Report Summary
75-
if: always()
76-
uses: ./.github/actions/test-report
77-
78-
- name: Upload Test Reports
79-
uses: actions/upload-artifact@v6
80-
if: always()
74+
- name: Upload JaCoCo exec for site generation
75+
if: success() && github.ref == 'refs/heads/main'
76+
uses: actions/upload-artifact@v4
8177
with:
82-
name: test-reports
83-
path: target/surefire-reports/
84-
retention-days: 14
78+
name: jacoco-exec
79+
path: target/jacoco-test-results/sdk-tests.exec
80+
retention-days: 1
8581

86-
- name: Upload Coverage Report
87-
uses: actions/upload-artifact@v6
82+
- name: Generate Test Report Summary
8883
if: always()
89-
with:
90-
name: coverage-report
91-
path: target/site/jacoco-coverage/
92-
retention-days: 14
84+
uses: ./.github/actions/test-report

.github/workflows/deploy-site.yml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
name: Deploy Documentation
33

44
on:
5-
# Runs on pushes targeting the default branch (publishes to /snapshot/)
6-
push:
7-
branches: ["main"]
8-
paths:
9-
- 'pom.xml'
10-
- 'src/**'
11-
- '.github/**'
5+
# Runs after Build & Test succeeds on main (publishes to /snapshot/)
6+
workflow_run:
7+
workflows: ["Build & Test"]
8+
types: [completed]
9+
branches: [main]
1210

1311
# Runs on release publish (publishes to /latest/ and /vX.Y.Z/)
1412
release:
@@ -43,6 +41,8 @@ concurrency:
4341

4442
jobs:
4543
build-and-deploy:
44+
# Skip if triggered by workflow_run that failed
45+
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
4646
runs-on: ubuntu-latest
4747
environment:
4848
name: github-pages
@@ -111,11 +111,31 @@ jobs:
111111
echo "is_release=false" >> $GITHUB_OUTPUT
112112
fi
113113
114+
- name: Download JaCoCo exec from Build & Test
115+
if: steps.tags.outputs.is_release == 'false' && inputs.rebuild_all_versions != true && github.event_name == 'workflow_run'
116+
uses: actions/download-artifact@v4
117+
with:
118+
name: jacoco-exec
119+
path: /tmp/jacoco-exec
120+
run-id: ${{ github.event.workflow_run.id }}
121+
github-token: ${{ secrets.GITHUB_TOKEN }}
122+
continue-on-error: true
123+
114124
- name: Build snapshot documentation (main branch)
115125
if: steps.tags.outputs.is_release == 'false' && inputs.rebuild_all_versions != true
116126
run: |
117-
# Run tests with JaCoCo coverage for snapshot builds
118-
./mvnw clean verify site -Dcheckstyle.skip=true
127+
# Compile sources (needed for javadoc and other reports)
128+
./mvnw clean compile -DskipTests -Dcheckstyle.skip=true
129+
130+
# Restore JaCoCo exec if available from Build & Test
131+
if [ -f "/tmp/jacoco-exec/sdk-tests.exec" ]; then
132+
mkdir -p target/jacoco-test-results
133+
cp /tmp/jacoco-exec/sdk-tests.exec target/jacoco-test-results/
134+
echo "JaCoCo exec restored — coverage report will be included"
135+
fi
136+
137+
# Generate site (JaCoCo report plugin picks up the exec file)
138+
./mvnw site -DskipTests -Dcheckstyle.skip=true
119139
120140
rm -rf "site/snapshot"
121141
mkdir -p "site/snapshot"
@@ -172,9 +192,9 @@ jobs:
172192
173193
done <<< "${{ steps.tags.outputs.all_tags }}"
174194
175-
# Return to main and build snapshot with JaCoCo coverage
195+
# Return to main and build snapshot
176196
git checkout main
177-
./mvnw clean verify site -Dcheckstyle.skip=true
197+
./mvnw clean site -DskipTests -Dcheckstyle.skip=true
178198
179199
rm -rf "site/snapshot"
180200
mkdir -p "site/snapshot"

0 commit comments

Comments
 (0)