Hello,
currently I try to improve our test automation. Since we have some E2E test which run like 5-15min, I need to cancel running tests which are triggered on the same pull request.
I experimented on a separat git repository with the following action:
name: Check Abortable Pull Request Runs
on:
workflow_dispatch:
push:
pull_request:
types:
- synchronize
- opened
- reopened
jobs:
test_pr:
runs-on: ubuntu-x64-small
steps:
- name: 5sec job 1
run: |
# simulate a job adjustment
sleep 5
- name: 5sec job 2
run: |
# simulate a job
sleep 5
- name: 5sec job 3
run: |
# simulate a job
sleep 5
- name: 10sec job
run: |
# simulate a job
sleep 10
- name: 15sec job
run: |
# simulate a job
sleep 15
- name: 30sec job 1
run: |
# simulate a job
sleep 30
- name: 30sec job 2
run: |
# simulate a job
sleep 30
Its a quite simple action simulating some longer test process. I have the following observations:
- When pushing to the same branch multiple times the run triggered by the push before is canceled by the new push. (As i would like it with runs triggered by pull_request: synchronized)
- When pushing onto a branch with an open pull request a new run is created because of pull_request: synchronized). Pushing again while the last run is still running, the old and new run are both active. None is cancelled.
Currently we work with the newest stable release gitea 1.24.7. My act_runner runs on v0.2.13 (also newest stable).
This somehow decides the whole integration process of our testing, since test time add up if people push to pull reuqests multiple times and runs are not aborted.
I looked at the code of gitea 1.24.7 and in notify_helper.go there is some code regarding this:
if run.Event == webhook_module.HookEventPush ||
run.Event == webhook_module.HookEventPullRequestSync
{
if err := CancelPreviousJobs(
ctx,
run.RepoID,
run.Ref,
run.WorkflowID,
run.Event,
); err != nil {
log.Error("CancelPreviousJobs: %v", err)
}
}
But I cannot figure out what is not configured in the right way.
Is there any solution that runs get cancelled when pushed to a branch on the same pull request?