Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis CI migration to GitHub Actions #15011

Merged
merged 3 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 196 additions & 0 deletions .github/workflows/basic_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# This workflow performs the checks like license check,
# doxygen, unit tests etc.

name: Basic Checks

on:
pull_request:
push:
branches:
- mbed-os-5.15

jobs:

license-check:
runs-on: ubuntu-latest
container:
image: ghcr.io/armmbed/mbed-os-env:mbed-os-5.15-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0

-
name: license check
run: |
set -x
mkdir -p SCANCODE

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:mbed-os-5.15-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2

-
name: "include check"
run: |
! git grep '^#include\s["'"']mbed.h['"'"]$' -- '*.c' '*.h' '*.cpp' '*.hpp' \
':!*platform_mbed.h' ':!*TESTS/*' ':!TEST_APPS/' ':!UNITTESTS/' \
':!*tests/*' ':!*targets/*' ':!*TARGET_*' ':!*unsupported/*'

docs-check:
runs-on: ubuntu-latest
container:
image: ghcr.io/armmbed/mbed-os-env:mbed-os-5.15-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2

-
name: spell checks
run: |
./tools/test/ci/doxy-spellchecker/spell.sh drivers
./tools/test/ci/doxy-spellchecker/spell.sh platform
./tools/test/ci/doxy-spellchecker/spell.sh events
./tools/test/ci/doxy-spellchecker/spell.sh rtos
./tools/test/ci/doxy-spellchecker/spell.sh connectivity/netsocket

-
name: doxygen
run: |
mkdir BUILD
# 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 ]


style-check:
runs-on: ubuntu-latest
container:
image: ghcr.io/armmbed/mbed-os-env:mbed-os-5.15-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0

-
name: astyle checks
run: |
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
| ( grep '.*\.\(c\|cpp\|h\|hpp\)$' || true ) \
| ( grep -v -f .astyleignore || true ) \
| while read file; do astyle -n --options=.astylerc "${file}"; done
git diff --exit-code --diff-filter=d --color

-
name: "UTF-8 Check"
run: |
# 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 '.*' )


python-tests:
# these tests run in 3.7, hence running in vm not in pre-built docker
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.5', '3.6', '3.7' ]

steps:
-
name: Checkout repo
uses: actions/checkout@v2


- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

-
name: install dependencies
run: |
pip install -r requirements.txt
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'
-
name: pytest
run: |
# 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

events-library:
runs-on: ubuntu-latest
container:
image: ghcr.io/armmbed/mbed-os-env:mbed-os-5.15-latest

steps:

-
name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0

-
name: run test
shell: bash
run: |
# Check that example compiles
sed -n '/``` cpp/,/```/{/```$/Q;/```/d;p;}' events/README.md > main.cpp
python tools/make.py -t GCC_ARM -m K64F --source=. --build=BUILD/K64F/GCC_ARM -j0
# Check that example compiles without rtos
sed -n '/``` cpp/,/```/{/```$/Q;/```/d;p;}' events/README.md > main.cpp
rm -r rtos drivers/source/usb features/cellular features/netsocket features/nanostack \
features/lwipstack features/frameworks/greentea-client \
features/frameworks/utest features/frameworks/unity components BUILD
python tools/make.py -t GCC_ARM -m DISCO_F401VC --source=. --build=BUILD/DISCO_F401VC/GCC_ARM -j0
# Run local equeue tests
make -C events/source test
# Run profiling tests
make -C events/source prof | tee prof
121 changes: 121 additions & 0 deletions .github/workflows/docker_management.publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@

name: Publish or Update docker image for mbed-os-5.15

on:
push:
branches:
- mbed-os-5.15

paths:
- requirements.txt
- docker_images/mbed-os-env/**
- .github/workflows/docker_management.publish.yml

# manual trigger when needed
workflow_dispatch:

jobs:
prepare-tags:
runs-on: ubuntu-latest
steps:
-
name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

-
name: Set UUID
id: generate-uuid
uses: filipstefansson/uuid-action@v1

# set docker tags we are building, and intending to publish
# dev-tag is temporary for testing purpose. This should be considered as unstable.
# dated-tag is created for versioning purpose
# prod-tag-latest could be used by customers, CI etc for keeping up to date
-
name: Get build information
shell: bash
run: |
mkdir -p build_info
date=$(date +"%Y.%m.%dT%H.%M.%S")
echo dev-${{ steps.extract_branch.outputs.branch }}-${date}-${{ steps.generate-uuid.outputs.uuid }} > build_info/dev_tag
echo ${{ steps.extract_branch.outputs.branch }}-${date} > build_info/prod_tag_dated
echo ${{ steps.extract_branch.outputs.branch }}-latest > build_info/prod_tag_latest
echo ${{ steps.extract_branch.outputs.branch }} > build_info/mbed_os_version
echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]' > build_info/repository_owner

-
name: Archive information
uses: actions/upload-artifact@v2
with:
name: build-info
path: build_info


build-container:
runs-on: ubuntu-latest
needs: prepare-tags

steps:
-
name: unarchive artefacts
uses: actions/download-artifact@v2
with:
name: build-info

-
name: Get build info from archive
shell: bash
id: build_info
run: |
value=`cat dev_tag`
echo "DEV TAG is $value"
echo "::set-output name=DOCKER_DEV_TAG::$value"
value=`cat prod_tag_dated`
echo "PROD TAG DATED is $value"
echo "::set-output name=DOCKER_PROD_TAG_DATED::$value"
value=`cat prod_tag_latest`
echo "::set-output name=DOCKER_PROD_TAG_LATEST::$value"
echo "PROD TAG is $value"
value=`cat repository_owner`
echo "::set-output name=REPO_OWNER::$value"
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

-
name: Login to ghcr.io
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

-
name: Checkout
uses: actions/checkout@v2

-
name: Build docker containers
uses: docker/build-push-action@v2
id: docker_build_dev
with:
context: .
platforms: linux/amd64
push: true
file: ./docker_images/mbed-os-env/Dockerfile
tags: ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env:${{ steps.build_info.outputs.DOCKER_PROD_TAG_LATEST }}

# as docker tags are reused, copy also to a "fixed tag"
# for troubleshooting purpose if needed
-
name: copy tag to fixed tag
run: |
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 }}
72 changes: 72 additions & 0 deletions .github/workflows/docker_management.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build and test docker image

# This workflow is triggered when Dockerfile related or github action itself changes are made in a PR
# The workflow is quite simple - builds and test the image. Release of newer version is done only when PR is merged.

on:
pull_request:
branches: [ mbed-os-5.15 ]
paths:
- docker_images/mbed-os-env/**
- .github/workflows/docker_management.*
- requirements.txt

jobs:

build-container:
runs-on: ubuntu-latest

strategy:
matrix:
platform: [linux/amd64]

steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# use mbed-os-5.15 branch of blinky
-
name: Checkout
uses: actions/checkout@v2
with:
repository: ARMmbed/mbed-os-example-blinky
path: mbed-os-example-blinky
ref: mbed-os-5.15

-
name: Remove mbed-os from example-application
shell: bash
run: |
cd mbed-os-example-blinky
rm -rf mbed-os
-
name: Checkout
uses: actions/checkout@v2
with:
path: mbed-os-example-blinky/mbed-os

-
name: Build container
uses: docker/build-push-action@v2
id: docker_build_dev
with:
context: ./mbed-os-example-blinky/mbed-os
platforms: ${{ matrix.platform }}
file: ./mbed-os-example-blinky/mbed-os/docker_images/mbed-os-env/Dockerfile
load: true
tags: mbed-os-env:a_pr_test

-
name: test the container
id: test
uses: addnab/docker-run-action@v2
with:
options: -v ${{ github.workspace }}:/work -w=/work
image: mbed-os-env:a_pr_test
shell: bash
run: |
uname -m
cd mbed-os-example-blinky
# build using CLI1
mbed compile -m K64F -t GCC_ARM
Loading