forked from aws/aws-iot-device-sdk-embedded-C
-
Notifications
You must be signed in to change notification settings - Fork 0
318 lines (316 loc) · 12 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
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"
- 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-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"
- 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 build for custom install location
run: |
mkdir installed-headers-dir installed-libs-dir
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/../installed-headers-dir" -DCSDK_LIB_INSTALL_PATH="$PWD/../installed-headers-dir"
- name: Install libraries and verify custom install location
run: |
cd build && sudo make install
while IFS="" read -r p || [ -n "$p" ]
do
if [[ $p != "$PWD/../installed-headers-dir"* ]] && [[ $p != "$PWD/../installed-libs-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-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install Doxygen
run: |
wget -qO- "https://sourceforge.net/projects/doxygen/files/rel-1.8.20/doxygen-1.8.20.linux.bin.tar.gz/download" | sudo tar --strip-components=1 -xz -C /usr/local
sudo apt-get install -y libclang-9-dev graphviz
- name: Install Python3
uses: actions/setup-python@v2
with:
python-version: '3.x'
- 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
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install pandoc
run: |
wget https://github.com/jgm/pandoc/releases/download/2.11/pandoc-2.11-1-amd64.deb -O pandoc.deb
sudo dpkg -i pandoc.deb
rm pandoc.deb
- name: Install gh
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install -y gh
- name: Install python dependencies
run: |
sudo apt-get install -y python3-setuptools python3-pip
pip3 install --user bs4 requests termcolor
- name: Check Links
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
FILES=($(find . -type f -name '*.md' | grep -E -i -v 'cbmc|cmock|third-party|3rdparty|libmosquitto' | tr '\n' ' '))
LINKS=($(grep -e 'https\?://' . -RIa --include='*.c' --include='*.h' --include='*.dox' \
--exclude-dir=.git --exclude-dir=cbmc --exclude-dir=CMock --exclude-dir=third-party --exclude-dir=3rdparty --exclude-dir=libmosquitto | \
grep -IoE '\b(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]' | sort | uniq | \
grep -Fxvf tools/link-verifier/allowlist.txt | tr '\n' ' '))
python3 tools/link-verifier/verify-links.py -F ${FILES[@]} -L ${LINKS[@]}
if [ $? -ne "0" ]
then
exit 1
fi