forked from webview/webview
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (130 loc) · 4.77 KB
/
ci.yaml
File metadata and controls
145 lines (130 loc) · 4.77 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
name: CI
on: [push, pull_request]
defaults:
run:
shell: bash
jobs:
check:
uses: ./.github/workflows/check.yaml
vars:
runs-on: ubuntu-22.04
outputs:
gcovr-version: ${{ steps.vars.outputs.gcovr-version }}
steps:
- id: vars
run: |
echo "gcovr-version=7.2" >> "${GITHUB_OUTPUT}"
shell: bash
build:
needs:
- check
- vars
uses: ./.github/workflows/build.yaml
with:
gcovr-version: ${{ needs.vars.outputs.gcovr-version }}
build-pr:
if: github.event_name == 'pull_request'
needs:
- check
- vars
uses: ./.github/workflows/build.yaml
with:
gcovr-version: ${{ needs.vars.outputs.gcovr-version }}
pr: true
merge-package-artifacts:
needs: build
runs-on: ubuntu-22.04
steps:
- name: Merge package artifacts
uses: actions/upload-artifact/merge@v4
with:
name: package
pattern: package_*
delete-merged: true
retention-days: 1
generate-coverage-report:
needs:
- build
- vars
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python
run: >
sudo apt-get update && sudo apt-get install --no-install-recommends -y
python3
python3-lxml
python3-markupsafe
python3-pip
- name: Install gcovr
run: pip install "gcovr==${{ needs.vars.outputs.gcovr-version }}"
- name: Merge test coverage artifacts
uses: actions/upload-artifact/merge@v4
with:
name: test_coverage_data
pattern: test_coverage_data_*
delete-merged: true
retention-days: 1
separate-directories: true
- name: Download merged test coverage artifacts
uses: actions/download-artifact@v4
with:
name: test_coverage_data
- name: Generate report
id: generate-report
run: |
tracefile_args=()
while read f; do
tracefile_args+=(--add-tracefile "${f}")
done <<< "$(find . -type f -name "coverage.json")"
artifact_dir="temp_${RANDOM}/report"
mkdir -p "${artifact_dir}/html"
gcovr --config gcovr.ci.cfg --json "${artifact_dir}/gcovr.json" "${tracefile_args[@]}"
gcovr --config gcovr.ci.cfg --coveralls "${artifact_dir}/coveralls.json" --add-tracefile "${artifact_dir}/gcovr.json"
gcovr --config gcovr.ci.cfg --json-summary "${artifact_dir}/summary.json" --add-tracefile "${artifact_dir}/gcovr.json"
gcovr --config gcovr.ci.cfg --html-details "${artifact_dir}/html/index.html" --add-tracefile "${artifact_dir}/gcovr.json"
echo "upload-dir=${artifact_dir}" >> "${GITHUB_OUTPUT}"
- name: Upload report artifacts
uses: actions/upload-artifact@v4
with:
name: test_coverage_report
path: ${{ steps.generate-report.outputs.upload-dir }}
retention-days: 1
if-no-files-found: error
- name: Add report to CI job summary
uses: actions/github-script@v7
with:
script: |
const numberOr = (value, alternative) => Number.isNaN(value = parseInt(value)) ? alternative : value;
const percentValue = (value, percentSymbol = "%") => numberOr(value, "-") + percentSymbol;
const data = require("./${{ steps.generate-report.outputs.upload-dir }}/summary.json");
await core.summary
.addHeading("Test Coverage Summary")
.addTable([
[
{ data: "Lines", header: true },
{ data: "Functions", header: true },
{ data: "Branches", header: true }
],
[
`${percentValue(data.line_percent)} ${data.line_covered}/${data.line_total}`,
`${percentValue(data.function_percent)} ${data.function_covered}/${data.function_total}`,
`${percentValue(data.branch_percent)} ${data.branch_covered}/${data.branch_total}`
]
])
.addTable([
[
{ data: "File", header: true },
{ data: "Lines", header: true },
{ data: "Functions", header: true },
{ data: "Branches", header: true }
],
...data.files.map(file => [
file.filename,
`${percentValue(file.line_percent)} ${file.line_covered}/${file.line_total}`,
`${percentValue(file.function_percent)} ${file.function_covered}/${file.function_total}`,
`${percentValue(file.branch_percent)} ${file.branch_covered}/${file.branch_total}`
])
])
.write();