Skip to content

Commit

Permalink
ci(build-test-tidy): introduce success condition jobs (#9769)
Browse files Browse the repository at this point in the history
Signed-off-by: M. Fatih Cırıt <[email protected]>
  • Loading branch information
xmfcx authored Dec 24, 2024
1 parent 24bcd0e commit 421ec7d
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/actions/evaluate-job-result/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Evaluate Job Result
description: Evaluates the result of a job and updates the summary.
inputs:
job_result:
description: Result of the job to evaluate (e.g., success, failure, skipped)
required: true
type: string
job_name:
description: Name of the job to evaluate
required: true
type: string
expected_results:
description: Comma-separated list of acceptable results (e.g., success,skipped)
required: true
type: string
outputs:
failed:
description: Indicates if the job failed
value: ${{ steps.evaluate.outputs.failed }}

runs:
using: composite
steps:
- name: Evaluate Job Result
id: evaluate
run: |
JOB_RESULT="${{ inputs.job_result }}"
IFS=',' read -ra EXPECTED <<< "${{ inputs.expected_results }}"
FAILED=false
for RESULT in "${EXPECTED[@]}"; do
if [[ "$JOB_RESULT" == "$RESULT" ]]; then
echo "- **${{ inputs.job_name }}:** "$JOB_RESULT" ✅" >> "$GITHUB_STEP_SUMMARY"
echo "failed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
done
# If no expected result matched
echo "::error::${{ inputs.job_name }} failed. ❌"
echo "- **${{ inputs.job_name }}:** failed ❌" >> "$GITHUB_STEP_SUMMARY"
echo "failed=true" >> "$GITHUB_OUTPUT"
exit 1
shell: bash
61 changes: 61 additions & 0 deletions .github/workflows/build-test-tidy-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ jobs:
secrets:
codecov-token: ${{ secrets.CODECOV_TOKEN }}

build-test-pr:
needs:
- build-and-test-differential
- build-and-test-differential-cuda
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Initialize Summary
run: echo "### Build Test PR Results" > $GITHUB_STEP_SUMMARY
shell: bash

- name: Evaluate build-and-test-differential
uses: ./.github/actions/evaluate-job-result
with:
job_result: ${{ needs.build-and-test-differential.result }}
job_name: build-and-test-differential
expected_results: success

- name: Evaluate build-and-test-differential-cuda
if: ${{ always() }}
uses: ./.github/actions/evaluate-job-result
with:
job_result: ${{ needs.build-and-test-differential-cuda.result }}
job_name: build-and-test-differential-cuda
expected_results: success,skipped

clang-tidy-differential:
needs:
- check-if-cuda-job-is-needed
Expand All @@ -74,3 +102,36 @@ jobs:
with:
container: ghcr.io/autowarefoundation/autoware:universe-devel
container-suffix: -cuda

clang-tidy-pr:
needs:
- clang-tidy-differential
- clang-tidy-differential-cuda
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Initialize Summary
run: echo "### Clang Tidy PR Results" > $GITHUB_STEP_SUMMARY
shell: bash

- name: Check clang-tidy success
if: ${{ needs.clang-tidy-differential.result == 'success' || needs.clang-tidy-differential-cuda.result == 'success' }}
run: |
echo "✅ Either one of the following has succeeded:" >> $GITHUB_STEP_SUMMARY
- name: Fail if conditions not met
if: ${{ !(needs.clang-tidy-differential.result == 'success' || needs.clang-tidy-differential-cuda.result == 'success') }}
run: |
echo "::error::❌ Either one of the following should have succeeded:"
echo "::error::clang-tidy-differential: ${{ needs.clang-tidy-differential.result }}"
echo "::error::clang-tidy-differential-cuda: ${{ needs.clang-tidy-differential-cuda.result }}"
echo "❌ Either one of the following should have succeeded:" >> $GITHUB_STEP_SUMMARY
exit 1
- name: Print the results
if: ${{ always() }}
run: |
echo "- **clang-tidy-differential:** ${{ needs.clang-tidy-differential.result }}" >> $GITHUB_STEP_SUMMARY
echo "- **clang-tidy-differential-cuda:** ${{ needs.clang-tidy-differential-cuda.result }}" >> $GITHUB_STEP_SUMMARY

0 comments on commit 421ec7d

Please sign in to comment.