Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: pass run condition to reusable workflow #9771

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions .github/actions/evaluate-job-result/action.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions .github/workflows/build-and-test-differential.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
default: humble
required: false
type: string
run-condition:
default: true
required: false
type: boolean
container-suffix:
required: false
default: ""
Expand All @@ -28,6 +32,7 @@ env:

jobs:
build-and-test-differential:
if: ${{ inputs.run-condition }}
runs-on: ${{ inputs.runner }}
container: ${{ inputs.container }}${{ inputs.container-suffix }}
steps:
Expand Down
68 changes: 5 additions & 63 deletions .github/workflows/build-test-tidy-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,88 +50,30 @@ jobs:

build-and-test-differential-cuda:
needs: check-if-cuda-job-is-needed
if: ${{ needs.check-if-cuda-job-is-needed.outputs.cuda_job_is_needed == 'true' }}
uses: ./.github/workflows/build-and-test-differential.yaml
with:
container: ghcr.io/autowarefoundation/autoware:universe-devel
container-suffix: -cuda
run-condition: ${{ needs.check-if-cuda-job-is-needed.outputs.cuda_job_is_needed == 'true' }}
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:
if: ${{ always() }} # always run to provide report for status check
needs:
- check-if-cuda-job-is-needed
- build-and-test-differential
if: ${{ needs.check-if-cuda-job-is-needed.outputs.cuda_job_is_needed == 'false' }}
uses: ./.github/workflows/clang-tidy-differential.yaml
with:
container: ghcr.io/autowarefoundation/autoware:universe-devel
run-condition: ${{ needs.check-if-cuda-job-is-needed.outputs.cuda_job_is_needed == 'false' }}

clang-tidy-differential-cuda:
if: ${{ always() }} # always run to provide report for status check
needs:
- build-and-test-differential-cuda
Comment on lines +72 to 74
Copy link
Member Author

@mitsudome-r mitsudome-r Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to explicitly set "always()" condition to make sure that "clang-tidy-differential-cuda" job even when build-and-test-differential-cuda is not ran.

Check here for the details:
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks

When a job fails, any jobs that depend on the failed job are skipped and do not report a failure. A pull request that requires the check may not be blocked. To use a required check on a job that depends on other jobs, use the always() conditional expression in addition to needs, see Using jobs in a workflow.

uses: ./.github/workflows/clang-tidy-differential.yaml
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
run-condition: ${{ needs.check-if-cuda-job-is-needed.outputs.cuda_job_is_needed == 'true' }}
5 changes: 5 additions & 0 deletions .github/workflows/clang-tidy-differential.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ on:
default: ubuntu-24.04
required: false
type: string
run-condition:
default: true
required: false
type: boolean

jobs:
clang-tidy-differential:
if: ${{ inputs.run-condition }}
runs-on: ${{ inputs.runner }}
container: ${{ inputs.container }}${{ inputs.container-suffix }}
steps:
Expand Down
Loading