File tree Expand file tree Collapse file tree 2 files changed +52
-16
lines changed
actions/pit-results-badge Expand file tree Collapse file tree 2 files changed +52
-16
lines changed Original file line number Diff line number Diff line change
1
+ name : Create Shields.io badge from PIT mutation test results
2
+ author :
Emil Lundberg <[email protected] >
3
+ description : |
4
+ Parses a [PIT][pitest] report file and outputs a [Shields.io][shields]
5
+ [endpoint badge][endpoint] definition file.
6
+
7
+ [endpoint]: https://shields.io/endpoint
8
+ [pitest]: https://pitest.org/
9
+ [shields]: https://shields.io/
10
+
11
+ inputs :
12
+ cache-seconds :
13
+ default : 3600
14
+ description : Passed through as cacheSeconds to Shields.io.
15
+
16
+ label :
17
+ default : " mutation coverage"
18
+ description : Label for the left side of the badge.
19
+
20
+ mutations-file :
21
+ default : build/reports/pitest/mutations.xml
22
+ description : Path to the PIT report XML file.
23
+
24
+ output-file :
25
+ required : true
26
+ description : Path to write output file to.
27
+
28
+ runs :
29
+ using : " composite"
30
+
31
+ steps :
32
+ - name : Install yq (and xq)
33
+ shell : bash
34
+ run : pip install yq
35
+
36
+ - name : Create coverage badge
37
+ shell : bash
38
+ run : |
39
+ cat ${{ inputs.mutations-file }} \
40
+ | xq '.mutations.mutation
41
+ | (map(select(.["@detected"] == "true")) | length) / length
42
+ | {
43
+ schemaVersion: 1,
44
+ label: "${{ inputs.label }}",
45
+ message: "\(. * 100 | floor | tostring) %",
46
+ color: "hsl(\(. * 120 | floor | tostring), 100%, 40%",
47
+ cacheSeconds: ${{ inputs.cache-seconds }},
48
+ }' \
49
+ > ${{ inputs.output-file }}
Original file line number Diff line number Diff line change 33
33
name : pitest-reports-${{ github.sha }}
34
34
path : " */build/reports/pitest/**"
35
35
36
- - name : Install yq (and xq)
37
- run : |
38
- pip install yq
39
-
40
36
- name : Create output directory
41
37
run : mkdir -p build/gh-pages
42
38
51
47
- name : Create coverage badge
52
48
# This creates a file that defines a [Shields.io endpoint badge](https://shields.io/endpoint)
53
49
# which we can then include in the project README.
54
- run : |
55
- cat build/reports/pitest/mutations.xml \
56
- | xq '.mutations.mutation
57
- | (map(select(.["@detected"] == "true")) | length) / length
58
- | {
59
- schemaVersion: 1,
60
- label: "mutation coverage",
61
- message: "\(. * 100 | floor | tostring) %",
62
- color: "hsl(\(. * 120 | floor | tostring), 100%, 40%",
63
- cacheSeconds: 3600,
64
- }' \
65
- > build/gh-pages/coverage-badge.json
50
+ uses : ./.github/actions/pit-results-badge
51
+ with :
52
+ output-file : build/gh-pages/coverage-badge.json
66
53
67
54
- name : Check out GitHub Pages branch
68
55
uses : actions/checkout@v3
You can’t perform that action at this time.
0 commit comments