about summary refs log tree commit diff
path: root/.github/workflows/check-by-name.yml
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows/check-by-name.yml')
-rw-r--r--.github/workflows/check-by-name.yml35
1 files changed, 15 insertions, 20 deletions
diff --git a/.github/workflows/check-by-name.yml b/.github/workflows/check-by-name.yml
index 8e2011cb6d52a..ce7802f4aa8ee 100644
--- a/.github/workflows/check-by-name.yml
+++ b/.github/workflows/check-by-name.yml
@@ -14,18 +14,16 @@ on:
     # While `edited` is also triggered when the PR title/body is changed,
     # this PR action is fairly quick, and PR's don't get edited that often,
     # so it shouldn't be a problem
+    # There is a feature request for adding a `base_changed` event:
+    # https://github.com/orgs/community/discussions/35058
     types: [opened, synchronize, reopened, edited]
 
-permissions:
-  # We need this permission to cancel the workflow run if there's a merge conflict
-  actions: write
+permissions: {}
 
-# Create a check-by-name concurrency group based on the pull request number. if
-# an event triggers a run on the same PR while a previous run is still in
-# progress, the previous run will be canceled and the new one will start.
-concurrency:
-  group: check-by-name-${{ github.event.pull_request.number }}
-  cancel-in-progress: true
+# We don't use a concurrency group here, because the action is triggered quite often (due to the PR edit
+# trigger), and contributers would get notified on any canceled run.
+# There is a feature request for supressing notifications on concurrency-canceled runs:
+# https://github.com/orgs/community/discussions/13015
 
 jobs:
   check:
@@ -79,31 +77,27 @@ jobs:
 
           if [[ "$mergeable" == "true" ]]; then
             echo "The PR can be merged, checking the merge commit $mergedSha"
+            echo "mergedSha=$mergedSha" >> "$GITHUB_ENV"
           else
-            echo "The PR cannot be merged, it has a merge conflict, cancelling the workflow.."
-            gh api \
-              --method POST \
-              -H "Accept: application/vnd.github+json" \
-              -H "X-GitHub-Api-Version: 2022-11-28" \
-              /repos/"$GITHUB_REPOSITORY"/actions/runs/"$GITHUB_RUN_ID"/cancel
-            sleep 60
-            # If it's still not canceled after a minute, something probably went wrong, just exit
-            exit 1
+            echo "The PR cannot be merged, it has a merge conflict, skipping the rest.."
           fi
-          echo "mergedSha=$mergedSha" >> "$GITHUB_ENV"
-      - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
+      - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
+        if: env.mergedSha
         with:
           # pull_request_target checks out the base branch by default
           ref: ${{ env.mergedSha }}
           # Fetches the merge commit and its parents
           fetch-depth: 2
       - name: Checking out base branch
+        if: env.mergedSha
         run: |
           base=$(mktemp -d)
           git worktree add "$base" "$(git rev-parse HEAD^1)"
           echo "base=$base" >> "$GITHUB_ENV"
       - uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26
+        if: env.mergedSha
       - name: Fetching the pinned tool
+        if: env.mergedSha
         # Update the pinned version using pkgs/test/check-by-name/update-pinned-tool.sh
         run: |
           # The pinned version of the tooling to use
@@ -114,6 +108,7 @@ jobs:
           # Adds a result symlink as a GC root
           nix-store --realise "$toolPath" --add-root result
       - name: Running nixpkgs-check-by-name
+        if: env.mergedSha
         env:
           # Force terminal colors to be enabled. The library that
           # nixpkgs-check-by-name uses respects: https://bixense.com/clicolors/