Skip to content

Commit 41f9cf3

Browse files
workflows: compliance: remove continue-on-error
Compliance is not failing on error, This should fix it. Added error state tracking using GitHub environment variables. Combined the two duplicate check-warns steps into a single more comprehensive Process Compliance Results step. Improved formatting for readability. Signed-off-by: Giacomo Dematteis <giacomo.dematteis@nordicsemi.no>
1 parent b589bff commit 41f9cf3

File tree

1 file changed

+75
-47
lines changed

1 file changed

+75
-47
lines changed

.github/workflows/compliance.yml

+75-47
Original file line numberDiff line numberDiff line change
@@ -16,56 +16,84 @@ jobs:
1616
if: ${{ !contains(github.actor, 'renovate') }}
1717

1818
steps:
19-
- name: Checkout the code
20-
uses: actions/checkout@v4
21-
with:
22-
path: asset-tracker-template
23-
ref: ${{ github.event.pull_request.head.sha }}
24-
fetch-depth: 0
19+
- name: Checkout the code
20+
uses: actions/checkout@v4
21+
with:
22+
path: asset-tracker-template
23+
ref: ${{ github.event.pull_request.head.sha }}
24+
fetch-depth: 0
2525

26-
- name: Initialize
27-
working-directory: asset-tracker-template
28-
run: |
29-
west init -l .
30-
west config manifest.group-filter +bsec
31-
west config build.sysbuild True
32-
west update -o=--depth=1 -n
33-
west blobs fetch hal_nordic
26+
- name: Initialize
27+
working-directory: asset-tracker-template
28+
run: |
29+
west init -l .
30+
west config manifest.group-filter +bsec
31+
west config build.sysbuild True
32+
west update -o=--depth=1 -n
33+
west blobs fetch hal_nordic
3434
35-
- name: Run Compliance Tests
36-
continue-on-error: true
37-
id: compliance
38-
shell: bash
39-
env:
40-
BASE_REF: ${{ github.base_ref }}
41-
working-directory: asset-tracker-template
42-
run: |
43-
export ZEPHYR_BASE="../zephyr"
44-
$ZEPHYR_BASE/scripts/ci/check_compliance.py -m Codeowners -m Devicetree -m Gitlint -m Identity -m Nits -m pylint -m checkpatch -m KconfigBasic -c origin/${BASE_REF}..
35+
- name: Run Compliance Tests
36+
id: compliance
37+
shell: bash
38+
env:
39+
BASE_REF: ${{ github.base_ref }}
40+
working-directory: asset-tracker-template
41+
run: |
42+
export ZEPHYR_BASE="../zephyr"
43+
$ZEPHYR_BASE/scripts/ci/check_compliance.py \
44+
-m Codeowners \
45+
-m Devicetree \
46+
-m Gitlint \
47+
-m Identity \
48+
-m Nits \
49+
-m pylint \
50+
-m checkpatch \
51+
-m KconfigBasic \
52+
-c origin/${BASE_REF}.. || \
53+
echo "COMPLIANCE_FAILED=true" >> $GITHUB_ENV
4554
46-
- name: check-warns
47-
working-directory: asset-tracker-template
48-
shell: bash
49-
run: |
50-
if [[ ! -s "compliance.xml" ]]; then
51-
exit 1;
52-
fi
55+
- name: Process Compliance Results
56+
working-directory: asset-tracker-template
57+
shell: bash
58+
run: |
59+
# Check for compliance.xml existence
60+
if [[ ! -s "compliance.xml" ]]; then
61+
echo "::error::compliance.xml file is missing or empty"
62+
exit 1
63+
fi
64+
65+
# Initialize exit code
66+
exit_code=0
67+
68+
# Define error files to check
69+
error_files=(
70+
"Nits.txt"
71+
"checkpatch.txt"
72+
"Identity.txt"
73+
"Gitlint.txt"
74+
"pylint.txt"
75+
"Devicetree.txt"
76+
"Kconfig.txt"
77+
"KconfigBasic.txt"
78+
"Codeowners.txt"
79+
)
80+
81+
# Process each error file
82+
for file in "${error_files[@]}"; do
83+
if [[ -s $file ]]; then
84+
errors=$(cat $file)
85+
errors="${errors//'%'/'%25'}"
86+
errors="${errors//$'\n'/'%0A'}"
87+
errors="${errors//$'\r'/'%0D'}"
88+
echo "::error file=${file}::$errors"
89+
exit_code=1
90+
fi
91+
done
5392
54-
- name: check-warns
55-
working-directory: asset-tracker-template
56-
shell: bash
57-
run: |
58-
for file in Nits.txt checkpatch.txt Identity.txt Gitlint.txt pylint.txt Devicetree.txt Kconfig.txt KconfigBasic.txt Codeowners.txt; do
59-
if [[ -s $file ]]; then
60-
errors=$(cat $file)
61-
errors="${errors//'%'/'%25'}"
62-
errors="${errors//$'\n'/'%0A'}"
63-
errors="${errors//$'\r'/'%0D'}"
64-
echo "::error file=${file}::$errors"
65-
exit=1
93+
# Check if compliance test failed
94+
if [[ "$COMPLIANCE_FAILED" == "true" ]]; then
95+
echo "::error::Compliance tests failed. Please check the logs for details."
96+
exit_code=1
6697
fi
67-
done
6898
69-
if [[ $exit == 1 ]]; then
70-
exit 1
71-
fi
99+
exit $exit_code

0 commit comments

Comments
 (0)