forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
341 lines (322 loc) · 13.9 KB
/
.travis.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
# Copyright (c) 2013-2019 Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
language: sh
os: linux
dist: focal
env:
global:
- deps_url="https://mbed-os-ci-public.s3-eu-west-1.amazonaws.com/jenkins-ci/deps"
- deps_dir="${HOME}/.cache/deps"
cache:
pip: true
ccache: true
directories:
- ${HOME}/.cache/deps
before_install:
- source tools/test/travis-ci/functions.sh
addons:
apt:
sources:
- sourceline: 'deb https://apt.kitware.com/ubuntu/ focal main'
key_url: 'https://apt.kitware.com/keys/kitware-archive-latest.asc'
packages:
- cmake
- ninja-build
- gcovr
- libncursesw5
- g++-7
matrix:
include:
### Basic Tests ###
- &basic-vm
stage: "Basic"
name: "file attributes"
env: NAME=gitattributestest
script:
- git diff --exit-code
- <<: *basic-vm
name: "license check"
env: NAME=licence_check
language: python
python: 3.6.8 # scancode-toolkit v3.1.1 requires v3.6.8
install:
# workaround for https://github.com/ARMmbed/mbed-os/issues/13322
- pip install pdfminer.six==20200517
- pip install scancode-toolkit==3.1.1
before_script:
- mkdir -p SCANCODE
- mkdir -p SCANCODE_NEW_FILES
# Fetch the base branch to compare against
- git fetch origin "${TRAVIS_BRANCH}" --depth=1
script:
# scancode does not support list of files, only one file or directory
# we use SCANCODE directory for all changed files (their copies with full tree)
- >-
git diff --name-only --diff-filter=ad FETCH_HEAD..HEAD \
| ( 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
- scancode -l --json-pp scancode.json SCANCODE
- python ./tools/test/travis-ci/scancode-evaluate.py scancode.json || true
# run the same but for new files. All new files must have SPDX
- >-
git diff --name-only --diff-filter=A FETCH_HEAD..HEAD \
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
| ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
| while read file; do cp --parents "${file}" SCANCODE_NEW_FILES; done
- scancode -l --json-pp scancode_new_files.json SCANCODE_NEW_FILES
- python ./tools/test/travis-ci/scancode-evaluate.py scancode_new_files.json || true
- cat scancode-evaluate.log
- COUNT=$(cat scancode-evaluate.log | grep 'File:' | grep -v 'SPDX' | wc -l) || true
- python ./tools/test/travis-ci/scancode-evaluate.py scancode_new_files.json
- cat scancode-evaluate.log
- COUNT_NEW_FILES=$(cat scancode-evaluate.log | grep 'File:' | grep -v 'SPDX' | wc -l) || true
- |
if [ $COUNT == 0 ] && [ $COUNT_NEW_FILES == 0 ]; then
echo "License check OK";
true;
elif [ $COUNT_NEW_FILES != 0 ]; then
echo "License check failed, new files with the license issues found";
false;
else
echo "License check failed, please review license issues found in modified files";
false;
fi
- <<: *basic-vm
name: "UTF-8 Check"
script:
# Make sure we're not introducing any text which is not UTF-8 encoded
- git diff $TRAVIS_BRANCH...HEAD -U0 | ( grep -a '^+' || true ) | ( ! grep -axv '.*' )
- <<: *basic-vm
name: "include check"
env: NAME=include_check
script:
- |
! 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/*'
### Docs Tests ###
- &docs-vm
stage: "Docs"
name: "astyle"
env: NAME=astyle
install:
- >-
curl -L0 https://mbed-os-ci-public.s3-eu-west-1.amazonaws.com/jenkins-ci/deps/astyle_3.1_linux.tar.gz --output astyle.tar.gz;
mkdir -p BUILD && tar xf astyle.tar.gz -C BUILD;
cd BUILD/astyle/build/gcc;
make;
export PATH="${PWD}/bin:${PATH}";
cd -
- astyle --version
# Fetch the base branch to compare against
- git fetch origin "${TRAVIS_BRANCH}" --depth=1
script:
- >-
git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \
| ( 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
- <<: *docs-vm
name: "spellcheck"
env: NAME=doxy-spellcheck
install:
- source_pkg aspell
script:
# TODO: run checks on all directories once all mispellings are fixed
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh drivers .codecheckignore
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh platform .codecheckignore
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh events .codecheckignore
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh rtos .codecheckignore
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh connectivity/netsocket .codecheckignore
- <<: *docs-vm
name: "doxygen"
env: NAME=docs
install:
# Build doxygen
- >
(git clone --depth=1 --single-branch --branch Release_1_8_14 https://github.com/doxygen/doxygen;
cd doxygen;
mkdir build;
cd build;
cmake -G "Unix Makefiles" ..;
make;
sudo make install)
# Create BUILD directory for tests
- ccache -s
- mkdir BUILD
script:
# Assert that the Doxygen build produced no warnings.
# The strange command below asserts that the Doxygen command had an
# output of zero length
- doxygen doxyfile_options 2>&1
# Once Mbed OS has been fixed, enable the full test by replacing the top line with this:
# - ( ! doxygen doxyfile_options 2>&1 | grep . )
# 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 ]
### Python Tests ###
- &pytools-vm
stage: "Pytest"
name: "tools-py35"
env: NAME=tools-py3.5
language: python
python: 3.7
install:
# Install gcc
- source_pkg gcc
- arm-none-eabi-gcc --version
# Install additional python modules
- python --version
- |-
tr -d ' ' >> requirements.txt <<< "
mock==2.0.0
attrs==19.1.0
pytest==3.3.0
pylint>=1.9,<2
hypothesis>=3,<4
coverage>=4.5,<5
"
- pip install --upgrade pip
- pip install -r requirements.txt
- pip list --verbose
script:
# Run local testing on tools
- PYTHONPATH=. 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
- &extended-vm
stage: "Pin validation"
name: "pinvalidate"
env: NAME=pinvalidate
language: python
python: 3.7
install:
# Install python modules
- pip install --upgrade pip
- pip install tabulate argparse
- pip list --verbose
# Fetch the base branch to compare against
- git fetch origin "${TRAVIS_BRANCH}" --depth=1
script:
- >-
git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \
| ( grep '.*[\\|\/]PinNames.h$' || true ) \
| while read file; do python ./hal/tests/pinvalidate/pinvalidate.py -vfp "${file}"; done
- git diff --exit-code --diff-filter=d --color
### CMake Check ###
- &cmake-vm
stage: "CMake Check"
name: "Backward compatiblity check - MBED_TEST_MODE"
env: NAME=mbed-test-mode-check ROOT=tools/cmake/tests/mbed_test_mode/ TOOLCHAIN=GCC_ARM TARGET_NAME=K64F PROFILE=develop
language: python
python: 3.8
install:
# Hide Travis-preinstalled CMake
# The Travis-preinstalled CMake is unfortunately not installed via apt, so we
# can't replace it with an apt-supplied version very easily. Additionally, we
# can't permit the Travis-preinstalled copy to survive, as the Travis default
# path lists the Travis CMake install location ahead of any place where apt
# would install CMake to. Instead of apt removing or upgrading to a new CMake
# version, we must instead delete the Travis copy of CMake.
- sudo rm -rf /usr/local/cmake*
# Setup ccache
- ccache -o compiler_check=content
- ccache -M 1G
- pushd /usr/lib/ccache
- sudo ln -s ../../bin/ccache arm-none-eabi-gcc
- sudo ln -s ../../bin/ccache arm-none-eabi-g++
- export PATH="/usr/lib/ccache:$PATH"
- popd
# Install arm-none-eabi-gcc
- pushd /home/travis/build && mkdir arm-gcc && cd arm-gcc
- curl -L0 "https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2?revision=05382cca-1721-44e1-ae19-1e7c3dc96118&la=en&hash=D7C9D18FCA2DD9F894FD9F3C3DC9228498FA281A" --output gcc-arm-none-eabi-9-2020-q2-update.tar.bz2
- tar xf gcc-arm-none-eabi-9-2020-q2-update.tar.bz2
- export PATH="$PATH:${PWD}/gcc-arm-none-eabi-9-2020-q2-update/bin"
- popd
- arm-none-eabi-gcc --version
# Install python modules
- pip install --upgrade mbed-tools
- pip install -r tools/cmake/requirements.txt
script:
- mbedtools configure -p ${ROOT} -t ${TOOLCHAIN} -m ${TARGET_NAME} --mbed-os-path .
- cmake -S ${ROOT} -B ${ROOT}/cmake_build/${TARGET_NAME}/${PROFILE}/${TOOLCHAIN}/ -GNinja -DCMAKE_BUILD_TYPE=${PROFILE}
- cmake --build ${ROOT}/cmake_build/${TARGET_NAME}/${PROFILE}/${TOOLCHAIN}/
### Mbed OS unittest ###
- &cmake-build-run-unittest
stage: "CMake"
name: "CMake unittest build"
env: NAME=cmake_unittest
install:
# Hide Travis-preinstalled CMake
# The Travis-preinstalled CMake is unfortunately not installed via apt, so we
# can't replace it with an apt-supplied version very easily. Additionally, we
# can't permit the Travis-preinstalled copy to survive, as the Travis default
# path lists the Travis CMake install location ahead of any place where apt
# would install CMake to. Instead of apt removing or upgrading to a new CMake
# version, we must instead delete the Travis copy of CMake.
- sudo rm -rf /usr/local/cmake*
script:
- echo ctest --build-and-test . build --build-generator Ninja --build-options -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DCOVERAGE=ON -DCMAKE_CXX_COMPILER=g++-7 -DCMAKE_C_COMPILER=gcc-7 --test-command ctest
- ctest --build-and-test . build --build-generator Ninja --build-options -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DCOVERAGE=ON -DCMAKE_CXX_COMPILER=g++-7 -DCMAKE_C_COMPILER=gcc-7 --test-command ctest
- gcovr --gcov-executable gcov-7 -r . ./build -s -e ".*\.h" --exclude-directories=$TRAVIS_BUILD_DIR/build/UNITTESTS --exclude-directories=$TRAVIS_BUILD_DIR/build/_deps
- ccache -s
### Frozen tools check ###
- &frozen-tools-vm
stage: "Frozen tools check"
name: "Frozen tools check"
env: NAME=frozen_tools_check
before_script:
# Fetch the base branch to compare against
- git fetch origin "${TRAVIS_BRANCH}" --depth=1
script:
# Reject any changes to tools that would require a re-release of the
# tools for the online compiler.
- >-
frozen_files=`\
git diff --name-only FETCH_HEAD..HEAD \
| egrep \
-e "^tools/build_api*" \
-e "^tools/config*" \
-e "^tools/export*" \
-e "^tools/notifier*" \
-e "^tools/paths*" \
-e "^tools/resources*" \
-e "^tools/targets*" \
-e "^tools/toolchains*" \
-e "^tools/utils*" \
-e "^$"`
if [ -z "$frozen_files" ]; then
echo "Success!";
else
echo -e "Failure: Frozen files were modified\n$frozen_files";
echo -e "Please see https://os.mbed.com/blog/entry/Introducing-the-new-Mbed-Tools/" \
"\nfor why we've frozen the legacy tools.";
false;
fi