Skip to content

Commit 04cac2c

Browse files
committed
[nrf noup] ci: Add compliance test
Use standard Zephyr's compliance in CI, copy the dependencies from Zephyr repo. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent db9f97f commit 04cac2c

File tree

8 files changed

+766
-0
lines changed

8 files changed

+766
-0
lines changed

.checkpatch.conf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--emacs
2+
--summary-file
3+
--show-types
4+
--max-line-length=100
5+
--min-conf-desc-length=1
6+
7+
--ignore BRACES
8+
--ignore PRINTK_WITHOUT_KERN_LEVEL
9+
--ignore SPLIT_STRING
10+
--ignore VOLATILE
11+
--ignore CONFIG_EXPERIMENTAL
12+
--ignore PREFER_KERNEL_TYPES
13+
--ignore PREFER_SECTION
14+
--ignore AVOID_EXTERNS
15+
--ignore NETWORKING_BLOCK_COMMENT_STYLE
16+
--ignore DATE_TIME
17+
--ignore MINMAX
18+
--ignore CONST_STRUCT
19+
--ignore FILE_PATH_CHANGES
20+
--ignore SPDX_LICENSE_TAG
21+
--ignore C99_COMMENT_TOLERANCE
22+
--ignore REPEATED_WORD
23+
--ignore UNDOCUMENTED_DT_STRING
24+
--ignore DT_SPLIT_BINDING_PATCH
25+
--ignore DT_SCHEMA_BINDING_PATCH
26+
--ignore TRAILING_SEMICOLON
27+
--ignore COMPLEX_MACRO
28+
--ignore MULTISTATEMENT_MACRO_USE_DO_WHILE
29+
--ignore ENOSYS
30+
--ignore IS_ENABLED_CONFIG
31+
--ignore EMBEDDED_FUNCTION_NAME
32+
--ignore MACRO_WITH_FLOW_CONTROL

.github/workflows/compliance.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Compliance Checks
2+
3+
on: pull_request
4+
5+
jobs:
6+
check_compliance:
7+
runs-on: ubuntu-22.04
8+
name: Run compliance checks on patch series (PR)
9+
steps:
10+
- name: Update PATH for west
11+
run: |
12+
echo "$HOME/.local/bin" >> $GITHUB_PATH
13+
14+
- name: Checkout the code
15+
uses: actions/checkout@v3
16+
with:
17+
path: sdk-hostap
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
fetch-depth: 0
20+
21+
- name: cache-pip
22+
uses: actions/cache@v3
23+
with:
24+
path: ~/.cache/pip
25+
key: ${{ runner.os }}-doc-pip
26+
27+
- name: Install python dependencies
28+
working-directory: sdk-hostap
29+
run: |
30+
pip3 install setuptools
31+
pip3 install wheel
32+
pip3 install python-magic lxml junitparser gitlint pylint pykwalify yamllint
33+
pip3 install west
34+
35+
- name: Clone Zephyr downstream
36+
env:
37+
BASE_REF: ${{ github.base_ref }}
38+
working-directory: sdk-hostap
39+
run: |
40+
git config --global user.email "[email protected]"
41+
git config --global user.name "Your Name"
42+
git remote -v
43+
# Ensure there's no merge commits in the PR
44+
#[[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \
45+
#(echo "::error ::Merge commits not allowed, rebase instead";false)
46+
# Sauce tag checks before rebasing
47+
git rev-list --first-parent origin/${BASE_REF}..HEAD | tr '\n' ',' | \
48+
xargs gitlint -c ncs-sauce-tags.enable=true \
49+
-c title-starts-with-subsystem.regex=".*" --commits
50+
git rebase origin/${BASE_REF}
51+
# debug
52+
git log --pretty=oneline | head -n 10
53+
# Clone downstream Zephyr (no west needed as we only need the scripts)
54+
git clone https://github.com/nrfconnect/sdk-zephyr
55+
56+
- name: Run CODEOWNERS test
57+
id: codeowners
58+
env:
59+
BASE_REF: ${{ github.base_ref }}
60+
working-directory: sdk-hostap
61+
if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true
62+
run: |
63+
./scripts/ci/codeowners.py -c origin/${BASE_REF}..
64+
65+
- name: Run Compliance Tests
66+
continue-on-error: true
67+
id: compliance
68+
env:
69+
BASE_REF: ${{ github.base_ref }}
70+
working-directory: sdk-hostap
71+
if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true
72+
run: |
73+
export ZEPHYR_BASE="$(dirname "$(pwd)")/sdk-hostap/sdk-zephyr"
74+
# debug
75+
ls -la
76+
git log --pretty=oneline | head -n 10
77+
./scripts/ci/check_compliance.py --annotate -e KconfigBasic -e Kconfig \
78+
-c origin/${BASE_REF}..
79+
80+
- name: upload-results
81+
uses: actions/upload-artifact@v3
82+
continue-on-error: true
83+
if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true
84+
with:
85+
name: compliance.xml
86+
path: sdk-hostap/compliance.xml
87+
88+
- name: check-warns
89+
working-directory: sdk-hostap
90+
if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true
91+
run: |
92+
export ZEPHYR_BASE="$(dirname "$(pwd)")/sdk-hostap/sdk-zephyr"
93+
if [[ ! -s "compliance.xml" ]]; then
94+
exit 1;
95+
fi
96+
97+
files=($($ZEPHYR_BASE/scripts/ci/check_compliance.py -l))
98+
for file in "${files[@]}"; do
99+
f="${file}.txt"
100+
if [[ -s $f ]]; then
101+
errors=$(cat $f)
102+
errors="${errors//'%'/'%25'}"
103+
errors="${errors//$'\n'/'%0A'}"
104+
errors="${errors//$'\r'/'%0D'}"
105+
echo "::error file=${f}::$errors"
106+
exit=1
107+
fi
108+
done
109+
110+
if [ "${exit}" == "1" ]; then
111+
exit 1;
112+
fi

.gitlint

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# All these sections are optional, edit this file as you like.
2+
[general]
3+
ignore=title-trailing-punctuation, T3, title-max-length, T1, body-hard-tab, B3, B1
4+
# verbosity should be a value between 1 and 3, the commandline -v flags take precedence over this
5+
verbosity = 3
6+
# By default gitlint will ignore merge commits. Set to 'false' to disable.
7+
ignore-merge-commits=false
8+
ignore-revert-commits=false
9+
ignore-fixup-commits=false
10+
ignore-squash-commits=false
11+
# Enable debug mode (prints more output). Disabled by default
12+
debug = false
13+
14+
# Set the extra-path where gitlint will search for user defined rules
15+
# See http://jorisroovers.github.io/gitlint/user_defined_rules for details
16+
extra-path=scripts/gitlint
17+
18+
[title-max-length-no-revert]
19+
line-length=120
20+
21+
[body-min-line-count]
22+
min-line-count=1
23+
24+
[body-max-line-count]
25+
max-line-count=200
26+
27+
[title-starts-with-subsystem]
28+
regex = ^(?!subsys:)(([^:]+):)(\s([^:]+):)*\s(.+)$
29+
30+
[title-must-not-contain-word]
31+
# Comma-separated list of words that should not occur in the title. Matching is case
32+
# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING"
33+
# will not cause a violation, but "WIP: my title" will.
34+
words=wip
35+
36+
[title-match-regex]
37+
# python like regex (https://docs.python.org/2/library/re.html) that the
38+
# commit-msg title must be matched to.
39+
# Note that the regex can contradict with other rules if not used correctly
40+
# (e.g. title-must-not-contain-word).
41+
#regex=^US[0-9]*
42+
43+
[max-line-length-with-exceptions]
44+
# B1 = body-max-line-length
45+
line-length=120
46+
47+
[body-min-length]
48+
min-length=3
49+
50+
[body-is-missing]
51+
# Whether to ignore this rule on merge commits (which typically only have a title)
52+
# default = True
53+
ignore-merge-commits=false
54+
55+
[body-changed-file-mention]
56+
# List of files that need to be explicitly mentioned in the body when they are changed
57+
# This is useful for when developers often erroneously edit certain files or git submodules.
58+
# By specifying this rule, developers can only change the file when they explicitly reference
59+
# it in the commit message.
60+
#files=gitlint/rules.py,README.md

0 commit comments

Comments
 (0)