From 88a6855255916eb3734c4b5b86f978708530d07f Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Wed, 5 Jun 2024 08:26:04 -0400 Subject: [PATCH] test: cancel old unit tests when a new PR commit is pushed (#34909) Based on: * https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-and-the-default-behavior * https://stackoverflow.com/questions/68418857/how-to-cancel-existing-runs-when-a-new-push-happens-on-github-actions-but-only --- .github/workflows/unit-tests.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 6f13d2b9aac9..c6513baa0fbb 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -6,6 +6,12 @@ on: branches: - master +concurrency: + # We only need to be running tests for the latest commit on each PR + # (however, we fully test every commit on master, even as new ones land). + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + jobs: run-tests: name: ${{ matrix.shard_name }}(py=${{ matrix.python-version }},dj=${{ matrix.django-version }},mongo=${{ matrix.mongo-version }})