-
Notifications
You must be signed in to change notification settings - Fork 5
155 lines (120 loc) · 4.06 KB
/
Copy pathbuild.yml
File metadata and controls
155 lines (120 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: build
on: [push]
jobs:
run-gradle-build:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Run Gradle build
run: |
./gradlew build
rm build/reports/jacoco/test/html/jacoco-sessions.html
- name: Upload JaCoCo coverage artifact
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage
path: build/reports/jacoco/test/html
publish-jacoco-coverage:
if: ${{ always() && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: run-gradle-build
outputs:
COVERAGE_PERCENT: ${{ steps.coverage-percent.outputs.COVERAGE_PERCENT }}
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Download JaCoCo coverage artifact
uses: actions/download-artifact@v4
with:
name: jacoco-coverage
path: pages/coverage
- name: Extract coverage percent
id: coverage-percent
run: |
echo "COVERAGE_PERCENT=$(grep -oP '>\K([0-9]+)(?=%)' pages/coverage/index.html | head -n 1)" >> $GITHUB_OUTPUT
- name: Publish coverage report
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: pages/coverage
target-folder: coverage
publish-delta-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
- name: Run delta coverage
run: ./gradlew test deltaCoverage
- name: Publish summary
run: cat build/reports/coverage-reports/delta-coverage/report.md >> $GITHUB_STEP_SUMMARY
- name: Add disclaimer
run: echo "The summary table will list class files and percent changes on each row, with totals at the bottom. If you have no class file changes, your totals will show NaN%. Run ./gradlew test deltaCoverage locally to view line-by-line changes. [Plugin Documentation](https://gw-kit.github.io/delta-coverage-plugin/stable/)" >> $GITHUB_STEP_SUMMARY
update-build-badges:
if: ${{ always() && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [run-gradle-build, publish-jacoco-coverage]
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Generate coverage badge
uses: knightdave/anybadge-action@v1.1.0
with:
file: docs/badges/coverage.svg
label: coverage
value: ${{ needs.publish-jacoco-coverage.outputs.COVERAGE_PERCENT }}
value_format: "%d%%"
anybadge_args: 50=red 60=orange 80=yellow 100=green
template: docs/badges/template.svg
overwrite: true
- name: Get build result
run: |
if [[ ${{ needs.run-gradle-build.result }} == "success" || ${{ needs.run-gradle-build.result }} == "skipped" ]]; then
exit 0
else
exit 1
fi
- name: Generate passing badge
if: success()
uses: knightdave/anybadge-action@v1.1.0
with:
file: docs/badges/build.svg
label: build
value: passing
color: green
template: docs/badges/template.svg
overwrite: true
- name: Generate failing badge
if: failure()
uses: knightdave/anybadge-action@v1.1.0
with:
file: docs/badges/build.svg
label: build
value: failing
color: red
template: docs/badges/template.svg
overwrite: true
- name: Publish badge
if: success() || failure()
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs/badges
target-folder: badges
clean: false