Skip to content

Commit 421ec7d

Browse files
authored
ci(build-test-tidy): introduce success condition jobs (#9769)
Signed-off-by: M. Fatih Cırıt <mfc@autoware.org>
1 parent 24bcd0e commit 421ec7d

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Evaluate Job Result
2+
description: Evaluates the result of a job and updates the summary.
3+
inputs:
4+
job_result:
5+
description: Result of the job to evaluate (e.g., success, failure, skipped)
6+
required: true
7+
type: string
8+
job_name:
9+
description: Name of the job to evaluate
10+
required: true
11+
type: string
12+
expected_results:
13+
description: Comma-separated list of acceptable results (e.g., success,skipped)
14+
required: true
15+
type: string
16+
outputs:
17+
failed:
18+
description: Indicates if the job failed
19+
value: ${{ steps.evaluate.outputs.failed }}
20+
21+
runs:
22+
using: composite
23+
steps:
24+
- name: Evaluate Job Result
25+
id: evaluate
26+
run: |
27+
JOB_RESULT="${{ inputs.job_result }}"
28+
IFS=',' read -ra EXPECTED <<< "${{ inputs.expected_results }}"
29+
FAILED=false
30+
31+
for RESULT in "${EXPECTED[@]}"; do
32+
if [[ "$JOB_RESULT" == "$RESULT" ]]; then
33+
echo "- **${{ inputs.job_name }}:** "$JOB_RESULT" ✅" >> "$GITHUB_STEP_SUMMARY"
34+
echo "failed=false" >> "$GITHUB_OUTPUT"
35+
exit 0
36+
fi
37+
done
38+
39+
# If no expected result matched
40+
echo "::error::${{ inputs.job_name }} failed. ❌"
41+
echo "- **${{ inputs.job_name }}:** failed ❌" >> "$GITHUB_STEP_SUMMARY"
42+
echo "failed=true" >> "$GITHUB_OUTPUT"
43+
44+
exit 1
45+
shell: bash

.github/workflows/build-test-tidy-pr.yaml

+61
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,34 @@ jobs:
5858
secrets:
5959
codecov-token: ${{ secrets.CODECOV_TOKEN }}
6060

61+
build-test-pr:
62+
needs:
63+
- build-and-test-differential
64+
- build-and-test-differential-cuda
65+
if: ${{ always() }}
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v4
69+
70+
- name: Initialize Summary
71+
run: echo "### Build Test PR Results" > $GITHUB_STEP_SUMMARY
72+
shell: bash
73+
74+
- name: Evaluate build-and-test-differential
75+
uses: ./.github/actions/evaluate-job-result
76+
with:
77+
job_result: ${{ needs.build-and-test-differential.result }}
78+
job_name: build-and-test-differential
79+
expected_results: success
80+
81+
- name: Evaluate build-and-test-differential-cuda
82+
if: ${{ always() }}
83+
uses: ./.github/actions/evaluate-job-result
84+
with:
85+
job_result: ${{ needs.build-and-test-differential-cuda.result }}
86+
job_name: build-and-test-differential-cuda
87+
expected_results: success,skipped
88+
6189
clang-tidy-differential:
6290
needs:
6391
- check-if-cuda-job-is-needed
@@ -74,3 +102,36 @@ jobs:
74102
with:
75103
container: ghcr.io/autowarefoundation/autoware:universe-devel
76104
container-suffix: -cuda
105+
106+
clang-tidy-pr:
107+
needs:
108+
- clang-tidy-differential
109+
- clang-tidy-differential-cuda
110+
if: ${{ always() }}
111+
runs-on: ubuntu-latest
112+
steps:
113+
- name: Initialize Summary
114+
run: echo "### Clang Tidy PR Results" > $GITHUB_STEP_SUMMARY
115+
shell: bash
116+
117+
- name: Check clang-tidy success
118+
if: ${{ needs.clang-tidy-differential.result == 'success' || needs.clang-tidy-differential-cuda.result == 'success' }}
119+
run: |
120+
echo "✅ Either one of the following has succeeded:" >> $GITHUB_STEP_SUMMARY
121+
122+
- name: Fail if conditions not met
123+
if: ${{ !(needs.clang-tidy-differential.result == 'success' || needs.clang-tidy-differential-cuda.result == 'success') }}
124+
run: |
125+
echo "::error::❌ Either one of the following should have succeeded:"
126+
echo "::error::clang-tidy-differential: ${{ needs.clang-tidy-differential.result }}"
127+
echo "::error::clang-tidy-differential-cuda: ${{ needs.clang-tidy-differential-cuda.result }}"
128+
129+
echo "❌ Either one of the following should have succeeded:" >> $GITHUB_STEP_SUMMARY
130+
131+
exit 1
132+
133+
- name: Print the results
134+
if: ${{ always() }}
135+
run: |
136+
echo "- **clang-tidy-differential:** ${{ needs.clang-tidy-differential.result }}" >> $GITHUB_STEP_SUMMARY
137+
echo "- **clang-tidy-differential-cuda:** ${{ needs.clang-tidy-differential-cuda.result }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)