-
Notifications
You must be signed in to change notification settings - Fork 2
137 lines (115 loc) · 4.03 KB
/
main_ci.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
name: Main CI
on:
pull_request:
branches: [ main,dev ]
paths:
- '**/*.cpp'
- '**/*.hpp'
- '**/CMakeLists.txt'
- '**/CMakePresets.txt'
- '**/cmake/**'
- '**/vcpkg.json'
- '.github/workflows/main_ci.yml'
- 'codecov.yml'
push:
branches: [ main,dev ]
paths:
- '**/*.cpp'
- '**/*.hpp'
- '**/CMakeLists.txt'
- '**/CMakePresets.txt'
- '**/cmake/**'
- '**/vcpkg.json'
- '.github/workflows/main_ci.yml'
- 'codecov.yml'
tags-ignore:
- '*'
workflow_dispatch:
env:
BUILD_TYPE: Debug
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg-cache
jobs:
linux:
runs-on: ubuntu-24.04
strategy:
matrix:
config: [ gcc ]
include:
- config: gcc
version: '14'
steps:
- uses: actions/checkout@v2
with:
path: bethutil
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: ${{ matrix.version }}
- name: Setup Environment
run: |
echo "GCOV=gcov-${{ matrix.version }}" >> $GITHUB_ENV
sudo apt install ninja-build gcovr liblz4-dev zlib1g-dev -y
- uses: lukka/run-vcpkg@v11
with:
vcpkgJsonGlob: ${{ github.workspace }}/bethutil/vcpkg.json
- name: Configure & Build
working-directory: ${{ github.workspace }}/bethutil
run: |
cmake --preset ninja-linux -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DBETHUTIL_BUILD_DOCS=OFF
cmake --build build
- name: Test
working-directory: ${{ github.workspace }}/bethutil/build
env:
gcovr: gcovr -r .. . --coveralls --exclude-unreachable-branches --exclude-function-lines --exclude-throw-branches
run: |
(cd tests && ./tests)
${{ env.gcovr }} -f ".*/src/.*" -f ".*/include/btu/.*" -o src.json
find -type f -name *.gcda | xargs rm
- name: Collect code coverage
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: bethutil/build/examples.json,bethutil/build/src.json
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
path: bethutil
- name: Install OpenCPPCoverage
working-directory: ${{ github.workspace }}/bethutil/scripts/opencppcoverage
run: |
choco pack
choco install opencppcoverage -s . -y
- name: Cache OpenCPPCoverage
uses: actions/cache@v3
env:
cache-name: opencppcoverage-cache
with:
path: ${{ env.SystemDrive }}/Program Files/OpenCppCoverage/*
key: ${{ runner.os }}-opencppcoverage-${{ env.cache-name }}-${{ hashFiles('${{ github.workspace }}/bethutil/scripts/opencppcoverage/opencppcoverage.nuspec') }}
- name: Setup MSVC (x64)
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- uses: lukka/run-vcpkg@v11
with:
vcpkgJsonGlob: '**/bethutil/vcpkg.json'
- name: (main) Configure & Build
working-directory: ${{ github.workspace }}/bethutil
run: |
cmake --preset ninja-windows
cmake --build build --config ${{ env.BUILD_TYPE }}
- name: (main) Test
working-directory: ${{ github.workspace }}/bethutil/build
run: |
& "$($env:SystemDrive)/Program Files/OpenCppCoverage/OpenCppCoverage.exe" -q --sources bethutil\examples --sources bethutil\src --sources bethutil\tests --cover_children --export_type cobertura:cov.xml -- ctest -C ${{ env.BUILD_TYPE }} -V --rerun-failed --output-on-failure
- name: (main) Collect code coverage
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false # Windows coverage is almost the same as Linux, so as long as one of them passes, we're good
files: cov.xml
token: ${{ secrets.CODECOV_TOKEN }}
working-directory: ${{ github.workspace }}/bethutil/build