2021-11-14 06:53:37 +08:00
|
|
|
name: Compliance Checks
|
2020-06-08 23:58:14 +08:00
|
|
|
|
|
|
|
on: pull_request
|
|
|
|
|
|
|
|
jobs:
|
2021-11-14 06:53:37 +08:00
|
|
|
check_compliance:
|
2022-08-23 00:27:37 +08:00
|
|
|
runs-on: ubuntu-20.04
|
2020-06-08 23:58:14 +08:00
|
|
|
name: Run compliance checks on patch series (PR)
|
|
|
|
steps:
|
2021-01-05 06:28:33 +08:00
|
|
|
- name: Update PATH for west
|
|
|
|
run: |
|
|
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
|
|
|
2020-06-08 23:58:14 +08:00
|
|
|
- name: Checkout the code
|
2022-10-14 01:48:20 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-01-05 06:28:33 +08:00
|
|
|
with:
|
2021-01-13 11:27:48 +08:00
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
fetch-depth: 0
|
2020-06-08 23:58:14 +08:00
|
|
|
|
|
|
|
- name: cache-pip
|
2022-10-14 02:11:23 +08:00
|
|
|
uses: actions/cache@v3
|
2020-06-08 23:58:14 +08:00
|
|
|
with:
|
|
|
|
path: ~/.cache/pip
|
|
|
|
key: ${{ runner.os }}-doc-pip
|
|
|
|
|
|
|
|
- name: Install python dependencies
|
|
|
|
run: |
|
|
|
|
pip3 install setuptools
|
|
|
|
pip3 install wheel
|
2022-11-11 22:48:35 +08:00
|
|
|
pip3 install python-magic lxml junitparser gitlint pylint pykwalify
|
2020-06-08 23:58:14 +08:00
|
|
|
pip3 install west
|
|
|
|
|
2021-01-05 06:28:33 +08:00
|
|
|
- name: west setup
|
2021-02-03 21:37:44 +08:00
|
|
|
env:
|
|
|
|
BASE_REF: ${{ github.base_ref }}
|
2021-01-05 06:28:33 +08:00
|
|
|
run: |
|
2021-02-03 21:37:44 +08:00
|
|
|
git config --global user.email "you@example.com"
|
|
|
|
git config --global user.name "Your Name"
|
|
|
|
git remote -v
|
2022-11-29 22:43:52 +08:00
|
|
|
# Ensure there's no merge commits in the PR
|
|
|
|
[[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \
|
|
|
|
(echo "::error ::Merge commits not allowed, rebase instead";false)
|
2021-02-03 21:37:44 +08:00
|
|
|
git rebase origin/${BASE_REF}
|
|
|
|
# debug
|
|
|
|
git log --pretty=oneline | head -n 10
|
2021-01-05 06:28:33 +08:00
|
|
|
west init -l . || true
|
2021-11-16 21:53:30 +08:00
|
|
|
west update 2>&1 1> west.update.log || west update 2>&1 1> west.update2.log
|
2021-01-05 06:28:33 +08:00
|
|
|
|
2020-06-08 23:58:14 +08:00
|
|
|
- name: Run Compliance Tests
|
2021-01-20 21:46:47 +08:00
|
|
|
continue-on-error: true
|
2020-06-08 23:58:14 +08:00
|
|
|
id: compliance
|
|
|
|
env:
|
|
|
|
BASE_REF: ${{ github.base_ref }}
|
|
|
|
run: |
|
|
|
|
export ZEPHYR_BASE=$PWD
|
2021-01-13 11:27:48 +08:00
|
|
|
# debug
|
|
|
|
ls -la
|
|
|
|
git log --pretty=oneline | head -n 10
|
2022-11-21 19:19:16 +08:00
|
|
|
./scripts/ci/check_compliance.py --annotate -e KconfigBasic \
|
2022-11-10 23:02:09 +08:00
|
|
|
-c origin/${BASE_REF}..
|
2020-06-08 23:58:14 +08:00
|
|
|
|
|
|
|
- name: upload-results
|
2022-08-23 01:13:39 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2020-06-08 23:58:14 +08:00
|
|
|
continue-on-error: True
|
|
|
|
with:
|
|
|
|
name: compliance.xml
|
|
|
|
path: compliance.xml
|
|
|
|
|
|
|
|
- name: check-warns
|
|
|
|
run: |
|
2021-01-20 21:46:47 +08:00
|
|
|
if [[ ! -s "compliance.xml" ]]; then
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2022-11-21 19:19:16 +08:00
|
|
|
files=($(./scripts/ci/check_compliance.py -l))
|
|
|
|
for file in "${files[@]}"; do
|
|
|
|
f="${file}.txt"
|
|
|
|
if [[ -s $f ]]; then
|
|
|
|
errors=$(cat $f)
|
2020-12-18 20:15:11 +08:00
|
|
|
errors="${errors//'%'/'%25'}"
|
|
|
|
errors="${errors//$'\n'/'%0A'}"
|
|
|
|
errors="${errors//$'\r'/'%0D'}"
|
2022-11-21 19:19:16 +08:00
|
|
|
echo "::error file=${f}::$errors"
|
2020-12-18 20:15:11 +08:00
|
|
|
exit=1
|
|
|
|
fi
|
|
|
|
done
|
2020-06-08 23:58:14 +08:00
|
|
|
|
2021-12-03 17:40:55 +08:00
|
|
|
if [ "${exit}" == "1" ]; then
|
2020-06-08 23:58:14 +08:00
|
|
|
exit 1;
|
|
|
|
fi
|