Skip to content

Commit

Permalink
build: run compliance checks
Browse files Browse the repository at this point in the history
This change ensures that code changes satisfy a number of
criteria before being considered for submission.

The compliance checks are similar to those in Zephyr.

Fixes #57

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
  • Loading branch information
cfriedt committed Dec 29, 2020
1 parent 0bc0180 commit 51bf430
Show file tree
Hide file tree
Showing 3 changed files with 409 additions and 4 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/compliance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Compliance

on: pull_request

jobs:
compliance_job:
runs-on: ubuntu-latest
name: Run compliance checks on patch series (PR)
env:
ZEPHYR_BASE: ${{ github.workspace }}/zephyr
ZEPHYR_TOOLCHAIN_VARIANT: zephyr
ZEPHYR_SDK_INSTALL_DIR: /opt/sdk/zephyr-sdk-0.11.4
WS: ${{ github.workspace }}
GB: ${{ github.workspace }}/greybus
PATH: ${{ github.workspace }}/zephyr/scripts:${{ github.workspace }}/tools/net-tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
steps:
- name: Checkout the code
uses: actions/checkout@v2
with:
path: greybus

- name: cache-pip
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-doc-pip

- name: Install python dependencies
run: |
export PATH=$PATH:~/.local/bin
pip3 install setuptools
pip3 install wheel
pip3 install python-magic junitparser gitlint pylint pykwalify
pip3 install west
- name: Setup Environment
run: |
export PATH=$PATH:~/.local/bin
west init -l greybus
west update
cd ${ZEPHYR_BASE}
git apply ${GB}/zephyr-sys-byteorder-posix.patch
git apply ${GB}/zephyr-gpio-get-direction.patch
git apply ${GB}/zephyr-dynamic-pthread-stacks.patch
- name: Run Compliance Tests
id: compliance
env:
BASE_REF: ${{ github.base_ref }}
run: |
export PATH=$PATH:~/.local/bin
cd ${GB}
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git rebase origin/${BASE_REF}
${ZEPHYR_BASE}/scripts/ci/check_compliance.py -m Codeowners -m Devicetree -m Gitlint -m Identity -m Nits -m pylint -m checkpatch -m Kconfig -c origin/${BASE_REF}.. || true
- name: upload-results
uses: actions/upload-artifact@master
continue-on-error: True
with:
name: compliance.xml
path: compliance.xml

- name: check-warns
run: |
for file in Nits.txt checkpatch.txt Identity.txt Gitlint.txt pylint.txt Devicetree.txt Kconfig.txt Codeowners.txt; do
if [[ -s $file ]]; then
errors=$(cat $file)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=${file}::$errors"
exit=1
fi
done
if [ ${exit} == 1 ]; then
exit 1;
fi
Loading

0 comments on commit 51bf430

Please sign in to comment.