1
- # Copyright 2023-2023 the original author or authors.
1
+ # Copyright 2023-2023 the original author or authors.
2
2
#
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
6
#
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
7
+ # http://www.apache.org/licenses/LICENSE-2.0
14
8
#
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
15
14
#
16
15
#
17
16
@@ -20,25 +19,68 @@ name: Java 17 CI with Maven
20
19
on :
21
20
push :
22
21
branches : [ main ]
23
- # Each pull request is important to us, doesn't matter from which branch.
24
- # Furthermore, we do not want to build on just the default GitHub Action
25
- # events, we also want to react onto `labeled` events for our extended
26
- # build execution
27
22
pull_request :
28
23
types : [ labeled, opened, synchronize, reopened ]
29
24
30
25
jobs :
31
26
build :
32
-
33
27
runs-on : ubuntu-latest
34
28
35
29
steps :
36
30
- uses : actions/checkout@v3
31
+
37
32
- name : Set up JDK 17
38
33
uses : actions/setup-java@v3
39
34
with :
40
35
distribution : ' temurin'
41
36
java-version : 17
42
37
cache : maven
38
+
43
39
- name : Build with Maven
44
- run : mvn -B verify -P java-17,run-its
40
+ run : mvn -B verify -P java-17,run-its
41
+
42
+ - name : Generate JaCoCo badge
43
+ id : jacoco
44
+
45
+ with :
46
+ badges-directory : .github/badges
47
+ generate-branches-badge : true
48
+ generate-summary : true
49
+ summary-filename : coverage-summary_java-17.json
50
+ coverage-badge-filename : jacoco_java-17.svg
51
+ branches-badge-filename : branches_java-17.svg
52
+ coverage-endpoint-filename : jacoco_java-17.json
53
+ branches-endpoint-filename : branches_java-17.json
54
+
55
+ - name : Log coverage percentages to workflow output
56
+ run : |
57
+ echo "(java-17) coverage = ${{ steps.jacoco.outputs.coverage }}%"
58
+ echo "(java-17) branches = ${{ steps.jacoco.outputs.branches }}%"
59
+
60
+ - name : Upload JaCoCo coverage report
61
+ uses : actions/upload-artifact@v4
62
+ with :
63
+ name : jacoco-report-java-17
64
+ path : target/site/jacoco/
65
+
66
+ - name : Deploy to Coverage Branch
67
+ if : ${{ github.event_name != 'pull_request' }}
68
+ uses : crazy-max/ghaction-github-pages@v4
69
+ with :
70
+ target_branch : coverage
71
+ build_dir : .github/badges
72
+ env :
73
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
74
+
75
+ - name : Comment on PR with coverage percentages
76
+ if : ${{ github.event_name == 'pull_request' }}
77
+ run : |
78
+ REPORT=$(<.github/badges/coverage-summary_java-17.json)
79
+ COVERAGE=$(jq -r '.coverage' <<< "$REPORT")%
80
+ BRANCHES=$(jq -r '.branches' <<< "$REPORT")%
81
+ NEWLINE=$'\n'
82
+ BODY="## JaCoCo Test Coverage Summary Statistics (java-17) ${NEWLINE}* __Coverage:__ ${COVERAGE}${NEWLINE}* __Branches:__ ${BRANCHES}"
83
+ gh pr comment ${{github.event.pull_request.number}} -b "${BODY}"
84
+ continue-on-error : true
85
+ env :
86
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments