-
Notifications
You must be signed in to change notification settings - Fork 0
224 lines (196 loc) · 7.84 KB
/
meson-unit-test.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# SPDX-FileCopyrightText: 2021 Comcast Cable Communications Management, LLC
# SPDX-License-Identifier: Apache-2.0
name: Meson C Unit Test
on:
workflow_call:
inputs:
packages:
description: 'The optional list of ubuntu packages to install prior to building.'
type: string
required: false
brew-extra:
description: 'The optional list of environment variables needed to find the brew packages when meson looks.'
type: string
required: false
brew-packages:
description: 'The optional list of brew (MacOS) packages to install prior to building.'
type: string
required: false
macos-openssl-fix:
description: 'Fix macos and openssl not working well.'
type: string
required: false
default: 'false'
macos-skip:
description: 'Set if building for macOS should be skipped.'
type: string
required: false
default: 'false'
meson-version:
description: 'The version of meson to use.'
type: string
required: false
default: '0.60.3'
runner-macos:
description: 'The ubuntu runner to use.'
type: string
required: false
default: 'macos-latest'
runner-ubuntu:
description: 'The ubuntu runner to use.'
type: string
required: false
default: 'ubuntu-latest'
sonarcloud-skip:
description: 'Skip uploading to sonarcloud.'
type: string
required: false
default: 'false'
secrets:
sonar_login:
description: 'The sonarcloud login token.'
required: true
codecov_token:
description: 'The codecov.io token.'
required: true
jobs:
test-macos:
name: Unit Tests (MacOS)
if: inputs.macos-skip != 'true'
runs-on: ${{ inputs.runner-macos }}
steps:
- uses: actions/checkout@v4 # v3.5.3
- name: Install packages
run: |
brew install cunit ninja meson ${{ inputs.brew-packages }}
- name: Fix openssl
if: inputs.macos-openssl-fix == 'true'
run: |
# To find out the environment variables I had to run these:
# brew upgrade openssl
# brew link --force openssl
# pkg-config --modversion openssl
echo "LDFLAGS=\"-L/usr/local/opt/openssl@3/lib\"" >> $GITHUB_ENV
echo "CPPFLAGS=\"-I/usr/local/opt/openssl@3/include\"" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=\"/usr/local/opt/openssl@3/lib/pkgconfig\"" >> $GITHUB_ENV
- name: Meson Setup
run: |
${{ inputs.brew-extra }} meson setup --warnlevel 3 --werror build
- name: Build
working-directory: build
run: |
ninja all
- name: Run Tests
working-directory: build
run: |
ninja test
test-linux-clang:
name: Unit Tests (Linux clang)
runs-on: ${{ inputs.runner-ubuntu }}
steps:
- uses: actions/checkout@v4 # v3.5.3
- name: Install packages
run: |
sudo apt-get update
sudo apt-get -y install python3 python3-pip python3-setuptools python3-wheel \
ninja-build valgrind gcovr \
libcunit1 libcunit1-doc libcunit1-dev \
${{ inputs.packages }}
- name: Install Meson
run: |
pip3 install --user 'meson>=${{ inputs.meson-version }}'
- name: Meson Setup
run: |
CC=clang meson setup --warnlevel 3 --werror build
- name: Build
working-directory: build
run: |
ninja all
- name: Run Tests
working-directory: build
run: |
ninja test
test-linux-gcc:
name: Unit Tests (Linux gcc)
runs-on: ${{ inputs.runner-ubuntu }}
steps:
- uses: actions/checkout@v4 # v3.5.3
with:
fetch-depth: 0
- name: Install packages
run: |
sudo apt-get update
sudo apt-get -y install python3 python3-pip python3-setuptools python3-wheel \
ninja-build valgrind gcovr \
libcunit1 libcunit1-doc libcunit1-dev \
${{ inputs.packages }}
- name: Install Meson
run: |
pip3 install --user 'meson>=${{ inputs.meson-version }}'
- name: Meson Setup
run: |
meson setup --warnlevel 3 --werror build
- name: Get Sonarcloud Binaries
if: inputs.sonarcloud-skip != 'true'
uses: xmidt-org/sonarcloud-installer-action@v1
with:
working-directory: build
- name: Update .sonar-project.properties
if: inputs.sonarcloud-skip != 'true'
run: |
# Warn if we find something that shouldn't be in the sonar file.
if [[ -n `grep ".*sonar.cfamily.build-wrapper-output.*" .sonar-project.properties` ]]; then
echo -e "\e[0;31mWarning: remove this from the .sonar-project.properties file: sonar.cfamily.build-wrapper-output\e[m"
fi
if [[ -n `grep ".*sonar.cfamily.threads.*" .sonar-project.properties` ]]; then
echo -e "\e[0;31mWarning: remove this from the .sonar-project.properties file: sonar.cfamily.threads\e[m"
fi
if [[ -n `grep ".*sonar.cfamily.cache.enabled.*" .sonar-project.properties` ]]; then
echo -e "\e[0;31mWarning: remove this from the .sonar-project.properties file: sonar.cfamily.cache.enabled\e[m"
fi
if [[ -n `grep ".*sonar.coverageReportPaths.*" .sonar-project.properties` ]]; then
echo -e "\e[0;31mWarning: remove this from the .sonar-project.properties file: sonar.coverageReportPaths\e[m"
fi
# Remove the lines we want to replace
sed -i 's/.*sonar.cfamily.build-wrapper-output.*//g' .sonar-project.properties
sed -i 's/.*sonar.cfamily.threads.*//g' .sonar-project.properties
sed -i 's/.*sonar.cfamily.cache.enabled.*//g' .sonar-project.properties
sed -i 's/.*sonar.coverageReportPaths.*//g' .sonar-project.properties
# Add the version we need.
echo "sonar.cfamily.build-wrapper-output=build/bw-output" >> .sonar-project.properties
echo "sonar.cfamily.threads=2" >> .sonar-project.properties
echo "sonar.cfamily.cache.enabled=false" >> .sonar-project.properties
echo "sonar.coverageReportPaths=build/meson-logs/sonarqube.xml" >> .sonar-project.properties
- name: Build with Sonarcloud
if: inputs.sonarcloud-skip != 'true'
working-directory: build
run: |
wrapper='build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output'
if [ "{{ inputs.sonarcloud-skip }}" = "true" ]; then
wrapper=''
}
$wrapper ninja all
- name: Run Tests
working-directory: build
run: |
ninja test
- name: Generate Coverage Report
working-directory: build
run: |
ninja coverage
- name: Upload SonarCloud
if: inputs.sonarcloud-skip != 'true'
run: |
build/sonar-scanner/bin/sonar-scanner -Dsonar.host.url=https://sonarcloud.io \
-Dproject.settings=.sonar-project.properties \
-Dsonar.login=${{ secrets.sonar_login }}
env:
# Required by the sonar-scanner program
GITHUB_TOKEN: ${{ github.token }}
- name: Upload Codecov.io
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v4.6.0
with:
directory: .
files: build/meson-logs/coverage.xml
fail_ci_if_error: true
token: ${{ secrets.codecov_token }}