-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (125 loc) · 3.96 KB
/
action.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Action workflow
on: [push, pull_request]
jobs:
build:
name: Build Project
strategy:
fail-fast: false
matrix:
configuration:
- Debug
- Release
runs-on: ubuntu-latest
env:
build_dir: .build
steps:
- name: checkout
uses: actions/checkout@v4
- name: configure
shell: bash
run: |
mkdir ${build_dir}
cd ${build_dir}
cmake \
-DCMAKE_BUILD_TYPE=${{ matrix.configuration }} \
-DCMAKE_C_COMPILER=$(which gcc) \
-DCMAKE_CXX_COMPILER=$(which g++) \
..
- name: build all targets
shell: bash
run: |
pushd ${build_dir}
cmake --build . --target all
popd
mv ${build_dir}/tests/tests ./tests-${{ matrix.configuration }}
- name: upload tests binary
uses: actions/upload-artifact@v4
with:
name: tests-${{ matrix.configuration }}
path: tests-${{ matrix.configuration }}
if-no-files-found: error
tests:
name: Run Tests
strategy:
fail-fast: false
matrix:
configuration:
- Debug
- Release
needs: build
runs-on: ubuntu-latest
env:
build_dir: .build
steps:
- name: download tests binary
uses: actions/download-artifact@v4
with:
name: tests-${{ matrix.configuration }}
- name: prepare tests location
shell: bash
run: |
mkdir ${build_dir}
mv ./tests-${{ matrix.configuration }} ${build_dir}/tests
chmod 755 ${build_dir}/tests
- name: run tests
shell: bash
run: |
cd ${build_dir}
./tests -r compact
coverage:
if: ${{ github.event_name == 'push' }}
name: Prepare Coverage Report
strategy:
fail-fast: false
matrix:
configuration:
- Debug
runs-on: ubuntu-latest
env:
build_dir: .build
steps:
- name: checkout
uses: actions/checkout@v4
- name: configure
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends lcov
sudo apt-get clean
grep -F "branch_coverage" /etc/lcovrc | sed 's/branch_coverage = 0/branch_coverage = 1/g' >> $HOME/.lcovrc
grep -F "no_exception_branch" /etc/lcovrc | sed 's/no_exception_branch = 0/no_exception_branch = 1/g' >> $HOME/.lcovrc
mkdir ${build_dir}
cd ${build_dir}
cmake \
-DCMAKE_BUILD_TYPE=${{ matrix.configuration }} \
-DCMAKE_C_COMPILER=$(which gcc) \
-DCMAKE_C_FLAGS="-g --coverage -fprofile-abs-path -fno-early-inlining" \
-DCMAKE_CXX_COMPILER=$(which g++) \
-DCMAKE_CXX_FLAGS="-g --coverage -fprofile-abs-path -fno-early-inlining" \
..
- name: build, run tests, prepare coverage data
shell: bash
run: |
cd ${build_dir}
cmake --build .
lcov --no-external --capture --initial --directory $( realpath .. ) --output-file /tmp/base.info
tests/tests -a
lcov --no-external --capture --directory $( realpath .. ) --output-file /tmp/test.info
lcov --add-tracefile /tmp/base.info --add-tracefile /tmp/test.info --output-file /tmp/total.info
lcov --remove /tmp/total.info "$( realpath . )/*" "$( realpath ../tests )/*" --output-file /tmp/filtered.info
cp /tmp/filtered.info "$( realpath .. )/coverage.txt"
- name: archive coverage data
uses: actions/upload-artifact@v4
with:
name: coverage.txt
path: coverage.txt
retention-days: 30
- name: upload coverage report
uses: codecov/[email protected]
with:
fail_ci_if_error: true
file: coverage.txt
disable_search: true
verbose: true
plugin: noop
token: ${{ secrets.CODECOV_TOKEN }}