Skip to content

Commit 91fa680

Browse files
committed
travis ci migration to github action
1 parent e14b961 commit 91fa680

16 files changed

+326
-592
lines changed

.github/workflows/basic_checks.yml

+269
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# This workflow performs the checks like license check,
2+
# doxygen, unit tests etc.
3+
name: Basic Checks
4+
5+
on:
6+
pull_request:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- master
11+
12+
jobs:
13+
license-check:
14+
runs-on: ubuntu-latest
15+
container:
16+
image: ghcr.io/armmbed/mbed-os-env:master-latest
17+
18+
steps:
19+
- name: Checkout repo
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
24+
-
25+
name: install dependencies
26+
shell: bash
27+
run: |
28+
pip install scancode-toolkit
29+
30+
-
31+
name: license check
32+
run: |
33+
set -x
34+
mkdir -p SCANCODE
35+
36+
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
37+
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true )
38+
echo $?
39+
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
40+
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
41+
| ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
42+
| while read file; do cp --parents "${file}" SCANCODE; done
43+
ls SCANCODE
44+
scancode -l --json-pp scancode.json SCANCODE
45+
python ./tools/test/ci/scancode-evaluate.py scancode.json || true
46+
cat scancode-evaluate.log
47+
COUNT=$(cat scancode-evaluate.log | grep 'File:' | grep -v 'SPDX' | wc -l) || true
48+
if [ $COUNT = 0 ]; then
49+
echo "License check OK";
50+
true;
51+
else
52+
echo "License check failed, please review license issues found in files";
53+
false;
54+
fi
55+
56+
include-check:
57+
runs-on: ubuntu-latest
58+
container:
59+
image: ghcr.io/armmbed/mbed-os-env:master-latest
60+
61+
steps:
62+
- name: Checkout repo
63+
uses: actions/checkout@v2
64+
with:
65+
fetch-depth: 0
66+
67+
-
68+
name: include check
69+
run: |
70+
# checks mbed.h is not included in MbedOS files except in tests
71+
! git grep '^#include\s["'"']mbed.h['"'"]$' -- '*.c' '*.h' '*.cpp' '*.hpp' \
72+
':!*platform_mbed.h' ':!*TESTS/*' ':!TEST_APPS/' ':!UNITTESTS/' \
73+
':!*tests/*' ':!*targets/*' ':!*TARGET_*' ':!*unsupported/*' \
74+
':!*events/tests/*' ':!*drivers/tests/*'
75+
76+
style-check:
77+
runs-on: ubuntu-latest
78+
container:
79+
image: ghcr.io/armmbed/mbed-os-env:master-latest
80+
81+
steps:
82+
83+
- name: Checkout repo
84+
uses: actions/checkout@v2
85+
with:
86+
fetch-depth: 0
87+
88+
-
89+
name: UTF-8 Check
90+
run: |
91+
# Make sure we're not introducing any text which is not UTF-8 encoded
92+
git diff origin/${GITHUB_BASE_REF} -U0 | ( grep -a '^+' || true ) | ( ! grep -axv '.*' )
93+
94+
95+
-
96+
name: astyle checks
97+
run: |
98+
set -x
99+
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
100+
| ( grep '.*\.\(c\|cpp\|h\|hpp\)$' || true ) \
101+
| ( grep -v -f .codecheckignore || true ) \
102+
| while read file; do astyle -n --options=.astylerc "${file}"; done
103+
git diff --exit-code --diff-filter=d --color
104+
105+
106+
docs-check:
107+
runs-on: ubuntu-latest
108+
container:
109+
image: ghcr.io/armmbed/mbed-os-env:master-latest
110+
111+
steps:
112+
113+
- name: Checkout repo
114+
uses: actions/checkout@v2
115+
with:
116+
fetch-depth: 0
117+
118+
-
119+
name: spell checks
120+
run: |
121+
set -x
122+
./tools/test/ci/doxy-spellchecker/spell.sh drivers .codecheckignore
123+
./tools/test/ci/doxy-spellchecker/spell.sh platform .codecheckignore
124+
./tools/test/ci/doxy-spellchecker/spell.sh events .codecheckignore
125+
./tools/test/ci/doxy-spellchecker/spell.sh rtos .codecheckignore
126+
./tools/test/ci/doxy-spellchecker/spell.sh connectivity/netsocket .codecheckignore
127+
128+
-
129+
name: doxygen
130+
run: |
131+
set -x
132+
ccache -s
133+
mkdir BUILD
134+
# Assert that the Doxygen build produced no warnings.
135+
# The strange command below asserts that the Doxygen command had an
136+
# output of zero length
137+
doxygen doxyfile_options 2>&1
138+
# Once Mbed OS has been fixed, enable the full test by replacing the top line with this:
139+
# - ( ! doxygen doxyfile_options 2>&1 | grep . )
140+
# Assert that all binary libraries are named correctly
141+
# The strange command below asserts that there are exactly 0 libraries
142+
# that do not start with lib
143+
find "(" -name "*.a" -or -name "*.ar" ")" -and -not -name "lib*" |
144+
tee BUILD/badlibs |
145+
sed -e "s/^/Bad library name found: /" && [ ! -s BUILD/badlibs ]
146+
# Assert that all assembler files are named correctly
147+
# The strange command below asserts that there are exactly 0 libraries
148+
# that do end with .s
149+
find -name "*.s" | tee BUILD/badasm |
150+
sed -e "s/^/Bad Assembler file name found: /" && [ ! -s BUILD/badasm ]
151+
152+
python-tests:
153+
# these tests run in 3.7, hence running in vm not in pre-built docker
154+
runs-on: ubuntu-latest
155+
steps:
156+
-
157+
name: Checkout repo
158+
uses: actions/checkout@v2
159+
160+
161+
- uses: actions/setup-python@v2
162+
with:
163+
python-version: '3.7'
164+
165+
-
166+
name: install dependencies
167+
run: |
168+
pip install -r requirements.txt
169+
pip install mock==2.0.0 attrs==19.1.0 pytest==3.3.0 'pylint>=1.9,<2' 'hypothesis>=3,<4' 'coverage>=4.5,<5'
170+
171+
-
172+
name: pytest
173+
run: |
174+
set -x
175+
coverage run -a -m pytest tools/test
176+
python tools/test/pylint.py
177+
coverage run -a tools/project.py -S | sed -n '/^Total/p'
178+
coverage html
179+
180+
pin-validation:
181+
runs-on: ubuntu-latest
182+
container:
183+
image: ghcr.io/armmbed/mbed-os-env:master-latest
184+
steps:
185+
-
186+
name: Checkout repo
187+
uses: actions/checkout@v2
188+
with:
189+
fetch-depth: 0
190+
191+
-
192+
name: validate pins
193+
run: |
194+
set -x
195+
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
196+
| ( grep '.*[\\|\/]PinNames.h$' || true ) \
197+
| while read file; do python ./hal/tests/pinvalidate/pinvalidate.py -vvvfp "${file}"; done
198+
git diff --exit-code --diff-filter=d --color
199+
200+
cmake-checks:
201+
env:
202+
NAME: mbed-test-mode-check
203+
ROOT: tools/cmake/tests/mbed_test_mode/
204+
TOOLCHAIN: GCC_ARM
205+
TARGET_NAME: K64F
206+
PROFILE: develop
207+
runs-on: ubuntu-latest
208+
container:
209+
image: ghcr.io/armmbed/mbed-os-env:master-latest
210+
steps:
211+
-
212+
name: Checkout repo
213+
uses: actions/checkout@v2
214+
215+
-
216+
name: cmake build
217+
run: |
218+
set -x
219+
mbedtools configure -p ${{ env.ROOT}} -t ${{ env.TOOLCHAIN }} -m ${{ env.TARGET_NAME }} --mbed-os-path .
220+
cmake -S ${{env.ROOT}} -B ${{ env.ROOT }}/cmake_build/${{env.TARGET_NAME}}/${{ env.PROFILE }}/${{ env.TOOLCHAIN }}/ -GNinja -DCMAKE_BUILD_TYPE=${{ env.PROFILE }}
221+
cmake --build ${{ env.ROOT }}/cmake_build/${{ env.TARGET_NAME }}/${{ env.PROFILE }}/${{ env.TOOLCHAIN }}/
222+
223+
-
224+
name: cmake unittest
225+
run: |
226+
set -x
227+
ctest --build-and-test . build --build-generator Ninja --build-options -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DCOVERAGE=ON --test-command ctest
228+
gcovr --gcov-executable gcov -r . ./build -s -e ".*\.h" --exclude-directories=${GITHUB_WORKSPACE}/build/UNITTESTS --exclude-directories=${GITHUB_WORKSPACE}/build/_deps
229+
ccache -s
230+
231+
# Reject any changes to tools that would require a re-release of the
232+
# tools for the online compiler.
233+
frozen-tools-check:
234+
runs-on: ubuntu-latest
235+
container:
236+
image: ghcr.io/armmbed/mbed-os-env:master-latest
237+
steps:
238+
-
239+
name: Checkout repo
240+
uses: actions/checkout@v2
241+
with:
242+
fetch-depth: 0
243+
244+
-
245+
name: frozen tool check
246+
run: |
247+
set -x
248+
git diff --name-only origin/${GITHUB_BASE_REF} \
249+
| egrep \
250+
-e "^tools/build_api*" \
251+
-e "^tools/config*" \
252+
-e "^tools/export*" \
253+
-e "^tools/notifier*" \
254+
-e "^tools/paths*" \
255+
-e "^tools/resources*" \
256+
-e "^tools/targets*" \
257+
-e "^tools/toolchains*" \
258+
-e "^tools/utils*" \
259+
-e "^$" > output.log | true
260+
frozen_files=`cat output.log`
261+
262+
if [ -z "$frozen_files" ]; then
263+
echo "Success!";
264+
else
265+
echo -e "Failure: Frozen files were modified\n$frozen_files";
266+
echo -e "Please see https://os.mbed.com/blog/entry/Introducing-the-new-Mbed-Tools/" \
267+
"\nfor why we've frozen the legacy tools.";
268+
false;
269+
fi

.mergify.yml

+34-12
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,17 @@ pull_request_rules:
3535
remove: ['needs: review', 'needs: CI']
3636

3737
# From needs: review to needs: work - CI failure
38-
- name: "label needs: work when travis-ci failed"
38+
- name: "label needs: work when GitHub Actions jobs have failed"
3939
conditions:
40-
# Travis failing
41-
- status-failure~=Travis CI - Pull Request
40+
# GitHub Actions are failing
41+
- check-failure=license-check
42+
- check-failure=include-check
43+
- check-failure=style-check
44+
- check-failure=docs-check
45+
- check-failure=python-tests
46+
- check-failure=pin-validation
47+
- check-failure=cmake-checks
48+
- check-failure=frozen-tools-check
4249
- "label!=mergify skip"
4350
actions:
4451
label:
@@ -49,7 +56,7 @@ pull_request_rules:
4956
- name: "label needs: work when Jenkins CI failed - pr head"
5057
conditions:
5158
# Jenkins CI failing
52-
- status-failure~=continuous-integration/jenkins/pr-head
59+
- check-failure~=continuous-integration/jenkins/pr-head
5360
- "label!=mergify skip"
5461
actions:
5562
label:
@@ -60,7 +67,7 @@ pull_request_rules:
6067
- name: "label needs: work when Jenkins CI failed - any of the pipeline"
6168
conditions:
6269
# Jenkins CI failing - any of the pipeline
63-
- status-failure~=^jenkins-ci
70+
- check-failure~=^jenkins-ci
6471
- "label!=mergify skip"
6572
actions:
6673
label:
@@ -80,11 +87,18 @@ pull_request_rules:
8087
# No conflict with the base branch
8188
- -conflict
8289

83-
# CI green policy, at least Travis should be green
84-
- status-success~=Travis CI - Pull Request
90+
# CI green policy, at least GitHub Actions jobs should be green
91+
- check-success=license-check
92+
- check-success=include-check
93+
- check-success=style-check
94+
- check-success=docs-check
95+
- check-success=python-tests
96+
- check-success=pin-validation
97+
- check-success=cmake-checks
98+
- check-success=frozen-tools-check
8599
# new CI needs to be done (neutral does not work, lets check if it failed or passed, if none, we need to run again)
86-
- -status-success~=continuous-integration/jenkins/pr-head
87-
- -status-failure~=continuous-integration/jenkins/pr-head
100+
- -check-success~=continuous-integration/jenkins/pr-head
101+
- -check-failure~=continuous-integration/jenkins/pr-head
88102
actions:
89103
label:
90104
add: ['needs: CI']
@@ -132,11 +146,19 @@ pull_request_rules:
132146
- "#changes-requested-reviews-by=0"
133147

134148
# CI green policy
135-
- status-success~=Travis CI - Pull Request
149+
- check-success=license-check
150+
- check-success=include-check
151+
- check-success=style-check
152+
- check-success=docs-check
153+
- check-success=python-tests
154+
- check-success=pin-validation
155+
- check-success=cmake-checks
156+
- check-success=frozen-tools-check
157+
136158
# Internal Jenkins - we rely on PR head to provide status
137-
- status-success~=continuous-integration/jenkins/pr-head
159+
- check-success~=continuous-integration/jenkins/pr-head
138160
# any of the jenkins pipeline needs to be green. We rely on not failure means all good (if skipped or executed)
139-
- -status-failure~=^jenkins-ci
161+
- -check-failure~=^jenkins-ci
140162
actions:
141163
label:
142164
add: ['ready for merge']

0 commit comments

Comments
 (0)