Skip to content

Commit 638bb47

Browse files
authored
Merge pull request thunder-id#85 from janithjay/e2e-fix
Run E2E on every PR and gate releases on it
2 parents cf93911 + ed4e374 commit 638bb47

5 files changed

Lines changed: 34 additions & 23 deletions

File tree

.github/actions/run-e2e-suite/action.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ runs:
5858
# the THUNDERID_ADMIN_* env vars. It always finishes by trying to attach its interactive
5959
# REPL, which needs a real TTY this runner doesn't have, so it fails; that's expected, and
6060
# by then the release is already downloaded and fully set up on disk, so the exit code is
61-
# ignored. We start it ourselves afterward with `start.sh`, since npx thunderid's own
62-
# (REPL-attached) background process doesn't outlive the npx invocation. This is the first
63-
# thing on this fresh runner to touch the ThunderID CLI's state, so there is no risk of it
64-
# picking up a stale "active version" the way a long-lived dev machine could.
61+
# ignored. npx thunderid already health-checked the server it started before that point, so
62+
# we only start it ourselves with `start.sh` if it isn't actually reachable (e.g. the REPL
63+
# failure tore it down) instead of racing a second instance onto the same port. This is the
64+
# first thing on this fresh runner to touch the ThunderID CLI's state, so there is no risk
65+
# of it picking up a stale "active version" the way a long-lived dev machine could.
6566
run: |
6667
# setsid detaches into a new session with no controlling terminal, so npx thunderid's
6768
# REPL (which opens /dev/tty directly, bypassing stdin redirection) fails to attach
@@ -78,7 +79,7 @@ runs:
7879
echo "dist_home=$DIST_HOME" >> "$GITHUB_OUTPUT"
7980
8081
chmod +x "$DIST_HOME/start.sh"
81-
(cd "$DIST_HOME" && setsid ./start.sh &)
82+
curl -skf https://localhost:8090/health/liveness > /dev/null || (cd "$DIST_HOME" && setsid ./start.sh &)
8283
for i in $(seq 1 60); do
8384
curl -skf https://localhost:8090/health/liveness && exit 0
8485
sleep 2

.github/workflows/e2e-nightly.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: 🌙 E2E Nightly (latest ThunderID)
22

33
# Runs the same E2E suite as pr-builder.yml's `e2e` job, against the same always-latest ThunderID
44
# release. The two differ only in trigger: this one runs on a schedule regardless of PR activity,
5-
# so a ThunderID release that breaks something surfaces even on a day with no relevant PR open —
6-
# the per-PR job (see pr-builder.yml) is label-gated and opt-in, not scheduled.
5+
# so a ThunderID release that breaks something surfaces even on a day with no open PR to catch it.
76

87
on:
98
schedule:

.github/workflows/pr-builder.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 👷🛠️ PR Builder
22

33
on:
44
pull_request:
5-
types: [opened, synchronize, reopened, labeled]
5+
types: [opened, synchronize, reopened]
66
merge_group:
77
workflow_dispatch:
88

@@ -101,12 +101,6 @@ jobs:
101101

102102
e2e:
103103
name: 🎭 E2E (sample apps)
104-
# Label-gated, mirroring thunderid's own pr-builder.yml `trigger-pr-builder` pattern — a real
105-
# backend + six sample apps is expensive enough that it shouldn't run on every push by
106-
# default. Always runs on merge_group/workflow_dispatch.
107-
if: >-
108-
github.event_name != 'pull_request' ||
109-
contains(github.event.pull_request.labels.*.name, 'trigger-e2e')
110104
runs-on: ubuntu-latest
111105
timeout-minutes: 40
112106
# Least privilege: this job never pushes, comments, or writes to the repo — only the default
@@ -117,10 +111,6 @@ jobs:
117111
- name: 📥 Checkout Code
118112
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
119113
with:
120-
# Matches thunder-id/thunderid's own checkout steps: the checked-out repo never needs
121-
# git push/fetch credentials in this job, so don't leave the token available to be
122-
# abused by anything that runs afterward (including the third-party composite actions
123-
# invoked later in this job).
124114
persist-credentials: false
125115

126116
- name: 🎭 Run E2E suite

.github/workflows/release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,29 @@ env:
9595
NODE_VERSION: "lts/*"
9696

9797
jobs:
98+
test-e2e:
99+
name: 🎭 E2E (sample apps)
100+
runs-on: ubuntu-latest
101+
timeout-minutes: 40
102+
# Least privilege: this job never pushes, comments, or writes to the repo — only the default
103+
# GITHUB_TOKEN's read access is needed for checkout.
104+
permissions:
105+
contents: read
106+
steps:
107+
- name: 📥 Checkout Code
108+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
109+
with:
110+
persist-credentials: false
111+
112+
- name: 🎭 Run E2E suite
113+
uses: ./.github/actions/run-e2e-suite
114+
with:
115+
node-version: ${{ env.NODE_VERSION }}
116+
artifact-name: playwright-report-release
117+
98118
validate:
99119
name: ✅ Validate Inputs
120+
needs: [test-e2e]
100121
runs-on: ubuntu-latest
101122
steps:
102123
- name: Guard against accidental major bump

tests/e2e/run-e2e.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ resolve_platform() {
122122
# GitHub API or thunderid.dev calls of our own and no version pinned in this repo, downloads it for
123123
# the current platform, and runs setup.sh non-interactively (admin credentials passed through via
124124
# THUNDERID_ADMIN_* env vars). It always finishes by trying to attach its interactive REPL, which
125-
# needs a real TTY and fails in a script; that is expected, so its exit code is ignored below. By
126-
# the time it fails, the release is already downloaded and fully set up on disk, so we start it
127-
# ourselves with `start.sh` rather than relying on npx thunderid's own (REPL-attached) background
128-
# process, which does not outlive the npx invocation. A scratch HOME is used for that one
125+
# needs a real TTY and fails in a script; that is expected, so its exit code is ignored below. npx
126+
# thunderid already health-checked the server it started before that point, so we only start it
127+
# ourselves with `start.sh` if it isn't actually reachable (e.g. the REPL failure tore it down)
128+
# instead of racing a second instance onto the same port. A scratch HOME is used for that one
129129
# invocation so it can't see, or reuse, a version already active from a developer's own separate
130130
# `npx thunderid` use on this machine, guaranteeing a fresh "no active version" state and therefore
131131
# the true latest release every run.
@@ -183,7 +183,7 @@ download_and_start_server() {
183183
fi
184184

185185
echo "Starting ThunderID server..."
186-
(cd "$DIST_HOME" && ./start.sh) &
186+
curl -sk "https://localhost:${SERVER_PORT}/health/liveness" > /dev/null 2>&1 || (cd "$DIST_HOME" && ./start.sh &)
187187
wait_for_url "https://localhost:${SERVER_PORT}/health/liveness" "ThunderID server"
188188
}
189189

0 commit comments

Comments
 (0)