Skip to content

workflows/premerge: Cancel in progress jobs when a PR is merged #125329

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

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

tstellar
Copy link
Collaborator

@tstellar tstellar commented Feb 1, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Feb 1, 2025

@llvm/pr-subscribers-github-workflow

Author: Tom Stellard (tstellar)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/125329.diff

1 Files Affected:

  • (modified) .github/workflows/premerge.yaml (+17-3)
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 91aa3eefde372c..b268f1faab9890 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -5,6 +5,15 @@ permissions:
 
 on:
   pull_request:
+    types:
+      - opened
+      - synchronize
+      - reopened
+      # When a PR is closed, we still start this workflow, but then skip
+      # all the jobs, which makes it effectively a no-op.  The reason to
+      # do this is that it allows us to take advantage of concurrency groups
+      # to cancel in progress CI jobs whenever the PR is closed.
+      - closed
     paths:
       - .github/workflows/premerge.yaml
   push:
@@ -14,7 +23,9 @@ on:
 
 jobs:
   premerge-checks-linux:
-    if: github.repository_owner == 'llvm'
+    if: >-
+        github.repository_owner == 'llvm' &&
+        (github.event_name != 'pull_request' || github.event.action != 'closed')
     runs-on: llvm-premerge-linux-runners
     concurrency:
       group: ${{ github.workflow }}-linux-${{ github.event.pull_request.number || github.sha }}
@@ -73,7 +84,9 @@ jobs:
           ./.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})" "$(echo ${linux_runtimes} | tr ' ' ';')" "$(echo ${linux_runtime_check_targets})"
 
   premerge-checks-windows:
-    if: github.repository_owner == 'llvm'
+    if: >-
+        github.repository_owner == 'llvm' &&
+        (github.event_name != 'pull_request' || github.event.action != 'closed')
     runs-on: llvm-premerge-windows-runners
     concurrency:
       group: ${{ github.workflow }}-windows-${{ github.event.pull_request.number || github.sha }}
@@ -141,7 +154,8 @@ jobs:
     if: >-
       github.repository_owner == 'llvm' &&
       (startswith(github.ref_name, 'release/') ||
-       startswith(github.base_ref, 'release/'))
+       startswith(github.base_ref, 'release/')) &&
+      (github.event_name != 'pull_request' || github.event.action != 'closed')
     steps:
       - name: Checkout LLVM
         uses: actions/checkout@v4

Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@tstellar tstellar merged commit 2deba08 into llvm:main Feb 3, 2025
11 checks passed
@tstellar tstellar added this to the LLVM 20.X Release milestone Feb 3, 2025
@tstellar
Copy link
Collaborator Author

tstellar commented Feb 3, 2025

/cherry-pick 2deba08

@llvmbot
Copy link
Member

llvmbot commented Feb 3, 2025

Failed to cherry-pick: 2deba08

https://github.com/llvm/llvm-project/actions/runs/13123075560

Please manually backport the fix and push it to your github fork. Once this is done, please create a pull request

tstellar added a commit that referenced this pull request Feb 4, 2025
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants