forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 19
230 lines (198 loc) · 7.4 KB
/
basic_checks.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
# This workflow performs the checks like license check,
# doxygen, unit tests etc.
name: Basic Checks
on:
pull_request:
workflow_dispatch:
push:
branches:
- master
jobs:
license-check:
runs-on: ubuntu-latest
container:
image: ghcr.io/armmbed/mbed-os-env:master-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: install dependencies
shell: bash
run: |
pip install -U scancode-toolkit "click>=7,<8"
-
name: license check
run: |
set -x
mkdir -p SCANCODE
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true )
echo $?
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
| ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
| while read file; do cp --parents "${file}" SCANCODE; done
ls SCANCODE
scancode -l --json-pp scancode.json SCANCODE
python ./tools/test/ci/scancode-evaluate.py scancode.json || true
cat scancode-evaluate.log
COUNT=$(cat scancode-evaluate.log | grep 'File:' | grep -v 'SPDX' | wc -l) || true
if [ $COUNT = 0 ]; then
echo "License check OK";
true;
else
echo "License check failed, please review license issues found in files";
false;
fi
include-check:
runs-on: ubuntu-latest
container:
image: ghcr.io/armmbed/mbed-os-env:master-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: include check
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# checks mbed.h is not included in MbedOS files except in tests
! git grep '^#include\s["'"']mbed.h['"'"]$' -- '*.c' '*.h' '*.cpp' '*.hpp' \
':!*platform_mbed.h' ':!*TESTS/*' ':!TEST_APPS/' ':!UNITTESTS/' \
':!*tests/*' ':!*targets/*' ':!*TARGET_*' ':!*unsupported/*' \
':!*events/tests/*' ':!*drivers/tests/*'
style-check:
runs-on: ubuntu-latest
container:
image: ghcr.io/armmbed/mbed-os-env:master-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: UTF-8 Check
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# Make sure we're not introducing any text which is not UTF-8 encoded
git diff origin/${GITHUB_BASE_REF} -U0 | ( grep -a '^+' || true ) | ( ! grep -axv '.*' )
-
name: astyle checks
run: |
set -x
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
| ( grep '.*\.\(c\|cpp\|h\|hpp\)$' || true ) \
| ( grep -v -f .codecheckignore || true ) \
| while read file; do astyle -n --options=.astylerc "${file}"; done
git diff --exit-code --diff-filter=d --color
- name: Spell Checks
run: |
set -x
./tools/test/ci/doxy-spellchecker/spell.sh drivers .codecheckignore
./tools/test/ci/doxy-spellchecker/spell.sh platform .codecheckignore
./tools/test/ci/doxy-spellchecker/spell.sh events .codecheckignore
./tools/test/ci/doxy-spellchecker/spell.sh rtos .codecheckignore
./tools/test/ci/doxy-spellchecker/spell.sh connectivity/netsocket .codecheckignore
- name: File Naming Checks
run: |
set -x
# Assert that all binary libraries are named correctly
# The strange command below asserts that there are exactly 0 libraries
# that do not start with lib
find "(" -name "*.a" -or -name "*.ar" ")" -and -not -name "lib*" |
tee BUILD/badlibs |
sed -e "s/^/Bad library name found: /" && [ ! -s BUILD/badlibs ]
# Assert that all assembler files are named correctly
# The strange command below asserts that there are exactly 0 libraries
# that do end with .s
find -name "*.s" | tee BUILD/badasm |
sed -e "s/^/Bad Assembler file name found: /" && [ ! -s BUILD/badasm ]
docs-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Create BUILD folder
run: |
mkdir -p ${{ github.workspace }}/BUILD
- name: Doxygen Action
uses: mattnotmitt/[email protected]
with:
doxyfile-path: ./doxyfile_options
python-tests:
# these tests run in 3.7, hence running in vm not in pre-built docker
runs-on: ubuntu-latest
steps:
-
name: Checkout repo
uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: '3.7'
-
name: install dependencies
run: |
pip install -r tools/requirements.txt
pip install -r tools/test/requirements.txt
-
name: pytest
run: |
set -x
coverage run -a -m pytest tools/test
python tools/test/pylint.py
coverage run -a tools/project.py -S | sed -n '/^Total/p'
coverage html
pin-validation:
runs-on: ubuntu-latest
container:
image: ghcr.io/armmbed/mbed-os-env:master-latest
steps:
-
name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: validate pins
run: |
set -x
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
| ( grep '.*[\\|\/]PinNames.h$' || true ) \
| while read file; do python ./hal/tests/pinvalidate/pinvalidate.py -vvvfp "${file}"; done
git diff --exit-code --diff-filter=d --color
cmake-checks:
env:
NAME: mbed-test-mode-check
ROOT: tools/cmake/tests/mbed_test_mode/
TOOLCHAIN: GCC_ARM
TARGET_NAME: K64F
PROFILE: develop
runs-on: ubuntu-latest
container:
image: ghcr.io/armmbed/mbed-os-env:master-latest
steps:
-
name: Checkout repo
uses: actions/checkout@v3
-
name: cmake build
run: |
set -x
cmake -S ${{env.ROOT}} -B ${{ env.ROOT }}/cmake_build/${{env.TARGET_NAME}}/${{ env.PROFILE }}/${{ env.TOOLCHAIN }}/ -GNinja -DCMAKE_BUILD_TYPE=${{ env.PROFILE }} -DMBED_TARGET=${{ env.TARGET_NAME }}
cmake --build ${{ env.ROOT }}/cmake_build/${{ env.TARGET_NAME }}/${{ env.PROFILE }}/${{ env.TOOLCHAIN }}/
-
name: cmake unittest
run: |
set -x
ctest --build-and-test . build --build-generator Ninja --build-options -DMBED_ENABLE_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DCOVERAGE=ON --test-command ctest
gcovr --gcov-executable gcov -r . ./build -s -e ".*\.h" --exclude-directories=${GITHUB_WORKSPACE}/build/UNITTESTS --exclude-directories=${GITHUB_WORKSPACE}/build/_deps
ccache -s