Skip to content

Commit 4866c79

Browse files
authored
Merge pull request #15011 from saheerb/mbed-os-5.15
Travis CI migration to GitHub Actions
2 parents 4f89cbb + 6c918b2 commit 4866c79

19 files changed

+2003
-518
lines changed

.github/workflows/basic_checks.yml

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# This workflow performs the checks like license check,
2+
# doxygen, unit tests etc.
3+
4+
name: Basic Checks
5+
6+
on:
7+
pull_request:
8+
push:
9+
branches:
10+
- mbed-os-5.15
11+
12+
jobs:
13+
14+
license-check:
15+
runs-on: ubuntu-latest
16+
container:
17+
image: ghcr.io/armmbed/mbed-os-env:mbed-os-5.15-latest
18+
19+
steps:
20+
- name: Checkout repo
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
25+
-
26+
name: license check
27+
run: |
28+
set -x
29+
mkdir -p SCANCODE
30+
31+
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
32+
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true )
33+
echo $?
34+
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
35+
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
36+
| ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
37+
| while read file; do cp --parents "${file}" SCANCODE; done
38+
ls SCANCODE
39+
scancode -l --json-pp scancode.json SCANCODE
40+
41+
python ./tools/test/ci/scancode-evaluate.py scancode.json || true
42+
cat scancode-evaluate.log
43+
COUNT=$(cat scancode-evaluate.log | grep 'File:' | grep -v 'SPDX' | wc -l) || true
44+
if [ $COUNT = 0 ]; then
45+
echo "License check OK";
46+
true;
47+
else
48+
echo "License check failed, please review license issues found in files";
49+
false;
50+
fi
51+
52+
include-check:
53+
runs-on: ubuntu-latest
54+
container:
55+
image: ghcr.io/armmbed/mbed-os-env:mbed-os-5.15-latest
56+
57+
steps:
58+
- name: Checkout repo
59+
uses: actions/checkout@v2
60+
61+
-
62+
name: "include check"
63+
run: |
64+
! git grep '^#include\s["'"']mbed.h['"'"]$' -- '*.c' '*.h' '*.cpp' '*.hpp' \
65+
':!*platform_mbed.h' ':!*TESTS/*' ':!TEST_APPS/' ':!UNITTESTS/' \
66+
':!*tests/*' ':!*targets/*' ':!*TARGET_*' ':!*unsupported/*'
67+
68+
docs-check:
69+
runs-on: ubuntu-latest
70+
container:
71+
image: ghcr.io/armmbed/mbed-os-env:mbed-os-5.15-latest
72+
73+
steps:
74+
- name: Checkout repo
75+
uses: actions/checkout@v2
76+
77+
-
78+
name: spell checks
79+
run: |
80+
./tools/test/ci/doxy-spellchecker/spell.sh drivers
81+
./tools/test/ci/doxy-spellchecker/spell.sh platform
82+
./tools/test/ci/doxy-spellchecker/spell.sh events
83+
./tools/test/ci/doxy-spellchecker/spell.sh rtos
84+
./tools/test/ci/doxy-spellchecker/spell.sh connectivity/netsocket
85+
86+
-
87+
name: doxygen
88+
run: |
89+
mkdir BUILD
90+
# Assert that the Doxygen build produced no warnings.
91+
# The strange command below asserts that the Doxygen command had an
92+
# output of zero length
93+
doxygen doxyfile_options 2>&1
94+
# Once Mbed OS has been fixed, enable the full test by replacing the top line with this:
95+
# - ( ! doxygen doxyfile_options 2>&1 | grep . )
96+
# Assert that all binary libraries are named correctly
97+
# The strange command below asserts that there are exactly 0 libraries
98+
# that do not start with lib
99+
find "(" -name "*.a" -or -name "*.ar" ")" -and -not -name "lib*" |
100+
tee BUILD/badlibs |
101+
sed -e "s/^/Bad library name found: /" && [ ! -s BUILD/badlibs ]
102+
# Assert that all assembler files are named correctly
103+
# The strange command below asserts that there are exactly 0 libraries
104+
# that do end with .s
105+
find -name "*.s" | tee BUILD/badasm |
106+
sed -e "s/^/Bad Assembler file name found: /" && [ ! -s BUILD/badasm ]
107+
108+
109+
style-check:
110+
runs-on: ubuntu-latest
111+
container:
112+
image: ghcr.io/armmbed/mbed-os-env:mbed-os-5.15-latest
113+
114+
steps:
115+
- name: Checkout repo
116+
uses: actions/checkout@v2
117+
with:
118+
fetch-depth: 0
119+
120+
-
121+
name: astyle checks
122+
run: |
123+
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
124+
| ( grep '.*\.\(c\|cpp\|h\|hpp\)$' || true ) \
125+
| ( grep -v -f .astyleignore || true ) \
126+
| while read file; do astyle -n --options=.astylerc "${file}"; done
127+
git diff --exit-code --diff-filter=d --color
128+
129+
-
130+
name: "UTF-8 Check"
131+
run: |
132+
# Make sure we're not introducing any text which is not UTF-8 encoded
133+
git diff origin/${GITHUB_BASE_REF} -U0 | ( grep -a '^+' || true ) | ( ! grep -axv '.*' )
134+
135+
136+
python-tests:
137+
# these tests run in 3.7, hence running in vm not in pre-built docker
138+
runs-on: ubuntu-latest
139+
strategy:
140+
matrix:
141+
python-version: [ '3.5', '3.6', '3.7' ]
142+
143+
steps:
144+
-
145+
name: Checkout repo
146+
uses: actions/checkout@v2
147+
148+
149+
- uses: actions/setup-python@v2
150+
with:
151+
python-version: ${{ matrix.python-version }}
152+
153+
-
154+
name: install dependencies
155+
run: |
156+
pip install -r requirements.txt
157+
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'
158+
-
159+
name: pytest
160+
run: |
161+
# PYTHONPATH=.
162+
coverage run -a -m pytest tools/test
163+
python tools/test/pylint.py
164+
coverage run -a tools/project.py -S | sed -n '/^Total/p'
165+
coverage html
166+
167+
events-library:
168+
runs-on: ubuntu-latest
169+
container:
170+
image: ghcr.io/armmbed/mbed-os-env:mbed-os-5.15-latest
171+
172+
steps:
173+
174+
-
175+
name: Checkout repo
176+
uses: actions/checkout@v2
177+
with:
178+
fetch-depth: 0
179+
180+
-
181+
name: run test
182+
shell: bash
183+
run: |
184+
# Check that example compiles
185+
sed -n '/``` cpp/,/```/{/```$/Q;/```/d;p;}' events/README.md > main.cpp
186+
python tools/make.py -t GCC_ARM -m K64F --source=. --build=BUILD/K64F/GCC_ARM -j0
187+
# Check that example compiles without rtos
188+
sed -n '/``` cpp/,/```/{/```$/Q;/```/d;p;}' events/README.md > main.cpp
189+
rm -r rtos drivers/source/usb features/cellular features/netsocket features/nanostack \
190+
features/lwipstack features/frameworks/greentea-client \
191+
features/frameworks/utest features/frameworks/unity components BUILD
192+
python tools/make.py -t GCC_ARM -m DISCO_F401VC --source=. --build=BUILD/DISCO_F401VC/GCC_ARM -j0
193+
# Run local equeue tests
194+
make -C events/source test
195+
# Run profiling tests
196+
make -C events/source prof | tee prof
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
2+
name: Publish or Update docker image for mbed-os-5.15
3+
4+
on:
5+
push:
6+
branches:
7+
- mbed-os-5.15
8+
9+
paths:
10+
- requirements.txt
11+
- docker_images/mbed-os-env/**
12+
- .github/workflows/docker_management.publish.yml
13+
14+
# manual trigger when needed
15+
workflow_dispatch:
16+
17+
jobs:
18+
prepare-tags:
19+
runs-on: ubuntu-latest
20+
steps:
21+
-
22+
name: Extract branch name
23+
shell: bash
24+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
25+
id: extract_branch
26+
27+
-
28+
name: Checkout
29+
uses: actions/checkout@v2
30+
with:
31+
fetch-depth: 0
32+
33+
-
34+
name: Set UUID
35+
id: generate-uuid
36+
uses: filipstefansson/uuid-action@v1
37+
38+
# set docker tags we are building, and intending to publish
39+
# dev-tag is temporary for testing purpose. This should be considered as unstable.
40+
# dated-tag is created for versioning purpose
41+
# prod-tag-latest could be used by customers, CI etc for keeping up to date
42+
-
43+
name: Get build information
44+
shell: bash
45+
run: |
46+
mkdir -p build_info
47+
date=$(date +"%Y.%m.%dT%H.%M.%S")
48+
echo dev-${{ steps.extract_branch.outputs.branch }}-${date}-${{ steps.generate-uuid.outputs.uuid }} > build_info/dev_tag
49+
echo ${{ steps.extract_branch.outputs.branch }}-${date} > build_info/prod_tag_dated
50+
echo ${{ steps.extract_branch.outputs.branch }}-latest > build_info/prod_tag_latest
51+
echo ${{ steps.extract_branch.outputs.branch }} > build_info/mbed_os_version
52+
echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]' > build_info/repository_owner
53+
54+
-
55+
name: Archive information
56+
uses: actions/upload-artifact@v2
57+
with:
58+
name: build-info
59+
path: build_info
60+
61+
62+
build-container:
63+
runs-on: ubuntu-latest
64+
needs: prepare-tags
65+
66+
steps:
67+
-
68+
name: unarchive artefacts
69+
uses: actions/download-artifact@v2
70+
with:
71+
name: build-info
72+
73+
-
74+
name: Get build info from archive
75+
shell: bash
76+
id: build_info
77+
run: |
78+
value=`cat dev_tag`
79+
echo "DEV TAG is $value"
80+
echo "::set-output name=DOCKER_DEV_TAG::$value"
81+
value=`cat prod_tag_dated`
82+
echo "PROD TAG DATED is $value"
83+
echo "::set-output name=DOCKER_PROD_TAG_DATED::$value"
84+
value=`cat prod_tag_latest`
85+
echo "::set-output name=DOCKER_PROD_TAG_LATEST::$value"
86+
echo "PROD TAG is $value"
87+
value=`cat repository_owner`
88+
echo "::set-output name=REPO_OWNER::$value"
89+
-
90+
name: Set up Docker Buildx
91+
uses: docker/setup-buildx-action@v1
92+
93+
-
94+
name: Login to ghcr.io
95+
uses: docker/login-action@v1
96+
with:
97+
registry: ghcr.io
98+
username: ${{ github.repository_owner }}
99+
password: ${{ secrets.GITHUB_TOKEN }}
100+
101+
-
102+
name: Checkout
103+
uses: actions/checkout@v2
104+
105+
-
106+
name: Build docker containers
107+
uses: docker/build-push-action@v2
108+
id: docker_build_dev
109+
with:
110+
context: .
111+
platforms: linux/amd64
112+
push: true
113+
file: ./docker_images/mbed-os-env/Dockerfile
114+
tags: ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env:${{ steps.build_info.outputs.DOCKER_PROD_TAG_LATEST }}
115+
116+
# as docker tags are reused, copy also to a "fixed tag"
117+
# for troubleshooting purpose if needed
118+
-
119+
name: copy tag to fixed tag
120+
run: |
121+
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env:${{ steps.build_info.outputs.DOCKER_PROD_TAG_LATEST }} docker://ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env:${{ steps.build_info.outputs.DOCKER_PROD_TAG_DATED }}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build and test docker image
2+
3+
# This workflow is triggered when Dockerfile related or github action itself changes are made in a PR
4+
# The workflow is quite simple - builds and test the image. Release of newer version is done only when PR is merged.
5+
6+
on:
7+
pull_request:
8+
branches: [ mbed-os-5.15 ]
9+
paths:
10+
- docker_images/mbed-os-env/**
11+
- .github/workflows/docker_management.*
12+
- requirements.txt
13+
14+
jobs:
15+
16+
build-container:
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
platform: [linux/amd64]
22+
23+
steps:
24+
-
25+
name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v1
27+
28+
# use mbed-os-5.15 branch of blinky
29+
-
30+
name: Checkout
31+
uses: actions/checkout@v2
32+
with:
33+
repository: ARMmbed/mbed-os-example-blinky
34+
path: mbed-os-example-blinky
35+
ref: mbed-os-5.15
36+
37+
-
38+
name: Remove mbed-os from example-application
39+
shell: bash
40+
run: |
41+
cd mbed-os-example-blinky
42+
rm -rf mbed-os
43+
-
44+
name: Checkout
45+
uses: actions/checkout@v2
46+
with:
47+
path: mbed-os-example-blinky/mbed-os
48+
49+
-
50+
name: Build container
51+
uses: docker/build-push-action@v2
52+
id: docker_build_dev
53+
with:
54+
context: ./mbed-os-example-blinky/mbed-os
55+
platforms: ${{ matrix.platform }}
56+
file: ./mbed-os-example-blinky/mbed-os/docker_images/mbed-os-env/Dockerfile
57+
load: true
58+
tags: mbed-os-env:a_pr_test
59+
60+
-
61+
name: test the container
62+
id: test
63+
uses: addnab/docker-run-action@v2
64+
with:
65+
options: -v ${{ github.workspace }}:/work -w=/work
66+
image: mbed-os-env:a_pr_test
67+
shell: bash
68+
run: |
69+
uname -m
70+
cd mbed-os-example-blinky
71+
# build using CLI1
72+
mbed compile -m K64F -t GCC_ARM

0 commit comments

Comments
 (0)