forked from aws/aws-iot-device-sdk-embedded-C
-
Notifications
You must be signed in to change notification settings - Fork 0
390 lines (386 loc) · 14.8 KB
/
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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
name: CI Checks
on:
push:
branches: ["**"]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build-check-demos:
runs-on: ubuntu-18.04
steps:
- name: Clone This Repo
uses: actions/checkout@v2
with:
submodules: recursive
- name: Configure CMake build
run: |
sudo apt-get install -y libmosquitto-dev
curl https://cmake.org/files/v3.2/cmake-3.2.0-Linux-x86_64.tar.gz -o cmake.tar.gz
tar -xf cmake.tar.gz
mkdir build && cd build
../cmake-3.2.0-Linux-x86_64/bin/cmake .. \
-G "Unix Makefiles" \
-DBUILD_DEMOS=1 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS='-Wall -Wextra -Werror' \
-DAWS_IOT_ENDPOINT="aws-iot-endpoint" \
-DBROKER_ENDPOINT="broker-endpoint" \
-DCLIENT_CERT_PATH="cert/path" \
-DROOT_CA_CERT_PATH="cert/path" \
-DCLIENT_PRIVATE_KEY_PATH="key/path" \
-DCLIENT_IDENTIFIER="ci-identifier" \
-DTHING_NAME="thing-name" \
-DS3_PRESIGNED_GET_URL="get-url" \
-DS3_PRESIGNED_PUT_URL="put-url" \
-DCLAIM_CERT_PATH="cert/path" \
-DCLAIM_PRIVATE_KEY_PATH="key/path" \
-DPROVISIONING_TEMPLATE_NAME="template-name" \
-DDEVICE_SERIAL_NUMBER="00000" \
-DCSR_SUBJECT_NAME="CN=Fleet Provisioning Demo"
- name: Build Demos
run: |
make -C build/ help | grep demo | tr -d '. ' | xargs make -C build/
make -C demos/jobs/jobs_demo_mosquitto
build-check-demos-cpp:
runs-on: ubuntu-latest
steps:
- name: Clone This Repo
uses: actions/checkout@v2
with:
submodules: recursive
- name: Rename source files
run: |
for demo in mqtt http shadow defender pkcs11 fleet_provisioning
do
for source in demos/$demo/*/*.c
do
mv -- "$source" "${source%.c}.cpp"
done
done
- name: Configure CMake build
run: |
sudo apt-get install -y libmosquitto-dev
curl https://cmake.org/files/v3.2/cmake-3.2.0-Linux-x86_64.tar.gz -o cmake.tar.gz
tar -xf cmake.tar.gz
mkdir build && cd build
../cmake-3.2.0-Linux-x86_64/bin/cmake .. \
-G "Unix Makefiles" \
-DBUILD_DEMOS=1 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS='-Wall -Wextra' \
-DAWS_IOT_ENDPOINT="aws-iot-endpoint" \
-DBROKER_ENDPOINT="broker-endpoint" \
-DCLIENT_CERT_PATH="cert/path" \
-DROOT_CA_CERT_PATH="cert/path" \
-DCLIENT_PRIVATE_KEY_PATH="key/path" \
-DCLIENT_IDENTIFIER="ci-identifier" \
-DTHING_NAME="thing-name" \
-DS3_PRESIGNED_GET_URL="get-url" \
-DS3_PRESIGNED_PUT_URL="put-url" \
-DCLAIM_CERT_PATH="cert/path" \
-DCLAIM_PRIVATE_KEY_PATH="key/path" \
-DPROVISIONING_TEMPLATE_NAME="template-name" \
-DDEVICE_SERIAL_NUMBER="00000" \
-DCSR_SUBJECT_NAME="CN=Fleet Provisioning Demo"
- name: Build Demos
run: |
make -C build/ help | grep demo | tr -d '. ' | xargs make -C build/
build-check-system-tests:
runs-on: ubuntu-18.04
steps:
- name: Clone This Repo
uses: actions/checkout@v2
with:
submodules: recursive
- name: Configure CMake build
run: |
curl https://cmake.org/files/v3.2/cmake-3.2.0-Linux-x86_64.tar.gz -o cmake.tar.gz
tar -xf cmake.tar.gz
mkdir build && cd build
../cmake-3.2.0-Linux-x86_64/bin/cmake .. \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=1 \
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror' \
-DAWS_IOT_ENDPOINT="aws-iot-endpoint" \
-DBROKER_ENDPOINT="broker-endpoint" \
-DCLIENT_CERT_PATH="cert/path" \
-DROOT_CA_CERT_PATH="cert/path" \
-DCLIENT_PRIVATE_KEY_PATH="key/path" \
-DCLIENT_IDENTIFIER="ci-identifier" \
-DTHING_NAME="thing-name" \
-DS3_PRESIGNED_GET_URL="get-url" \
-DS3_PRESIGNED_PUT_URL="put-url" \
-DCLAIM_CERT_PATH="cert/path" \
-DCLAIM_PRIVATE_KEY_PATH="key/path" \
-DPROVISIONING_TEMPLATE_NAME="template-name" \
-DDEVICE_SERIAL_NUMBER="00000" \
-DCSR_SUBJECT_NAME="CN=Fleet Provisioning Demo"
- name: Build System Tests
run: make -C build/ help | grep system | tr -d '. ' | xargs make -C build/
build-check-install:
runs-on: ubuntu-18.04
steps:
- name: Clone This Repo
uses: actions/checkout@v2
with:
submodules: recursive
- name: Configure CMake for installation of shared libraries at custom location
run: |
curl https://cmake.org/files/v3.2/cmake-3.2.0-Linux-x86_64.tar.gz -o cmake.tar.gz
tar -xf cmake.tar.gz
mkdir build && cd build
../cmake-3.2.0-Linux-x86_64/bin/cmake .. \
-DBUILD_DEMOS=0 -DBUILD_TESTS=0 \
-DCSDK_HEADER_INSTALL_PATH="$PWD/../shared-libs-headers-install-dir" -DCSDK_LIB_INSTALL_PATH="$PWD/../shared-libs-install-dir"
- name: Install shared libraries and verify custom install location
run: |
cd build && sudo make install
while IFS="" read -r p || [ -n "$p" ]
do
if [[ $p != "$PWD/../shared-libs-headers-install-dir"* ]] && [[ $p != "$PWD/../shared-libs-install-dir"* ]]; then
exit 1
fi
# Each line of install_manifest.txt contains the location of an installed library or header
done <install_manifest.txt
# Uninstall and reset build.
sudo xargs rm < install_manifest.txt || echo "transport_interface.h is installed twice because of duplicate copies in spoke repos."
rm -rf *
- name: Configure CMake for installation of static libraries at custom location
run: |
cd build
../cmake-3.2.0-Linux-x86_64/bin/cmake .. \
-DBUILD_SHARED_LIBRARIES=OFF \
-DBUILD_DEMOS=0 -DBUILD_TESTS=0 \
-DCSDK_HEADER_INSTALL_PATH="$PWD/../static-libs-headers-install-dir" -DCSDK_LIB_INSTALL_PATH="$PWD/../static-libs-install-dir"
- name: Install static libraries and verify custom install location
run: |
cd build && sudo make install
while IFS="" read -r p || [ -n "$p" ]
do
if [[ $p != "$PWD/../static-libs-headers-install-dir"* ]] && [[ $p != "$PWD/../static-libs-install-dir"* ]]; then
exit 1
fi
# Each line of install_manifest.txt contains the location of an installed library or header
done <install_manifest.txt
# Uninstall and reset build.
sudo xargs rm < install_manifest.txt || echo "transport_interface.h is installed twice because of duplicate copies in spoke repos."
rm -rf *
- name: Configure CMake build for system install location and selective installation
run: |
cd build
../cmake-3.2.0-Linux-x86_64/bin/cmake .. \
-DBUILD_DEMOS=0 -DBUILD_TESTS=0 -DINSTALL_TO_SYSTEM=1 \
-DINSTALL_LIBS="SHADOW;DEFENDER" -DINSTALL_PLATFORM_ABSTRACTIONS=0
- name: Install selected libraries and verify default system installation path is used
run: |
cd build && sudo make install
while IFS="" read -r p || [ -n "$p" ]
do
if [[ $p != "/usr/local/include"* ]] && [[ $p != "/usr/local/lib"* ]]; then
exit 1
fi
# Each line of install_manifest.txt contains the location of an installed library or header
done <install_manifest.txt
- name: Verify filenames from selective build
run: |
cd build
while IFS="" read -r p || [ -n "$p" ]
do
if [[ $p != *"shadow"* ]] && [[ $p != *"defender"* ]]; then
exit 1
fi
# Each line of install_manifest.txt contains the location of an installed library or header
done <install_manifest.txt
unittest:
runs-on: ubuntu-18.04
steps:
- name: Clone This Repo
uses: actions/checkout@v2
with:
submodules: recursive
- name: Download CMake 3.2.0
run: |
curl https://cmake.org/files/v3.2/cmake-3.2.0-Linux-x86_64.tar.gz -o cmake.tar.gz
tar -xf cmake.tar.gz
mkdir build
cmake-3.2.0-Linux-x86_64/bin/cmake . -Bbuild/ \
-G "Unix Makefiles" \
-DBUILD_TESTS=1 \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG'
make -C build/ help | grep utest | tr -d '. ' | xargs make -C build/
- name: Build Unit Tests
run: |
sudo apt-get install -y lcov
make -C build/ help | grep utest | tr -d '. ' | xargs make -C build/
- name: Run ctest
run: |
cd build/
ctest -E system --output-on-failure
cd ..
- name: Run Coverage
run: |
make -C build/ coverage
declare -a EXCLUDE=("\*test\*" "\*CMakeCCompilerId\*" "\*mocks\*" "\*3rdparty\*" "\*netdb\*" "*openssl/*")
echo ${EXCLUDE[@]} | xargs lcov --rc lcov_branch_coverage=1 -r build/coverage.info -o build/coverage.info
lcov --rc lcov_branch_coverage=1 --list build/coverage.info
- name: Check Coverage
env:
MIN_COVERAGE: 100
run: |
LINE_COVERAGE=$(lcov --list build/coverage.info | tail -n 1 | cut -d '|' -f 2 | sed -n "s/\([^%]*\)%.*/\1/p")
BRANCH_COVERAGE=$(lcov --rc lcov_branch_coverage=1 --list build/coverage.info | tail -n 1 | cut -d '|' -f 4 | sed -n "s/\([^%]*\)%.*/\1/p")
RESULT=0
echo "Required line and branch coverages: $MIN_COVERAGE"
echo "Line coverage: $LINE_COVERAGE"
if [[ $(echo "$LINE_COVERAGE < $MIN_COVERAGE" | bc) -ne 0 ]]; then
echo "Line Coverage is too low."
RESULT=1
fi
echo "Branch coverage: $BRANCH_COVERAGE"
if [[ $(echo "$BRANCH_COVERAGE < $MIN_COVERAGE" | bc) -ne 0 ]]; then
echo "Branch Coverage is too low."
RESULT=1
fi
exit $RESULT
complexity:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Setup
run: sudo apt-get install complexity
- name: Check Complexity
run: |
find platform/ \( -iname '*.c' ! -wholename '*test*' \) |\
xargs complexity --scores --threshold=0 --horrid-threshold=8
spell-check:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Install spell
run: |
sudo apt-get install -y spell util-linux
- name: Check Spelling
run: |
PATH=$PATH:$PWD/tools/spell
for lexfile in `find platform/ demos/ integration-test/ docs/ -name lexicon.txt`
do dir=${lexfile%/lexicon.txt}
echo $dir
find-unknown-comment-words --directory $dir
if [ $? -ne "0" ]
then
exit 1
fi
done
formatting:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Install Uncrustify
run: sudo apt-get install uncrustify
- name: Check Formatting With Uncrustify
run: find . -iname "*.[hc]" -exec uncrustify --check -c tools/uncrustify.cfg {} +
- name: Check For Trailing Whitespace
run: |
set +e
grep --exclude="README.md" -rnI -e "[[:blank:]]$" .
if [ "$?" = "0" ]; then
echo "Files have trailing whitespace."
exit 1
else
exit 0
fi
- name: Check for CRLF
run: |
set +e
find . -path ./.git -prune -o -exec file {} + | grep "CRLF"
if [ "$?" = "0" ]; then
echo "Files have CRLF line endings."
exit 1
else
exit 0
fi
doxygen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install Doxygen
run: |
wget -qO- "https://sourceforge.net/projects/doxygen/files/rel-1.9.2/doxygen-1.9.2.linux.bin.tar.gz/download" | sudo tar --strip-components=1 -xz -C /usr/local
sudo apt-get install -y libclang-9-dev libclang-cpp9 graphviz
- name: Install Python3
uses: actions/setup-python@v2
with:
python-version: '3.7.10'
- name: Generate doxygen output
run: |
if [[ "$GITHUB_REF" == "refs/heads/main" ]]; then
echo 'Generate ZIP artifact of doxygen output'
python3 tools/doxygen/generate_docs.py --root . --zip
else
python3 tools/doxygen/generate_docs.py --root .
fi
- name: Upload doxygen artifact if main branch
if: success() && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v2
with:
name: doxygen.zip
path: ./doxygen.zip
retention-days: 2
git-secrets:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Checkout awslabs/git-secrets
uses: actions/checkout@v2
with:
repository: awslabs/git-secrets
ref: master
path: git-secrets
- name: Install git-secrets
run: cd git-secrets && sudo make install && cd ..
- name: Run git-secrets
run: |
git-secrets --register-aws
git-secrets --scan
link-verifier:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup Python for link verifier action
uses: actions/setup-python@v2
with:
python-version: '3.7.10'
- name: Check Links
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: FreeRTOS/CI-CD-GitHub-Actions/link-verifier@main
with:
path: ./
exclude-dirs: cmock,unity,cbmc,third-party,3rdparty,libmosquitto
include-file-types: .c,.h,.dox
allowlist-file: ./.github/links_allowlist.txt
verify-manifest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup Python for manifest.yml verifier action
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Verify manifest.yml
uses: FreeRTOS/CI-CD-GitHub-Actions/manifest-verifier@main
with:
path: ./
exclude-submodules: libraries/3rdparty/CMock,libraries/3rdparty/mbedtls,libraries/3rdparty/tinycbor,demos/jobs/jobs_demo_mosquitto/libmosquitto
fail-on-incorrect-version: true