-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (107 loc) · 4.5 KB
/
c-cpp.yml
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
name: Build
on:
push:
jobs:
build-project:
name: Build Project
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/[email protected]
- name: Fetch master
run: |
git fetch --no-tags --prune --depth=1 origin master
- name: Setup Ninja
uses: seanmiddleditch/gha-setup-ninja@v5
- name: Build Project
uses: threeal/[email protected]
with:
generator: Ninja
options: |
CMAKE_EXPORT_COMPILE_COMMANDS=ON
ENABLE_COVERAGE=ON
run-build: false
- name: Get modified source
id: get-modified-source
uses: actions/github-script@v7
with:
script: |
const diff = require('./scripts/diff.js');
return diff();
- name: Get affected targets
id: find-targets
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const targets = require('./scripts/targets.js');
return targets('${{steps.get-modified-source.outputs.result}} ');
- name: Build affected targets
if: ${{steps.find-targets.outputs.result != ''}}
run: ninja -C build ${{steps.find-targets.outputs.result}}
- name: Run ctest
if: ${{steps.find-targets.outputs.result != ''}}
run: ctest --test-dir build
- name: Generate a code coverage report
if: ${{steps.find-targets.outputs.result != ''}}
uses: threeal/gcovr-action@xml-out
with:
xml-out: coverage.xml
- run: npm install xml2js
- name: Check coverage report
id: check-coverage
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const parseString = require('xml2js').parseString;
const result = await new Promise((resolve, reject) => parseString(fs.readFileSync('coverage.xml', 'utf8'), (err, result) => {
if (err) reject(err);
else resolve(result);
}));
console.log('${{ github.base_ref }}');
console.log('${{ github.head_ref }}');
console.log('${{ github.ref }}');
console.log('${{ github.ref_name }}');
console.log('${{ github.path }}');
# "packages": [
# {
# "package": [
# {
# "$": {
# "name": "src",
# "line-rate": "0.5",
# "branch-rate": "0.5",
# "complexity": "0.0"
# },
# "classes": [
# {
# "class": [
# {
# "$": {
# "name": "main_cpp",
# "filename": "src/main.cpp",
# "line-rate": "0.0",
# "branch-rate": "1.0",
# "complexity": "0.0"
# },
# "methods": [
# ""
# ],
# "lines": [
# {
# "line": [
# {
# "$": {
# "number": "6",
# "hits": "0",
# "branch": "false"
# }
# },
# {
# "$": {
# "number": "7",
# "hits": "0",
# "branch": "false"
# }
# },