Skip to content

ci(repo): add e2e-staging workflow for clerk_go deploy validation#8051

Merged
jacekradko merged 8 commits intomainfrom
jacek/e2e-staging-workflow
Mar 12, 2026
Merged

ci(repo): add e2e-staging workflow for clerk_go deploy validation#8051
jacekradko merged 8 commits intomainfrom
jacek/e2e-staging-workflow

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Mar 12, 2026

Summary

  • Adds a new standalone GitHub Actions workflow (e2e-staging.yml) that runs JS SDK e2e tests against the staging environment
  • Triggered via repository_dispatch (for clerk_go staging deploy automation) and workflow_dispatch (for manual runs/debugging)
  • Supports configurable ref (default: main), clerk_go commit SHA for traceability, and Slack failure notifications
  • SDK source toggle: latest (default) uses published @latest from npm for production-like testing; ref builds from the checked-out branch for SDK change validation
  • Runs sessions:staging and handshake:staging test matrix — designed to be easily expanded as more staging instances are provisioned
  • Reports failures via Slack using slackapi/slack-github-action with Block Kit payload (matches ci(repo): add Slack failure notifications to release workflow #8023 pattern)
  • clerk_go commit status callback is wired but commented out, pending Part 2 design for the clerk_go dispatch side

Test plan

  • Trigger via workflow_dispatch from GitHub Actions UI with default inputs (sdk-source: latest)
  • Trigger with sdk-source: ref and verify it builds from the branch
  • Verify both staging test matrix entries run (sessions:staging, handshake:staging)
  • Verify Playwright trace artifacts upload on failure
  • Verify concurrency cancellation with back-to-back triggers
  • Verify workflow_dispatch with a non-main ref

Summary by CodeRabbit

  • Chores
    • Added a new, configurable end-to-end staging workflow to run integration tests against staging environments, support build-from-source or latest package installs, validate refs, and upload test results.
    • Added a changeset placeholder to track the change for releases and enable downstream automation.
    • Integrated optional Slack reporting for test failures and run summaries.

@vercel
Copy link

vercel bot commented Mar 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Mar 12, 2026 7:54pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

🦋 Changeset detected

Latest commit: 301e259

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds a new GitHub Actions workflow at .github/workflows/e2e-staging.yml triggered by repository_dispatch (staging-deploy) and workflow_dispatch. Introduces an integration-tests job with a matrix over test-name and test-project, input normalization for both event types, ref validation (only main or release/*), repository checkout, runtime/init steps, conditional SDK build-and-publish to a local registry or npm install depending on sdk-source, .npmrc configuration, certificate provisioning from secrets, Turbo-based test execution, and artifact upload on cancel/failure. Adds a report job that sends Slack notifications on failures. Also adds .changeset/floppy-rabbits-tease.md.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding a GitHub Actions workflow (e2e-staging.yml) for end-to-end staging validation. It is concise, specific, and directly reflects the primary changeset content.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 12, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8051

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8051

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8051

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8051

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8051

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8051

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8051

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8051

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8051

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8051

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8051

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8051

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8051

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8051

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8051

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8051

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8051

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8051

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8051

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8051

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8051

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8051

commit: 301e259

@jacekradko jacekradko changed the base branch from main to jacek/release-slack-notifications March 12, 2026 19:19
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/e2e-staging.yml:
- Around line 49-61: Duplicate shell normalization logic in the "Normalize
inputs" step (id: inputs) — which sets ref, clerk-go-commit-sha and notify-slack
via $GITHUB_OUTPUT — should be centralized: extract that logic into a single
reusable unit (either a tiny composite action or a dedicated preparatory job
that emits outputs) and replace both copies with calls to that unit; ensure the
composite/job writes the same outputs (ref, clerk-go-commit-sha, notify-slack)
to $GITHUB_OUTPUT and update callers to read the outputs instead of duplicating
the shell branch.
- Around line 121-123: Remove the console.log that prints the secret by
eliminating the console.log('rootCa', rootCa) call and keep writing the
INTEGRATION_ROOT_CA to disk via
fs.writeFileSync(path.join(process.env.GITHUB_WORKSPACE, 'integration/certs',
'rootCA.pem'), rootCa);; also add a simple guard to avoid writing undefined
(check process.env.INTEGRATION_ROOT_CA or rootCa and throw or fail the job with
a clear non-secret error) so the secret is never emitted to logs while still
creating the file.
- Around line 23-25: The workflow currently passes a caller-controlled ref into
actions/checkout while granting actions: write and exposing
TURBO_REMOTE_CACHE_SIGNATURE_KEY and TURBO_TOKEN, which lets a malicious ref run
local actions with staging creds; fix this by restricting the ref input to a
safe allowlist of known branches before checkout (validate
github.event.inputs.ref against a whitelist and only call actions/checkout when
it matches) and remove/limit the broad actions: write permission (or scope it
down) so the checkout cannot run unreviewed code with write-scoped GITHUB_TOKEN;
references to update: the actions/checkout usage, the ref input validation, and
the permissions block and the secrets
TURBO_REMOTE_CACHE_SIGNATURE_KEY/TURBO_TOKEN.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: c042fe0d-9761-4e5b-accc-9f695e61b9d0

📥 Commits

Reviewing files that changed from the base of the PR and between 296f52e and fa36213.

📒 Files selected for processing (1)
  • .github/workflows/e2e-staging.yml

Comment on lines +49 to +61
- name: Normalize inputs
id: inputs
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "ref=${{ github.event.inputs.ref || 'main' }}" >> $GITHUB_OUTPUT
echo "clerk-go-commit-sha=${{ github.event.inputs.clerk-go-commit-sha }}" >> $GITHUB_OUTPUT
echo "notify-slack=${{ github.event.inputs.notify-slack }}" >> $GITHUB_OUTPUT
else
echo "ref=${{ github.event.client_payload.ref || 'main' }}" >> $GITHUB_OUTPUT
echo "clerk-go-commit-sha=${{ github.event.client_payload.clerk-go-commit-sha || '' }}" >> $GITHUB_OUTPUT
NOTIFY_SLACK="${{ github.event.client_payload.notify-slack }}"
echo "notify-slack=${NOTIFY_SLACK:-true}" >> $GITHUB_OUTPUT
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Deduplicate the input normalization block.

The same shell branch appears in both jobs. Any future payload/input change now has two drift points; consider emitting these values once as job outputs or moving the logic into a tiny composite action.

Also applies to: 161-173

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/e2e-staging.yml around lines 49 - 61, Duplicate shell
normalization logic in the "Normalize inputs" step (id: inputs) — which sets
ref, clerk-go-commit-sha and notify-slack via $GITHUB_OUTPUT — should be
centralized: extract that logic into a single reusable unit (either a tiny
composite action or a dedicated preparatory job that emits outputs) and replace
both copies with calls to that unit; ensure the composite/job writes the same
outputs (ref, clerk-go-commit-sha, notify-slack) to $GITHUB_OUTPUT and update
callers to read the outputs instead of duplicating the shell branch.

@jacekradko jacekradko changed the base branch from jacek/release-slack-notifications to main March 12, 2026 19:24
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/e2e-staging.yml:
- Around line 57-70: In the "Normalize inputs" step validate the sdk-source
value from both workflow_dispatch and repository_dispatch paths before echoing
it to $GITHUB_OUTPUT: read the candidate into a local variable (e.g.,
SDK_SOURCE) from github.event.inputs.sdk-source or
github.event.client_payload.sdk-source, then if SDK_SOURCE is not empty and not
equal to "latest" or "ref" print an error and exit non‑zero (rejecting the run);
otherwise echo "sdk-source=${SDK_SOURCE:-latest}" to $GITHUB_OUTPUT—apply this
logic in the existing branches so invalid payloads are rejected before writing
sdk-source.
- Around line 51-53: The artifact name fails because the matrix key test-name
contains colons (values "sessions:staging" and "handshake:staging") which are
interpolated into the artifact name used by actions/upload-artifact@v4; update
the matrix to include a separate slug-safe field (e.g., test-slug) or transform
matrix.test-name to a slug (replace ":" with "-" or remove illegal chars) and
use that slug for the artifact name, while keeping matrix.test-name for
human-readable display; locate usages of matrix.test-name in the workflow (the
artifact upload step) and switch them to the new slug field (or the sanitized
value) so the artifact name contains no colons.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7ddc83f9-6aa6-484f-b578-4f13ffddf5d2

📥 Commits

Reviewing files that changed from the base of the PR and between fa36213 and b7d2a7c.

📒 Files selected for processing (2)
  • .changeset/floppy-rabbits-tease.md
  • .github/workflows/e2e-staging.yml

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (3)
.github/workflows/e2e-staging.yml (3)

31-33: ⚠️ Potential issue | 🟠 Major

Drop the unused actions: write scope.

None of the live steps appear to write to the Actions API, so this staging workflow is granting a write-scoped GITHUB_TOKEN without a current need. The commented clerk_go callback uses CLERK_COOKIE_PAT, not this token.

🔐 Tighten the default token scope
 permissions:
   contents: read
-  actions: write
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/e2e-staging.yml around lines 31 - 33, The workflow
permissions block grants an unnecessary write-scoped GITHUB_TOKEN via the
"actions: write" entry; remove the "actions: write" line (leaving "contents:
read") so the default token is least-privilege, and verify no job references
require Actions write access (ensure callbacks like the commented clerk_go use
CLERK_COOKIE_PAT instead of GITHUB_TOKEN).

51-54: ⚠️ Potential issue | 🟠 Major

Use a slug-safe artifact name.

matrix.test-name contains sessions:staging / handshake:staging, and actions/upload-artifact@v4 rejects : in with.name. The trace upload will fail exactly when you need it most.

📦 Keep the human-readable test name separate from the artifact slug
     strategy:
       fail-fast: false
       matrix:
-        test-name:
-          - "sessions:staging"
-          - "handshake:staging"
-        test-project: ["chrome"]
+        include:
+          - test-name: "sessions:staging"
+            artifact-name: "sessions-staging"
+            test-project: "chrome"
+          - test-name: "handshake:staging"
+            artifact-name: "handshake-staging"
+            test-project: "chrome"
@@
       - name: Upload test-results
         if: ${{ cancelled() || failure() }}
         uses: actions/upload-artifact@v4
         with:
-          name: playwright-traces-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.test-name }}
+          name: playwright-traces-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.artifact-name }}
           path: integration/test-results
           retention-days: 1

Also applies to: 197-201

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/e2e-staging.yml around lines 51 - 54, matrix.test-name
contains colons (e.g., "sessions:staging", "handshake:staging") which are
rejected by actions/upload-artifact@v4; fix by adding a slug-safe artifact name
(either a new matrix variable like test-slug or sanitize matrix.test-name) and
use that sanitized value in the upload step's with.name. Locate references to
matrix.test-name in the workflow (the matrix declaration entries
"sessions:staging"/"handshake:staging" and the upload-artifact step that uses
with.name), replace or map them to a version with forbidden characters replaced
(e.g., replace ":" with "-" or use github.actions/hash/format) and ensure the
same change is applied where the trace upload occurs (also update the other
matrix block referenced).

57-80: ⚠️ Potential issue | 🟠 Major

Reject unexpected sdk-source values before exporting them.

workflow_dispatch constrains this input, but repository_dispatch does not. Any non-empty value other than latest or ref skips both source-selection branches and turns into a later, harder-to-diagnose failure.

🧪 Validate once before writing `sdk-source`
         run: |
           if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
+            SDK_SOURCE="${INPUT_SDK_SOURCE:-latest}"
             echo "ref=${INPUT_REF:-main}" >> $GITHUB_OUTPUT
             echo "clerk-go-commit-sha=$INPUT_COMMIT_SHA" >> $GITHUB_OUTPUT
             echo "notify-slack=$INPUT_NOTIFY_SLACK" >> $GITHUB_OUTPUT
-            echo "sdk-source=${INPUT_SDK_SOURCE:-latest}" >> $GITHUB_OUTPUT
           else
+            SDK_SOURCE="${PAYLOAD_SDK_SOURCE:-latest}"
             echo "ref=${PAYLOAD_REF:-main}" >> $GITHUB_OUTPUT
             echo "clerk-go-commit-sha=${PAYLOAD_COMMIT_SHA:-}" >> $GITHUB_OUTPUT
             echo "notify-slack=${PAYLOAD_NOTIFY_SLACK:-true}" >> $GITHUB_OUTPUT
-            echo "sdk-source=${PAYLOAD_SDK_SOURCE:-latest}" >> $GITHUB_OUTPUT
           fi
+
+          case "$SDK_SOURCE" in
+            latest|ref) ;;
+            *)
+              echo "::error::Unsupported sdk-source '$SDK_SOURCE'. Expected 'latest' or 'ref'."
+              exit 1
+              ;;
+          esac
+
+          echo "sdk-source=$SDK_SOURCE" >> "$GITHUB_OUTPUT"

Also applies to: 215-238

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/e2e-staging.yml around lines 57 - 80, In the "Normalize
inputs" step, validate INPUT_SDK_SOURCE and PAYLOAD_SDK_SOURCE before echoing
"sdk-source": ensure the selected value is empty or one of the allowed values
("latest" or "ref"); if it is any other non-empty string, print a clear error
and exit non-zero to fail the job instead of exporting an unexpected value.
Update the branch handling that writes "sdk-source=${INPUT_SDK_SOURCE:-latest}"
and "sdk-source=${PAYLOAD_SDK_SOURCE:-latest}" to perform this validation first
(using the INPUT_SDK_SOURCE / PAYLOAD_SDK_SOURCE variables) and apply the same
validation logic to the other identical block referenced (lines 215-238) so both
places reject invalid sdk-source values consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/e2e-staging.yml:
- Around line 31-33: The workflow permissions block grants an unnecessary
write-scoped GITHUB_TOKEN via the "actions: write" entry; remove the "actions:
write" line (leaving "contents: read") so the default token is least-privilege,
and verify no job references require Actions write access (ensure callbacks like
the commented clerk_go use CLERK_COOKIE_PAT instead of GITHUB_TOKEN).
- Around line 51-54: matrix.test-name contains colons (e.g., "sessions:staging",
"handshake:staging") which are rejected by actions/upload-artifact@v4; fix by
adding a slug-safe artifact name (either a new matrix variable like test-slug or
sanitize matrix.test-name) and use that sanitized value in the upload step's
with.name. Locate references to matrix.test-name in the workflow (the matrix
declaration entries "sessions:staging"/"handshake:staging" and the
upload-artifact step that uses with.name), replace or map them to a version with
forbidden characters replaced (e.g., replace ":" with "-" or use
github.actions/hash/format) and ensure the same change is applied where the
trace upload occurs (also update the other matrix block referenced).
- Around line 57-80: In the "Normalize inputs" step, validate INPUT_SDK_SOURCE
and PAYLOAD_SDK_SOURCE before echoing "sdk-source": ensure the selected value is
empty or one of the allowed values ("latest" or "ref"); if it is any other
non-empty string, print a clear error and exit non-zero to fail the job instead
of exporting an unexpected value. Update the branch handling that writes
"sdk-source=${INPUT_SDK_SOURCE:-latest}" and
"sdk-source=${PAYLOAD_SDK_SOURCE:-latest}" to perform this validation first
(using the INPUT_SDK_SOURCE / PAYLOAD_SDK_SOURCE variables) and apply the same
validation logic to the other identical block referenced (lines 215-238) so both
places reject invalid sdk-source values consistently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 73b127eb-649f-4ef3-86e1-8f27e2cf389e

📥 Commits

Reviewing files that changed from the base of the PR and between b7d2a7c and fa5c11d.

📒 Files selected for processing (1)
  • .github/workflows/e2e-staging.yml

@jacekradko jacekradko merged commit 1686123 into main Mar 12, 2026
41 checks passed
@jacekradko jacekradko deleted the jacek/e2e-staging-workflow branch March 12, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants