Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: 🎭 E2E

on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
NODE_VERSION: "lts/*"

jobs:
discover:
name: 🔍 Discover E2E Suites
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
suites: ${{ steps.find.outputs.suites }}
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0

# Every tests/e2e/<area>/<sample>-e2e/ folder with a playwright.config.ts is a web suite for
# <area>/<sample>. On a pull request, a suite runs only when its sample, the suite itself,
# or what every suite shares changed. A manual run takes every suite.
- name: 🔍 Find Changed Suites
id: find
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
EVENT: ${{ github.event_name }}
run: |
if [ "$EVENT" = "pull_request" ]; then
changed=$(git diff --name-only "$BASE_SHA"...HEAD)
else
changed=""
fi
shared_changed=false
if [ "$EVENT" != "pull_request" ] || grep -qE '^(tests/e2e/(shared/|package(-lock)?\.json$|tsconfig\.json$)|\.github/workflows/e2e\.yml$)' <<<"$changed"; then
shared_changed=true
fi

suites=()
for config in tests/e2e/*/*-e2e/playwright.config.ts; do
suite=$(dirname "$config")
# A suite whose sample needs more than the latest ThunderID release offers carries a
# ci-skip file that says why. It still runs locally against a server that supports it.
if [ -f "$suite/ci-skip" ]; then
echo "Skipping ${suite#tests/e2e/}: $(head -n 1 "$suite/ci-skip")"
continue
fi
sample=${suite#tests/e2e/}
sample=${sample%-e2e}
if $shared_changed || grep -qE "^(${sample}|${suite})/" <<<"$changed"; then
suites+=("${suite#tests/e2e/}")
fi
done

json=$(printf '%s\n' ${suites[@]+"${suites[@]}"} | jq -R 'select(length > 0)' | jq -cs .)
echo "suites=$json" >> "$GITHUB_OUTPUT"
echo "E2E suites to run: $json"

e2e:
name: 🎭 E2E (${{ matrix.suite }})
needs: discover
if: ${{ needs.discover.outputs.suites != '[]' }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
suite: ${{ fromJson(needs.discover.outputs.suites) }}
defaults:
run:
working-directory: tests/e2e
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- name: ⚙️ Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: tests/e2e/package-lock.json

# Downloads the latest ThunderID release, runs its setup and starts it, the same way locally
# and in CI. The token only lifts the GitHub API rate limit for the latest-release lookup.
- name: 🚀 Start ThunderID (Latest Release)
env:
GITHUB_TOKEN: ${{ github.token }}
run: ./shared/scripts/thunderid.sh start

- name: 📦 Install Dependencies
run: npm ci --no-audit --no-fund

- name: 📦 Install Playwright Browsers
run: npx playwright install --with-deps chromium

# The suite's global setup imports what the sample needs and creates the test users, and
# Playwright starts the sample itself, installing it from its own lockfile.
- name: 🎭 Run E2E Suite
run: npm test -w "${{ matrix.suite }}"

- name: 📤 Upload Playwright Report
if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: playwright-report-${{ strategy.job-index }}
path: |
tests/e2e/${{ matrix.suite }}/playwright-report/
tests/e2e/${{ matrix.suite }}/test-results/
tests/e2e/.thunderid-server/server.log
retention-days: 14

- name: 🛑 Stop ThunderID
if: ${{ always() }}
run: ./shared/scripts/thunderid.sh stop || true
26 changes: 25 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ on a pull request.

- Put it under the area it belongs to and give it a `README.md` that follows the structure
below. Follow the sample-banner skill to render its banner.
- Depend on the published SDK release, never a workspace or local path.
- Depend on the latest published SDK release, never a workspace or local path. See
[SDK versions](#sdk-versions).
- Add a row to its area's table under `## Samples` in the root `README.md`, in alphabetical
order. A new area gets its own `### <Area>` heading, a one-line description, and a
table, in the same order as the Layout table above, and a row in that Layout table.
Expand Down Expand Up @@ -92,6 +93,29 @@ for a mobile app) and adapt it rather than starting from scratch.
Write in plain, direct sentences. Link only to pages that exist; check thunderid.dev links
before adding them.

## SDK versions

Every sample uses the latest release of its ThunderID SDK, so a developer who copies one gets
the current SDK and the code that goes with it.

- **npm:** depend on each `@thunderid/*` package, including `@thunderid/eslint-plugin` and
`@thunderid/prettier-config`, as `"latest"`, never an exact or ranged version. The committed
`package-lock.json` records the release it resolved.
- **Swift Package Manager:** `.package(url: "https://github.com/thunder-id/ios-sdks", from: "<latest release>")`.
- **pub:** `thunderid_flutter: ^<latest release>`.
- **Gradle:** JitPack has no `latest` alias, so use the latest release tag:
`com.github.thunder-id:android-sdks:v<latest release>`.

After an SDK release, move every sample that uses it to that release in one pull request. npm
keeps a locked version that already satisfies `"latest"`, so `npm install` alone does not move
it. In each sample, run `npm install <package>@latest` for each `@thunderid/*` package, set the
dependency back to `"latest"`, and run `npm install` again, then run the sample's format check,
lint and build.

Samples carry no compatibility with older SDK releases: no fallback settings, aliased
environment variables, or notes for earlier versions. When a release changes what a sample
needs, change the sample.

## Package manager

JavaScript samples use npm, so that a developer who copies one out needs nothing beyond Node.js.
Expand Down
4 changes: 2 additions & 2 deletions b2b/wayfinder-enterprise-nextjs/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ NEXT_PUBLIC_THUNDERID_AFTER_SIGN_IN_URL=http://localhost:3000
NEXT_PUBLIC_THUNDERID_AFTER_SIGN_OUT_URL=http://localhost:3000
NEXT_PUBLIC_THUNDERID_SCOPES=openid profile email roles ou booking:view booking:create booking:manage policy:view policy:manage user:view user:manage group:view group:manage role:view role:manage sso:view sso:manage

# Encrypts the session cookie. Generate it with `openssl rand -base64 32`.
THUNDERID_SECRET=
# Encrypts the session cookie. At least 32 bytes; generate it with `openssl rand -base64 32`.
THUNDERID_SESSION_SECRET=

# Where the app runs. The admin components reach the backend routes under /api/admin from here.
WAYFINDER_APP_URL=http://localhost:3000
Expand Down
4 changes: 2 additions & 2 deletions b2b/wayfinder-enterprise-nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Create your `.env.local`:
cp .env.example .env.local
```

The other defaults match the import. In `.env.local`, set `THUNDERID_CLIENT_SECRET` and `WAYFINDER_BACKEND_CLIENT_SECRET` to the client secrets you set in `thunderid.env`, and `THUNDERID_SECRET` to a long random string; the SDK encrypts the session cookie with it. Generate one with:
The other defaults match the import. In `.env.local`, set `THUNDERID_CLIENT_SECRET` and `WAYFINDER_BACKEND_CLIENT_SECRET` to the client secrets you set in `thunderid.env`, and `THUNDERID_SESSION_SECRET` to a random value of at least 32 bytes; the SDK encrypts the session cookie with it. Generate one with:

```bash
openssl rand -base64 32
Expand All @@ -104,7 +104,7 @@ openssl rand -base64 32
| `NEXT_PUBLIC_THUNDERID_APPLICATION_ID` | ID of the `Wayfinder Enterprise` application |
| `NEXT_PUBLIC_THUNDERID_AFTER_SIGN_IN_URL`, `NEXT_PUBLIC_THUNDERID_AFTER_SIGN_OUT_URL` | Where ThunderID returns the browser after sign-in and sign-out |
| `NEXT_PUBLIC_THUNDERID_SCOPES` | Scopes the app asks for: the organization and role claims, and the Wayfinder permissions |
| `THUNDERID_SECRET` | Encrypts the session cookie |
| `THUNDERID_SESSION_SECRET` | Encrypts the session cookie. At least 32 bytes, which production requires. |
| `WAYFINDER_APP_URL` | Where the app runs. The admin components reach the backend routes under `/api/admin` from here. |
| `WAYFINDER_API_RESOURCE` | The resource server whose permissions the app requests |
| `WAYFINDER_SIGN_IN_FLOW_ID`, `WAYFINDER_ADMIN_ROLE_ID`, `WAYFINDER_MEMBER_ROLE_ID`, `WAYFINDER_ADMIN_ROLE_NAME`, `WAYFINDER_USER_TYPE` | Resources the import creates with fixed IDs |
Expand Down
Loading
Loading