-
Notifications
You must be signed in to change notification settings - Fork 4
133 lines (119 loc) · 4.03 KB
/
qa-compliance.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Copyright (c) 2021-2023 TiaC Systems
# SPDX-License-Identifier: Apache-2.0
name: QA Compliance Check
on:
workflow_dispatch: # And manually on button click
pull_request:
types: [opened, synchronize, reopened]
jobs:
qa-compliance:
name: Run compliance checks on patch series (PR)
runs-on: ubuntu-latest
steps:
- name: Update GitHub PATH for west
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Checkout the code
uses: actions/checkout@v3
with:
path: workspace/bridle
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Restore PIP Cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-doc-pip
- name: Install base dependencies
working-directory: workspace
run: |
pip3 install --upgrade pip
pip3 install --upgrade setuptools
pip3 install --upgrade --requirement bridle/scripts/requirements-base.txt
pip3 show -f west
- name: West init and update
working-directory: workspace
env:
BASE_REF: ${{ github.base_ref }}
run: |
git -C bridle config --global user.email "[email protected]"
git -C bridle config --global user.name "Your Name"
git -C bridle remote -v
# Ensure there's no merge commits in the PR
[[ "$(git -C bridle rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \
(echo "::error ::Merge commits not allowed, rebase instead";false)
git -C bridle rebase origin/${BASE_REF}
# debug
git -C bridle log --pretty=oneline | head -n 10
west init -l bridle || true
west update
west zephyr-export
- name: Install compliance dependencies
working-directory: workspace
run: |
grep -hE -v "python-magic-bin" zephyr/scripts/requirements-*.txt | \
grep -hE "python-magic|lxml|junitparser|gitlint|pylint|pykwalify|yamllint" | \
xargs -I {} pip3 install --upgrade '{}'
- name: Run compliance tests
id: compliance
working-directory: workspace/bridle
env:
BASE_REF: ${{ github.base_ref }}
run: |
export BRIDLE_BASE="$(pwd)"
export ZEPHYR_BASE="$(dirname "$(pwd)")/zephyr"
# debug
ls -la
git log --pretty=oneline | head -n 10
# -m Checkpatch \
${BRIDLE_BASE}/scripts/ci/check_compliance.py \
--annotate \
-m Codeowners \
-m MaintainersFormat \
-m Gitlint \
-m YAMLLint \
-m Devicetree \
-m KconfigBasic \
-m Pylint \
-m Identity \
-m Nits \
-m ImageSize \
-m BinaryFiles \
-c origin/${BASE_REF}..
- name: Upload compliance tests results
uses: actions/upload-artifact@v3
with:
name: compliance.xml
path: workspace/bridle/compliance.xml
- name: Check warnings
working-directory: workspace/bridle
run: |
if [[ ! -s "compliance.xml" ]]; then
exit 1;
fi
# Checkpatch.txt \
for file in \
Codeowners.txt \
MaintainersFormat.txt \
Gitlint.txt \
YAMLLint.txt \
Devicetree.txt \
KconfigBasic.txt \
Pylint.txt \
Identity.txt \
Nits.txt \
ImageSize.txt \
BinaryFiles.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