Skip to content
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
269 changes: 269 additions & 0 deletions .github/workflows/basic_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
# 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@v2
with:
fetch-depth: 0

-
name: install dependencies
shell: bash
run: |
pip install scancode-toolkit

-
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:master-latest

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

-
name: include check
run: |
# 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@v2
with:
fetch-depth: 0

-
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 '.*' )


-
name: astyle checks
run: |
set -x
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


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

steps:

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

-
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: doxygen
run: |
set -x
ccache -s
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 ]

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@v2


- uses: actions/setup-python@v2
with:
python-version: '3.7'

-
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: |
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@v2
with:
fetch-depth: 0

-
name: validate pins
run: |
set -x
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@v2

-
name: cmake build
run: |
set -x
mbedtools configure -p ${{ env.ROOT}} -t ${{ env.TOOLCHAIN }} -m ${{ env.TARGET_NAME }} --mbed-os-path .
cmake -S ${{env.ROOT}} -B ${{ env.ROOT }}/cmake_build/${{env.TARGET_NAME}}/${{ env.PROFILE }}/${{ env.TOOLCHAIN }}/ -GNinja -DCMAKE_BUILD_TYPE=${{ env.PROFILE }}
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 -DBUILD_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

# Reject any changes to tools that would require a re-release of the
# tools for the online compiler.
frozen-tools-check:
runs-on: ubuntu-latest
container:
image: ghcr.io/armmbed/mbed-os-env:master-latest
steps:
-
name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0

-
name: frozen tool check
run: |
set -x
git diff --name-only origin/${GITHUB_BASE_REF} \
| 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 "^$" > output.log | true
frozen_files=`cat output.log`

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
46 changes: 34 additions & 12 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ pull_request_rules:
remove: ['needs: review', 'needs: CI']

# From needs: review to needs: work - CI failure
- name: "label needs: work when travis-ci failed"
- name: "label needs: work when GitHub Actions jobs have failed"
conditions:
# Travis failing
- status-failure~=Travis CI - Pull Request
# GitHub Actions are failing
- check-failure=license-check
- check-failure=include-check
- check-failure=style-check
- check-failure=docs-check
- check-failure=python-tests
- check-failure=pin-validation
- check-failure=cmake-checks
- check-failure=frozen-tools-check
- "label!=mergify skip"
actions:
label:
Expand All @@ -49,7 +56,7 @@ pull_request_rules:
- name: "label needs: work when Jenkins CI failed - pr head"
conditions:
# Jenkins CI failing
- status-failure~=continuous-integration/jenkins/pr-head
- check-failure~=continuous-integration/jenkins/pr-head
- "label!=mergify skip"
actions:
label:
Expand All @@ -60,7 +67,7 @@ pull_request_rules:
- name: "label needs: work when Jenkins CI failed - any of the pipeline"
conditions:
# Jenkins CI failing - any of the pipeline
- status-failure~=^jenkins-ci
- check-failure~=^jenkins-ci
- "label!=mergify skip"
actions:
label:
Expand All @@ -80,11 +87,18 @@ pull_request_rules:
# No conflict with the base branch
- -conflict

# CI green policy, at least Travis should be green
- status-success~=Travis CI - Pull Request
# CI green policy, at least GitHub Actions jobs should be green
- check-success=license-check
- check-success=include-check
- check-success=style-check
- check-success=docs-check
- check-success=python-tests
- check-success=pin-validation
- check-success=cmake-checks
- check-success=frozen-tools-check
# new CI needs to be done (neutral does not work, lets check if it failed or passed, if none, we need to run again)
- -status-success~=continuous-integration/jenkins/pr-head
- -status-failure~=continuous-integration/jenkins/pr-head
- -check-success~=continuous-integration/jenkins/pr-head
- -check-failure~=continuous-integration/jenkins/pr-head
actions:
label:
add: ['needs: CI']
Expand Down Expand Up @@ -132,11 +146,19 @@ pull_request_rules:
- "#changes-requested-reviews-by=0"

# CI green policy
- status-success~=Travis CI - Pull Request
- check-success=license-check
- check-success=include-check
- check-success=style-check
- check-success=docs-check
- check-success=python-tests
- check-success=pin-validation
- check-success=cmake-checks
- check-success=frozen-tools-check

# Internal Jenkins - we rely on PR head to provide status
- status-success~=continuous-integration/jenkins/pr-head
- check-success~=continuous-integration/jenkins/pr-head
# any of the jenkins pipeline needs to be green. We rely on not failure means all good (if skipped or executed)
- -status-failure~=^jenkins-ci
- -check-failure~=^jenkins-ci
actions:
label:
add: ['ready for merge']
Expand Down
Loading