Skip to content

Commit

Permalink
Merge pull request #11183 from wellcomecollection/remove-e2e-tests-no…
Browse files Browse the repository at this point in the history
…t-required-label

Remove e2e tests not required label
  • Loading branch information
agnesgaroux authored Sep 18, 2024
2 parents bf85de8 + 8df4441 commit b4e0a2d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 159 deletions.
31 changes: 4 additions & 27 deletions .buildkite/e2e_on_pull_requests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,17 @@ It's moderately fiddly, so this README tries to outline the broad approach.

## What it looks like for devs

At the end of a "build + test" job, devs get asked whether they want to run end-to-end tests:
At the end of a "build + test" job on a branch other than `main`, devs get asked whether they want to run end-to-end tests:

<img src="e2e_dev_picker.png">

If you select **Yes, run e2e tests now**, Buildkite will start running the end-to-end tests as part of the same "build + test" job.
If you select **Yes, run e2e tests now**, we use `buildkite-agent pipeline upload` to dynamically add more steps to the pipeline. Buildkite will start running these end-to-end tests steps as part of the same "build + test" job.
See [additional steps](pipeline.e2e-pull-requests.yml) for more details.

If you select **Not now, maybe later**, Buildkite will complete the current build, but ask you again when you push new commits.
This is useful if you know your PR is a draft or work-in-progress, and it's not worth running e2e tests yet.
This is useful if you know your PR is a draft or work-in-progress, and it's not worth running e2e tests yet.

If you select **No, not needed for this PR**, Buildkite will complete the current build, and won't ask you again when you push new commits.
Instead, it adds the `e2es not required` label to your PR.
If you want to re-run e2es later, remove this label.

## How it works

This is the rough flow:

```mermaid
flowchart TD
B["Buildkite runs tests on PR<br>(see pipeline.yml)"]
B --> HL{is there a<br>'skip e2e tests'<br>label?}
HL -->|yes| X[nothing to do,<br/>build completes]
HL -->|no| ASK{ask the user<br/>if they want<br/>to run e2es<br/>on this PR}
ASK -->|yes, now| Y["run e2e tests"]
ASK -->|no, maybe later| ML[nothing to do,<br/>build completes]
ASK -->|no, not needed| N[add the 'skip e2e tests' label<br/>in GitHub, build completes]
```

At both the choice steps, we're using `buildkite-agent pipeline upload` to dynamically add more steps to the pipeline.
See the individual scripts/YAML files for more explanatory comments.

## Implementation notes

* We use GitHub labels to track when a dev has declined to run e2es, because they're easily visible and use an interface we're already familiar with.

* We only turn on the e2e cluster when we're running tests, to reduce costs.
96 changes: 0 additions & 96 deletions .buildkite/e2e_on_pull_requests/check_if_we_need_to_ask.sh

This file was deleted.

Binary file modified .buildkite/e2e_on_pull_requests/e2e_dev_picker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

24 changes: 21 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,28 @@
#
# It doesn't run on main, because we run e2es on main by deploying
# into our stage/prod environments instead.
- label: 'check if we need to run e2es'
command: .buildkite/e2e_on_pull_requests/check_if_we_need_to_ask.sh
if: build.branch != "main"

- wait

- input: "Run end-to-end tests on this pull request?"
if: build.branch != "main"
key: "ask-user-if-should-run-e2es"
fields:
- select: "Run e2es?"
key: "should-run-e2es"
options:
- label: "Yes, run e2e tests now"
value: "yes"
- label: "Not now, maybe later"
value: "maybe-later"

- label: "Add steps for e2e tests (if necessary)"
depends_on: "ask-user-if-should-run-e2es"
command: |
if [[ "$$(buildkite-agent meta-data get should-run-e2es)" == "yes" ]]; then
buildkite-agent pipeline upload .buildkite/e2e_on_pull_requests/pipeline.e2e-pull-requests.yml
fi
agents:
queue: nano

Expand Down

0 comments on commit b4e0a2d

Please sign in to comment.