diff --git a/.forgejo/workflows/cancel-on-merge.yaml b/.forgejo/workflows/cancel-on-merge.yaml new file mode 100644 index 00000000..8bd77ea8 --- /dev/null +++ b/.forgejo/workflows/cancel-on-merge.yaml @@ -0,0 +1,20 @@ +name: Cancel Tests on Merge + +on: + pull_request: + types: [closed] + branches: + - main + - production + +jobs: + cancel-tests: + name: Cancel Running Tests + runs-on: ubuntu-22.04 + if: github.event.pull_request.merged == true + steps: + - name: Cancel in-progress workflow runs + uses: https://github.com/styfle/cancel-workflow-action@0.12.1 + with: + workflow_id: pr-tests.yaml + all_but_latest: false diff --git a/.forgejo/workflows/pr-tests.yaml b/.forgejo/workflows/pr-tests.yaml index 6d06e848..32ea08bf 100644 --- a/.forgejo/workflows/pr-tests.yaml +++ b/.forgejo/workflows/pr-tests.yaml @@ -2,10 +2,15 @@ name: Pull Request Tests on: pull_request: + types: [opened, synchronize, reopened] branches: - main - production +concurrency: + group: pr-tests-${{ github.event.pull_request.number }} + cancel-in-progress: true + env: MIX_ENV: test @@ -13,6 +18,8 @@ jobs: test-exunit: name: Run ExUnit Tests runs-on: ubuntu-22.04 + # Skip if PR is already merged + if: github.event.pull_request.merged == false env: DATABASE_URL: ecto://postgres:postgres@postgres/towerops_test