Use a concurrency group to avoid unnecessary CI runs (#10059)
Right now, we build every time someone pushes, which is quite wasteful.
There are some use cases for finishing in-progress runs because we
might be close to creating a cacheable artifact, but we don't have
those yet, and for now this should avoid a lot of unnecessary builds.
Tested: You can see the run for 07241b5088 was cancelled when I pushed
another commit fixing up some leftover debugging.
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 3c3f8cd..2a6b6a0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -40,6 +40,13 @@
branches:
- main
+concurrency:
+ # A PR number if a pull request and otherwise the commit hash. This cancels
+ # queued and in-progress runs for the same PR (presubmit) or commit
+ # (postsubmit).
+ group: ${{ github.event.number || github.sha }}
+ cancel-in-progress: true
+
env:
BUCKET: gs://iree-github-actions-${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}-artifacts