Skip to content

Commit

Permalink
More action refactoring [skip-tests][workflow:test][workflow:!pull_re…
Browse files Browse the repository at this point in the history
…quest]
  • Loading branch information
alliepiper committed May 2, 2024
1 parent 1af0389 commit ff95447
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
18 changes: 9 additions & 9 deletions .github/actions/workflow-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ inputs:
description: "Skip running tests"
default: "false"
required: false
inspect-changes_script:
inspect_changes_script:
description: "If defined, run this script to determine which projects/deps need to be tested."
default: ""
required: false
inspect_changes_base_sha:
description: "If defined, use this base ref for inspect-changes script."
default: ""
required: false
matrix_file:
description: "Path to the matrix file in the consumer repository."
default: "ci/matrix.yaml"
Expand All @@ -34,19 +38,15 @@ runs:
using: "composite"
steps:

- name: Lookup PR info
id: get-pr-info
uses: nv-gha-runners/get-pr-info@main

- name: Inspect changes
if: ${{ inputs.inspect-changes_script != '' }}
if: ${{ inputs.inspect_changes_script != '' && inputs.inspect_changes_base_sha != '' }}
id: inspect-changes
shell: bash --noprofile --norc -euo pipefail {0}
env:
base_sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.sha }}
base_ref: ${{ inputs.inspect_changes_base_sha }}
run: |
echo "Running inspect-changes script..."
${{ inputs.inspect-changes_script }} ${base_sha} ${GITHUB_SHA}
${{ inputs.inspect_changes_script }} ${base_ref} ${GITHUB_SHA}
echo "Exporting summary..."
mkdir workflow
cp ${GITHUB_STEP_SUMMARY} workflow/changes.md
Expand All @@ -56,7 +56,7 @@ runs:
shell: bash --noprofile --norc -euo pipefail {0}
env:
skip_tests: ${{ inputs.skip_tests == 'true' && '--skip-tests' || ''}}
dirty_projects_flag: ${{ inputs.inspect-changes_script != '' && '--dirty-projects' || ''}}
dirty_projects_flag: ${{ steps.inspect-changes.outputs.dirty_projects != '' && '--dirty-projects' || ''}}
dirty_projects: ${{ steps.inspect-changes.outputs.dirty_projects }}
matrix_parser: ${{ inputs.matrix_parser && inputs.matrix_parser || '${GITHUB_ACTION_PATH}/build-workflow.py' }}
run: |
Expand Down
19 changes: 8 additions & 11 deletions .github/actions/workflow-results/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ name: "CCCL Workflow Sentinal"
description: "Check the results of the dispatched jobs and comment on the PR."

inputs:
github-token:
github_token:
description: "The GitHub token to use for commenting on the PR."
required: true
pr_number:
description: "The PR number to comment on, if applicable. No comment will be made if not provided."
required: false

outputs:
success:
Expand All @@ -15,18 +18,11 @@ runs:
using: "composite"
steps:

- name: Get Base Branch from PR
id: get-pr-info
uses: nv-gha-runners/get-pr-info@main

- name: Download workflow artifacts
uses: actions/download-artifact@v3
with:
name: workflow
path: workflow/
- run: |
find . | grep workflow
shell: bash --noprofile --norc -euo pipefail {0}

- name: Download job success artifacts
continue-on-error: true # This may fail if no jobs succeed. The checks below will catch this.
Expand Down Expand Up @@ -64,20 +60,21 @@ runs:
cp final_summary.md ${GITHUB_STEP_SUMMARY}
- name: Comment on PR
if: ${{ !cancelled() && inputs.pr_number != '' }}
continue-on-error: true
env:
PR_NUMBER: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).number }}
PR_NUMBER: ${{ fromJSON(inputs.pr_number) }}
COMMENT_BODY: ${{ steps.final-summary.outputs.SUMMARY }}
uses: actions/github-script@v4
with:
github-token: ${{ inputs.github-token }}
github-token: ${{ inputs.github_token }}
script: |
const pr_number = process.env.PR_NUMBER;
const owner = 'NVIDIA';
const repo = 'cccl';
// Decode URL-encoded string for proper display in comments
const commentBody = decodeURIComponent(process.env.COMMENT_BODY);
console.log('::group::Commenting on PR #' + pr_number + ' with the following message:)
console.log('::group::Commenting on PR #' + pr_number + ' with the following message:')
console.log(commentBody);
console.log('::endgroup::');
github.issues.createComment({
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/ci-workflow-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Lookup PR info
id: get-pr-info
uses: nv-gha-runners/get-pr-info@main
- name: Build workflow
id: build-workflow
uses: ./.github/actions/workflow-build
with:
skip_tests: ${{ toJSON(contains(github.event.head_commit.message, '[skip-tests]')) }}
inspect-changes_script: ${{ toJSON(!contains(github.event.head_commit.message, '[all-projects]') && 'ci/inspect_changes.sh' || '') }}
inspect_changes_script: ${{ toJSON(!contains(github.event.head_commit.message, '[all-projects]') && 'ci/inspect_changes.sh' || '') }}
inspect_changes_base_sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.sha }}
workflows: >-
${{ !contains(github.event.head_commit.message, '[workflow:!pull_request]') && 'pull_request' || '' }}
${{ contains(github.event.head_commit.message, '[workflow:nightly]') && 'nightly' || '' }}
Expand Down Expand Up @@ -92,11 +96,16 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v3

- name: Get Base Branch from PR
id: get-pr-info
uses: nv-gha-runners/get-pr-info@main

- name: Check workflow success
id: check-workflow
uses: ./.github/actions/workflow-results
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).number }}

- name: Check results
run: |
Expand Down
2 changes: 1 addition & 1 deletion ci/build_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ function test_preset()
local PRESET=$2
local GPU_REQUIRED=${3:-"true"}

if [ $GPU_REQUIRED -eq "true" ]; then
if [ "$GPU_REQUIRED" -eq "true" ]; then
fail_if_no_gpu
fi

Expand Down

0 comments on commit ff95447

Please sign in to comment.