@@ -3,10 +3,10 @@ name: Compliance Checks
3
3
on :
4
4
pull_request :
5
5
types :
6
- - edited
7
- - opened
8
- - reopened
9
- - synchronize
6
+ - edited
7
+ - opened
8
+ - reopened
9
+ - synchronize
10
10
11
11
permissions :
12
12
contents : read
@@ -16,116 +16,116 @@ jobs:
16
16
runs-on : ubuntu-24.04
17
17
name : Run compliance checks on patch series (PR)
18
18
steps :
19
- - name : Update PATH for west
20
- run : |
21
- echo "$HOME/.local/bin" >> $GITHUB_PATH
22
- - name : Checkout the code
23
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24
- with :
25
- ref : ${{ github.event.pull_request.head.sha }}
26
- fetch-depth : 0
27
-
28
- - name : Rebase onto the target branch
29
- env :
30
- BASE_REF : ${{ github.base_ref }}
31
- run : |
32
- git config --global user.email "[email protected] "
33
- git config --global user.name "Your Name"
34
- git remote -v
35
- # Ensure there's no merge commits in the PR
36
- [[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \
37
- (echo "::error ::Merge commits not allowed, rebase instead";false)
38
- rm -fr ".git/rebase-apply"
39
- rm -fr ".git/rebase-merge"
40
- git rebase origin/${BASE_REF}
41
- git clean -f -d
42
- # debug
43
- git log --pretty=oneline | head -n 10
44
-
45
- - name : Set up Python
46
- uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
47
- with :
48
- python-version : 3.12
49
- cache : pip
50
- cache-dependency-path : scripts/requirements-actions.txt
51
-
52
- - name : Install Python packages
53
- run : |
54
- pip install -r scripts/requirements-actions.txt --require-hashes
55
-
56
- - name : west setup
57
- run : |
58
- west init -l . || true
59
- west config manifest.group-filter -- +ci,-optional
60
- west update -o=--depth=1 -n 2>&1 1> west.update.log || west update -o=--depth=1 -n 2>&1 1> west.update2.log
61
-
62
- - name : Setup Node.js
63
- uses : actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
64
- with :
65
- node-version : " 20"
66
-
67
- - name : Install dependencies
68
-
69
-
70
- - name : Run Compliance Tests
71
- continue-on-error : true
72
- id : compliance
73
- env :
74
- BASE_REF : ${{ github.base_ref }}
75
- run : |
76
- export ZEPHYR_BASE=$PWD
77
- # debug
78
- ls -la
79
- git log --pretty=oneline | head -n 10
80
- # Increase rename limit to allow for large PRs
81
- git config diff.renameLimit 10000
82
- excludes="-e KconfigBasic -e SysbuildKconfigBasic -e ClangFormat"
83
- # The signed-off-by check for dependabot should be skipped
84
- if [ "${{ github.actor }}" == "dependabot[bot]" ]; then
85
- excludes="$excludes -e Identity"
86
- fi
87
- ./scripts/ci/check_compliance.py --annotate $excludes -c origin/${BASE_REF}..
88
-
89
- - name : upload-results
90
- uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
91
- continue-on-error : true
92
- with :
93
- name : compliance.xml
94
- path : compliance.xml
95
-
96
- - name : check-warns
97
- run : |
98
- if [[ ! -s "compliance.xml" ]]; then
99
- exit 1;
100
- fi
101
-
102
- warns=("ClangFormat")
103
- files=($(./scripts/ci/check_compliance.py -l))
104
-
105
- for file in "${files[@]}"; do
106
- f="${file}.txt"
107
- if [[ -s $f ]]; then
108
- results=$(cat $f)
109
- results="${results//'%'/'%25'}"
110
- results="${results//$'\n'/'%0A'}"
111
- results="${results//$'\r'/'%0D'}"
112
-
113
- if [[ "${warns[@]}" =~ "${file}" ]]; then
114
- echo "::warning file=${f}::$results"
115
- else
116
- echo "::error file=${f}::$results"
117
- exit=1
19
+ - name : Update PATH for west
20
+ run : |
21
+ echo "$HOME/.local/bin" >> $GITHUB_PATH
22
+ - name : Checkout the code
23
+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24
+ with :
25
+ ref : ${{ github.event.pull_request.head.sha }}
26
+ fetch-depth : 0
27
+
28
+ - name : Rebase onto the target branch
29
+ env :
30
+ BASE_REF : ${{ github.base_ref }}
31
+ run : |
32
+ git config --global user.email "[email protected] "
33
+ git config --global user.name "Your Name"
34
+ git remote -v
35
+ # Ensure there's no merge commits in the PR
36
+ [[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \
37
+ (echo "::error ::Merge commits not allowed, rebase instead";false)
38
+ rm -fr ".git/rebase-apply"
39
+ rm -fr ".git/rebase-merge"
40
+ git rebase origin/${BASE_REF}
41
+ git clean -f -d
42
+ # debug
43
+ git log --pretty=oneline | head -n 10
44
+
45
+ - name : Set up Python
46
+ uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
47
+ with :
48
+ python-version : 3.12
49
+ cache : pip
50
+ cache-dependency-path : scripts/requirements-actions.txt
51
+
52
+ - name : Install Python packages
53
+ run : |
54
+ pip install -r scripts/requirements-actions.txt --require-hashes
55
+
56
+ - name : west setup
57
+ run : |
58
+ west init -l . || true
59
+ west config manifest.group-filter -- +ci,-optional
60
+ west update -o=--depth=1 -n 2>&1 1> west.update.log || west update -o=--depth=1 -n 2>&1 1> west.update2.log
61
+
62
+ - name : Setup Node.js
63
+ uses : actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
64
+ with :
65
+ node-version : " 20"
66
+
67
+ - name : Install dependencies
68
+
69
+
70
+ - name : Run Compliance Tests
71
+ continue-on-error : true
72
+ id : compliance
73
+ env :
74
+ BASE_REF : ${{ github.base_ref }}
75
+ run : |
76
+ export ZEPHYR_BASE=$PWD
77
+ # debug
78
+ ls -la
79
+ git log --pretty=oneline | head -n 10
80
+ # Increase rename limit to allow for large PRs
81
+ git config diff.renameLimit 10000
82
+ excludes="-e KconfigBasic -e SysbuildKconfigBasic -e ClangFormat"
83
+ # The signed-off-by check for dependabot should be skipped
84
+ if [ "${{ github.actor }}" == "dependabot[bot]" ]; then
85
+ excludes="$excludes -e Identity"
86
+ fi
87
+ ./scripts/ci/check_compliance.py --annotate $excludes -c origin/${BASE_REF}..
88
+
89
+ - name : upload-results
90
+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
91
+ continue-on-error : true
92
+ with :
93
+ name : compliance.xml
94
+ path : compliance.xml
95
+
96
+ - name : check-warns
97
+ run : |
98
+ if [[ ! -s "compliance.xml" ]]; then
99
+ exit 1;
100
+ fi
101
+
102
+ warns=("ClangFormat")
103
+ files=($(./scripts/ci/check_compliance.py -l))
104
+
105
+ for file in "${files[@]}"; do
106
+ f="${file}.txt"
107
+ if [[ -s $f ]]; then
108
+ results=$(cat $f)
109
+ results="${results//'%'/'%25'}"
110
+ results="${results//$'\n'/'%0A'}"
111
+ results="${results//$'\r'/'%0D'}"
112
+
113
+ if [[ "${warns[@]}" =~ "${file}" ]]; then
114
+ echo "::warning file=${f}::$results"
115
+ else
116
+ echo "::error file=${f}::$results"
117
+ exit=1
118
+ fi
118
119
fi
120
+ done
121
+
122
+ if [ "${exit}" == "1" ]; then
123
+ echo "Compliance error, check for error messages in the \"Run Compliance Tests\" step"
124
+ echo "You can run this step locally with the ./scripts/ci/check_compliance.py script."
125
+ exit 1;
126
+ fi
127
+
128
+ if [ "${{ steps.pr_description.outcome }}" == "failure" ]; then
129
+ echo "PR description cannot be empty"
130
+ exit 1;
119
131
fi
120
- done
121
-
122
- if [ "${exit}" == "1" ]; then
123
- echo "Compliance error, check for error messages in the \"Run Compliance Tests\" step"
124
- echo "You can run this step locally with the ./scripts/ci/check_compliance.py script."
125
- exit 1;
126
- fi
127
-
128
- if [ "${{ steps.pr_description.outcome }}" == "failure" ]; then
129
- echo "PR description cannot be empty"
130
- exit 1;
131
- fi
0 commit comments