Skip to content

Commit 5e9778f

Browse files
committed
ci: compliance: convert compliance to workflow_call
Add compliance to twister workflow as a the first step. If compliance fials, no twister will run. Signed-off-by: Anas Nashif <[email protected]>
1 parent 2016ab5 commit 5e9778f

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

.github/workflows/compliance.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
name: Compliance Checks
22

33
on:
4-
pull_request:
5-
types:
6-
- edited
7-
- opened
8-
- reopened
9-
- synchronize
4+
workflow_call:
105

116
permissions:
127
contents: read
138

149
jobs:
10+
check_compliance_push:
11+
if: github.event_name == 'push'
12+
runs-on: ubuntu-22.04
13+
name: Run compliance checks on patch series (PR)
14+
steps:
15+
- name: Do nothing
16+
run: |
17+
echo "Doing nothing"
18+
1519
check_compliance:
20+
if: github.event_name == 'pull_request'
1621
runs-on: ubuntu-22.04
1722
name: Run compliance checks on patch series (PR)
1823
steps:
@@ -96,6 +101,8 @@ jobs:
96101
path: compliance.xml
97102

98103
- name: check-warns
104+
id: check-warns
105+
continue-on-error: true
99106
run: |
100107
if [[ ! -s "compliance.xml" ]]; then
101108
exit 1;
@@ -124,10 +131,12 @@ jobs:
124131
if [ "${exit}" == "1" ]; then
125132
echo "Compliance error, check for error messages in the \"Run Compliance Tests\" step"
126133
echo "You can run this step locally with the ./scripts/ci/check_compliance.py script."
134+
echo "exit_code=${exit}" >> $GITHUB_OUTPUT
127135
exit 1;
128136
fi
129-
130-
if [ "${{ steps.pr_description.outcome }}" == "failure" ]; then
131-
echo "PR description cannot be empty"
132-
exit 1;
133-
fi
137+
- name: resolve
138+
if: |
139+
steps.check-warns.outputs.exit_code != 0 &&
140+
! contains(github.event.pull_request.labels.*.name, 'Compliance: False Positive')
141+
run: |
142+
exit ${{ steps.check-warns.outputs.exit_code }}

.github/workflows/twister.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ concurrency:
2323
cancel-in-progress: true
2424

2525
jobs:
26+
compliance-check:
27+
uses: ./.github/workflows/compliance.yml
28+
2629
twister-build-prep:
30+
needs: compliance-check
2731
uses: ./.github/workflows/twister-prep.yaml
2832

2933
twister-build:
@@ -219,7 +223,7 @@ jobs:
219223
permissions:
220224
checks: write # to create the check run entry with Twister test results
221225
# the build-and-test job might be skipped, we don't need to run this job then
222-
if: success() || failure()
226+
if: (success() || failure()) && needs.twister-build.result != 'skipped'
223227

224228
steps:
225229
- name: Check out source code
@@ -236,6 +240,7 @@ jobs:
236240
path: artifacts
237241

238242
- name: Merge Test Results
243+
if: needs.twister-build.result != 'skipped'
239244
run: |
240245
pip install junitparser junit2html
241246
junitparser merge artifacts/*/*/twister.xml junit.xml
@@ -280,6 +285,7 @@ jobs:
280285
if: always()
281286
name: "Check Twister Status"
282287
needs:
288+
- compliance-check
283289
- twister-build-prep
284290
- twister-build
285291
uses: ./.github/workflows/ready-to-merge.yml

0 commit comments

Comments
 (0)