Skip to content

ENH: GHA: cancel in progress builds for pull requests#5019

Merged
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:masterfrom
blowekamp:gha_pr_cancel_in_progress
Dec 6, 2024
Merged

ENH: GHA: cancel in progress builds for pull requests#5019
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:masterfrom
blowekamp:gha_pr_cancel_in_progress

Conversation

@blowekamp
Copy link
Member

When a PR is updated, cancel currently running builds to restart new one.

PR Checklist

  • No API changes were made (or the changes have been approved)
  • No major design changes were made (or the changes have been approved)
  • Added test (or behavior not changed)
  • Updated API documentation (or API not changed)
  • Added license to new files (if any)
  • Added Python wrapping to new files (if any) as described in ITK Software Guide Section 9.5
  • Added ITK examples for all new major features (if any)

Refer to the ITK Software Guide for
further development details if necessary.

@github-actions github-actions bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Enhancement Improvement of existing methods or implementation labels Dec 6, 2024
@SimonRit
Copy link

SimonRit commented Dec 6, 2024

Sounds nice! Can we directly copy paste this code to InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/ for remote modules?

@blowekamp
Copy link
Member Author

Sounds nice! Can we directly copy paste this code to InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/ for remote modules?

It should. I copied it from SimpleITK.

@hjmjohnson hjmjohnson merged commit 948e77a into InsightSoftwareConsortium:master Dec 6, 2024
SimonRit pushed a commit to SimonRit/ITKRemoteModuleBuildTestPackageAction that referenced this pull request Dec 8, 2024
dzenanz pushed a commit to InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction that referenced this pull request Dec 9, 2024
@SimonRit
Copy link

I have one question on this code: do I understand correctly that it prevents having two PRs based on the same SHA running in parallel? That is my interpretation of the github.event.pull_request.head.sha group. Is this intentional?

SimonRit pushed a commit to SimonRit/RTK that referenced this pull request Dec 11, 2024
@blowekamp
Copy link
Member Author

I have one question on this code: do I understand correctly that it prevents having two PRs based on the same SHA running in parallel? That is my interpretation of the github.event.pull_request.head.sha group. Is this intentional?

The intention is to cancel in progress actions when a PR is updated.

This here implements by using a "workflow@SHA" as an identifier for this. I don't think this is right, as the SHA would change when a PR is updated.

I hastily grabbed this for this "Batch" build workflow in SimpleITK:
https://github.com/SimpleITK/SimpleITK/blob/master/.github/workflows/BatchBuild.yml#L14-L15

This one probably has closer to the right behavior:
https://github.com/SimpleITK/SimpleITK/blob/master/.github/workflows/Build.yml#L18-L19
https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs

I suspect that it should be something closer to:
group: '${{ github.workflow }}@${{ github.head_ref || github.ref }}'

SimonRit pushed a commit to RTKConsortium/RTK that referenced this pull request Dec 11, 2024
@SimonRit
Copy link

Ok thanks. I used ${{ github.workflow }}@${{ github.head_ref || github.run_id }} in RTKConsortium/RTK#650 but that should not make any difference with ${{ github.workflow }}@${{ github.head_ref || github.ref }} given the following line, cancel-in-progress: ${{ github.event_name == 'pull_request' }}. I'll make a PR to continue the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants