--- title: "ADR 0100: Closing a pull request cancels only runs from pull request and ops-comment events" --- * Status: accepted * Code: [`pkg/pipelineascode/cancel_pipelineruns.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/pipelineascode/cancel_pipelineruns.go) ## Context When a pull request is closed, the runs of that pull request still in progress are cancelled. They are found by the `URLRepository` and `PullRequest` labels. A pull request is merged and a new push follows on the branch: the push PipelineRun is then assigned the number of the merged pull request, so the pull request label alone also matches runs that do not belong to the pull request. ## Decision * `cancelAllInProgressBelongingToClosedPullRequest` adds `event-type in (pull_request, Merge_Request, <ops comment types>)` to the label selector. Push-triggered runs carrying the pull request number are not cancelled. * The `cancel-in-progress` annotation is applied on top: with the global setting on, runs annotated `false` are excluded; with it off, only runs annotated `true` are selected. ## Consequences * A merge followed by a push cannot cancel the push's own run. * A new event type that should be cancelled on close has to be added to the selector. * The test `do not cancel push-triggered PipelineRuns on PR close` pins this; the cause above comes from that test's removed comment and is not otherwise visible in the code.