Skip to content

Start only the matching e2e suite when its label is added - #837

Open
wallrj-cyberark wants to merge 1 commit into
masterfrom
e2e-label-trigger
Open

Start only the matching e2e suite when its label is added#837
wallrj-cyberark wants to merge 1 commit into
masterfrom
e2e-label-trigger

Conversation

@wallrj-cyberark

@wallrj-cyberark wallrj-cyberark commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Adding the test-e2e, test-ark or test-ngts label to an open pull request does not start a run. This makes it start one — and only the suite you asked for.

Why now?

I hit this on #835. I added the test-e2e label, nothing happened, and I had to force-push to fire a synchronize before the e2e would start. It looks exactly like a broken job.

The cause is that tests.yaml uses on: pull_request: {}, which takes the default activity types.

By default, a workflow only runs when a pull_request event's activity type is opened, synchronize, or reopened.

Events that trigger workflows

labeled is not in that list, so the label sits there and no run starts. Re-running does not help either, because a re-run replays the original event payload, which had no labels.

So the label route documented in #833 has always needed a push afterwards. #833 gave us a reliable manual route with workflow_dispatch, which covers the release case. This fixes the pull request case.

What changes

labeled is added to the activity types, and each job then decides what a label event means for it:

  • verify and test skip on a label event. A label says nothing about the code, so there is nothing new to verify.
  • Each e2e job runs only if github.event.label.name — the single label that was just added — is its own label. Adding test-ngts does not start the ark or GKE suites.

github.event.action is null on push and on workflow_dispatch, so both guards only ever exclude the label event.

Nothing else changes. Push, workflow_dispatch and opened/synchronize/reopened behave exactly as they do today, so an e2e suite whose label is already on the pull request still re-runs on every new commit.

The one unavoidable wrinkle: GitHub cannot filter the trigger by label name, so adding an unrelated label still creates a workflow run. Every job in it skips, and a skipped job never claims a runner, so it costs nothing but a line in the Actions list.

Full behaviour table — every event this workflow subscribes to
Event Jobs that run
push to master verify, test
workflow_dispatch everything
PR opened, no labels verify, test
PR opened, has test-e2e verify, test, test-e2e
PR synchronize, has test-e2e verify, test, test-e2e
PR synchronize, has all three everything
label kind/cleanup added nothing
label test-e2e added test-e2e only
label test-ark added ark-test-e2e only
label test-ngts added, test-e2e already on ngts-test-e2e only
label keep-e2e-cluster added, test-e2e already on nothing

That last row is the one behaviour change worth knowing: add keep-e2e-cluster before test-e2e, not after. Adding it afterwards starts nothing, because it matches no job. Added first, it is already in github.event.pull_request.labels when the test-e2e run starts, so the cleanup step still sees it and keeps the cluster.

Verified on this pull request: a matching label starts one job, an unrelated label starts none

For pull_request events GitHub reads the trigger configuration from the merge commit, so this pull request tests its own change. Evidence is in the comments below, since run IDs only exist once the pull request is open.

What this does not fix
  • e2e still never runs automatically on master, on merge or on a schedule. A green master therefore still does not mean the e2e suites passed.
  • ark-test-e2e still carries its TEMPORARY comment about a recurring 400 "conflicting tagging values" error. Whether that flake is still real is unanswered, and it is the thing blocking a nightly run.

Both are tracked separately.

@wallrj-cyberark wallrj-cyberark added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Sep 10, 2026
@wallrj-cyberark

wallrj-cyberark commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Superseded. This describes the first revision, where adding any label also re-ran verify and test. That was needless and has been changed: a label event now starts only the e2e suite named by that label. See the current evidence. Kept for history.


Verified: the label alone started a run

Adding a label to this pull request started a second workflow run, with no push. That is the behaviour that does not happen on master today.

Run 1 Run 2
Trigger pull request opened label added
Run 34473375778 34473438702
Created 11:49:57Z 11:50:38Z
Head SHA c83c994 c83c994
Result success success

The two runs share the same head SHA, so no commit was pushed between them. Run 2 was created three seconds after I added kind/cleanup at 11:50:35Z. Nothing else could have created it.

I used kind/cleanup rather than an e2e label deliberately, so all three e2e jobs still skipped and no GKE cluster was created. Both runs show verify and test succeeding and ark-test-e2e, ngts-test-e2e and test-e2e skipped, which is correct for a pull request carrying none of the e2e labels.

What this run does not prove

It shows the labeled activity type now triggers the workflow. It does not separately re-prove that the if: gates read the new label, because kind/cleanup is not one of them. That part is unchanged by this pull request: the gates already read github.event.pull_request.labels successfully today, they were just never reached on a label event.

If you would rather see it end to end before merging, say so and I will add test-e2e here, which will run the full GKE suite.

Adding test-e2e, test-ark or test-ngts to an open pull request currently
does nothing. The workflow uses `on: pull_request: {}`, which takes the
default activity types of opened, synchronize and reopened. There is no
`labeled`, so the label sits on the pull request and no run starts.

Re-running the workflow does not help either, because a re-run replays
the original event payload, which had no labels. The only way through is
to close and reopen the pull request, or push a commit. The failure mode
is silent, so it looks like the job is broken.

Add `labeled` to the activity types, and make each job decide what a
label event means for it:

  - verify and test skip, because a label says nothing about the code.
  - each e2e job runs only when github.event.label.name, the single
    label that was just added, is its own label.

github.event.action is null on push and on workflow_dispatch, so both
guards only ever exclude the label event. Behaviour on push, on
workflow_dispatch and on opened/synchronize/reopened is unchanged, so an
e2e suite whose label is already on the pull request still re-runs on
every new commit.

The trigger itself cannot be filtered by label name, so adding an
unrelated label still creates a workflow run. Every job in it skips, and
a skipped job never claims a runner.

One ordering note: add keep-e2e-cluster before test-e2e, not after.
Adding it afterwards starts nothing, because it matches no job.

Signed-off-by: Richard Wall <richard.wall@cyberark.com>
@wallrj-cyberark wallrj-cyberark changed the title Make the e2e labels actually start a run when added Start only the matching e2e suite when its label is added Sep 10, 2026
@wallrj-cyberark wallrj-cyberark added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. test-ngts and removed kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. test-ngts labels Sep 10, 2026
@wallrj-cyberark

Copy link
Copy Markdown
Contributor Author

Verified on this pull request

Revised after review feedback: an unrelated label used to re-run verify and test, which was needless. Now a label event starts only the suite named by that label. All four runs below are on this pull request.

# What I did Run Jobs that ran
1 Force-pushed (synchronize) 34487851234 — success verify, test. Three e2e jobs skipped
2 Added kind/cleanup, no push 34488035695skipped none. All five jobs skipped
3 Added test-ngts, no push 34488147664 — cancelled by me ngts-test-e2e only. verify, test, ark-test-e2e, test-e2e all skipped
4 Removed a label no run unlabeled is not subscribed

Run 1 is the no-regression check: ordinary pushes still behave exactly as before.

Run 2 is the fix you asked for. The direct before/after is on the same pull request and the same action — adding kind/cleanup. Under the previous revision that produced 34473438702, where verify and test both ran to success. Now the whole run reports skipped and no runner is claimed.

Run 3 is the positive half, and the only real proof that github.event.label.name is populated on a labeled event — the GitHub webhook docs do not spell out the per-action payload fields, so I tested it rather than trusting it. Note test-e2e skipped even though ngts-test-e2e ran, which is the "only the matching suite" property.

I cancelled run 3 about 45 seconds in, once the job selection was visible, to avoid a full 30-minute QA run nobody asked for. It had reached the first seconds of make -j ngts-test-e2e; setup steps had completed and no test result was produced. I then removed the test-ngts label so later pushes here do not start the NGTS suite.

One behaviour change to know about

Add keep-e2e-cluster before test-e2e, not after. Adding it afterwards now starts nothing, because it matches no job. Added first, it is already in github.event.pull_request.labels when the test-e2e run starts, so the cleanup step still sees it and keeps the cluster.

Not covered by these runs

No GKE cluster was created at any point, so the test-e2e job and its cleanup step are unexercised here. Its gate is the same expression as the other two, and run 3 shows that expression correctly skipping it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant