Skip to content
Open
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
211 changes: 211 additions & 0 deletions .github/workflows/release-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
name: Release E2E

# Runs the E2E tests on Linux, Windows and macOS against every pull request into a stable line, so a
# release is tested on each system before it ships. The PR workflow runs them on Linux only. The
# remote tests use real Shopify accounts and stores, through the same secrets as that workflow's
# E2E tests.
#
# `edited` covers a pull request retargeted to a stable line. It runs on every edit: skipping the
# gate on the others would record a skipped "Release E2E", which counts as passing and replaces the
# last run.
on:
pull_request:
types: [opened, synchronize, reopened, edited]
branches:
- 'stable/**'
workflow_dispatch:
inputs:
branch-or-tag:
description: 'Branch or tag to test, such as stable/5.2 or 5.2.0'
type: string
required: true

permissions:
contents: read

concurrency:
group: release-e2e-${{ github.event.pull_request.number || inputs.branch-or-tag }}
cancel-in-progress: true

env:
DEBUG: '1'
SHOPIFY_CLI_ENV: development
PNPM_VERSION: '10.11.1'
# `playwright install chromium` hangs under Node 26.
PLAYWRIGHT_NODE_VERSION: '24.22.1'

jobs:
commit:
name: Find the commit to test
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
sha: ${{ steps.commit.outputs.sha }}
steps:
- name: Find the commit
id: commit
env:
EVENT: ${{ github.event_name }}
PULL_REQUEST_SHA: ${{ github.event.pull_request.head.sha }}
BRANCH_OR_TAG: ${{ inputs.branch-or-tag }}
run: |
set -euo pipefail
if [ "$EVENT" = pull_request ]; then
echo "sha=$PULL_REQUEST_SHA" >> "$GITHUB_OUTPUT"
exit 0
fi
# Only a branch or tag of this repository, so a run never tests a fork's commit with this
# repository's secrets. Every system tests the commit it named when the run started.
REFS=$(git ls-remote "https://github.com/$GITHUB_REPOSITORY" "refs/heads/$BRANCH_OR_TAG" "refs/tags/$BRANCH_OR_TAG" "refs/tags/$BRANCH_OR_TAG^{}")
# An annotated tag lists both the tag object and, with ^{}, the commit it points to.
SHA=$(awk '$2 ~ /\^\{\}$/ {peeled = $1} {last = $1} END {print peeled ? peeled : last}' <<< "$REFS")
COUNT=$(awk '$2 !~ /\^\{\}$/' <<< "$REFS" | grep -c . || true)
if [ "$COUNT" -ne 1 ]; then
echo "::error::$BRANCH_OR_TAG must name exactly one branch or tag of $GITHUB_REPOSITORY; it names $COUNT."
exit 1
fi
echo "Testing $BRANCH_OR_TAG at $SHA"
echo "sha=$SHA" >> "$GITHUB_OUTPUT"

e2e:
name: E2E on ${{ matrix.system }} (shard ${{ matrix.shard }})
needs: commit
# Fork pull requests get no secrets. The gate then fails, since a release can't skip these tests.
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ${{ matrix.os }}
# Leave room for setup, the local tests, reports and cleanup around the remote tests' global
# timeout.
timeout-minutes: 50
strategy:
fail-fast: false
matrix:
# App names and the cleanup pattern take their number from E2E_SHARD, so each job has its own
# `leg`: jobs with the same shard on two systems would share it, and one's cleanup could
# delete the other's apps.
# Windows and macOS create apps with npm, the default for new apps. Tests that choose a
# package manager themselves still use pnpm.
# The store lifecycle test runs on Linux only: each run needs a free store slot in the test
# organization.
include:
- {system: Linux, os: ubuntu-latest, shard: 1/2, leg: 1, package-manager: pnpm, skip: ''}
- {system: Linux, os: ubuntu-latest, shard: 2/2, leg: 2, package-manager: pnpm, skip: ''}
- {system: Windows, os: windows-latest, shard: 1/2, leg: 3, package-manager: npm, skip: store-lifecycle}
- {system: Windows, os: windows-latest, shard: 2/2, leg: 4, package-manager: npm, skip: store-lifecycle}
- {system: macOS, os: macos-latest, shard: 1/2, leg: 5, package-manager: npm, skip: store-lifecycle}
- {system: macOS, os: macos-latest, shard: 2/2, leg: 6, package-manager: npm, skip: store-lifecycle}
env:
E2E_ACCOUNT_EMAIL: ${{ secrets.E2E_ACCOUNT_EMAIL }}
E2E_ACCOUNT_PASSWORD: ${{ secrets.E2E_ACCOUNT_PASSWORD }}
E2E_ORG_ID: ${{ secrets.E2E_ORG_ID }}
E2E_LOADTEST_HEADER: ${{ secrets.E2E_LOADTEST_HEADER }}
E2E_SHARD: ${{ matrix.leg }}/6
E2E_PACKAGE_MANAGER: ${{ matrix.package-manager }}
# A failed login fails every test in the job, so a release run retries it longer than the PR
# workflow does.
E2E_AUTH_ATTEMPTS: '4'
E2E_AUTH_RETRY_DELAY_MS: '30000'
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.commit.outputs.sha }}
fetch-depth: 1
persist-credentials: false

- name: Verify the checked-out commit
shell: bash
env:
SHA: ${{ needs.commit.outputs.sha }}
run: |
set -euo pipefail
HEAD_SHA=$(git rev-parse HEAD)
if [ "$HEAD_SHA" != "$SHA" ]; then
echo "::error::Checked out $HEAD_SHA instead of $SHA."
exit 1
fi

- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.PLAYWRIGHT_NODE_VERSION }}

- name: Build
run: pnpm nx run-many --all --target=build --output-style=stream

- name: Install Playwright Chromium
run: pnpm exec playwright install chromium
working-directory: packages/e2e

- name: Rebuild node-pty
run: pnpm rebuild node-pty

# node-pty's published macOS prebuilds ship spawn-helper without the execute bit, so every
# pseudo-terminal would fail to start with "posix_spawnp failed".
- name: Make node-pty's spawn helper executable
if: runner.os == 'macOS'
working-directory: packages/e2e
run: chmod +x "$(node -p "require('path').dirname(require.resolve('node-pty/package.json'))")"/prebuilds/darwin-*/spawn-helper

# The local project needs no account. It checks the harness and the CLI's basics, such as
# starting a pseudo-terminal, on each system. It runs whole, once per system, so the remote
# shards stay even. One retry for both, so a passing retry shows as flaky in the report
# instead of failing the release.
- name: Run local E2E tests
if: matrix.shard == '1/2'
working-directory: packages/e2e
run: pnpm exec playwright test --project local --retries 1

- name: Run remote E2E tests
id: e2e
if: ${{ !cancelled() }}
shell: bash
working-directory: packages/e2e
env:
SHARD: ${{ matrix.shard }}
SKIP: ${{ matrix.skip }}
run: |
set -euo pipefail
# Slower systems and one retry need more than the config's 20-minute global timeout.
ARGS=(--project remote --shard "$SHARD" --retries 1 --global-timeout 2100000)
if [ -n "$SKIP" ]; then ARGS+=(--grep-invert "$SKIP"); fi
pnpm exec playwright test "${ARGS[@]}"

- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: release-e2e-report-leg-${{ matrix.leg }}
# Playwright traces contain request headers and must not expose E2E_LOADTEST_HEADER.
path: |
packages/e2e/playwright-report/
!packages/e2e/playwright-report/**/*.zip
retention-days: 14

- name: Upload test results
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: release-e2e-results-leg-${{ matrix.leg }}
path: |
packages/e2e/test-results/
!packages/e2e/test-results/**/trace.zip
retention-days: 14

- name: Clean up this job's E2E apps
if: ${{ always() && steps.e2e.outcome != 'skipped' }}
timeout-minutes: 5
shell: bash
run: |
RUN_TOKEN=$(node -e "process.stdout.write(BigInt(process.env.GITHUB_RUN_ID).toString(36))")
SHARD_NUMBER=${E2E_SHARD%/*}
pnpm --filter e2e exec tsx scripts/cleanup-apps.ts --pattern "r${RUN_TOKEN}a${GITHUB_RUN_ATTEMPT}s${SHARD_NUMBER}-"

gate:
name: Release E2E
needs: [commit, e2e]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Verify the tests passed on every system
if: needs.commit.result != 'success' || needs.e2e.result != 'success'
run: exit 1
Loading