Files
kandev/.github/workflows/e2e-tests.yml
T
2026-08-12 17:12:56 +01:00

822 lines
31 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: E2E Tests
on:
push:
branches: [main]
paths:
- "apps/backend/**"
- "apps/desktop/**"
- "apps/web/**"
- "apps/packages/**"
- "apps/pnpm-lock.yaml"
- "apps/pnpm-workspace.yaml"
- ".github/workflows/e2e-tests.yml"
- "!**/*.md"
pull_request:
branches: [main]
paths:
- "apps/backend/**"
- "apps/desktop/**"
- "apps/web/**"
- "apps/packages/**"
- "apps/pnpm-lock.yaml"
- "apps/pnpm-workspace.yaml"
- ".github/workflows/e2e-tests.yml"
- "!**/*.md"
# Manual trigger for verifying CI on draft PRs and ad-hoc reruns. The
# default sharded run uses the same ref the user picks in the dispatch UI.
workflow_dispatch:
inputs:
fail_on_flaky:
description: "Fail the run when Playwright needs a retry"
required: false
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
# The build/report jobs read the latest successful main timing artifact.
actions: read
# Required so the containerized build / e2e shards / e2e-report jobs can
# pull the kandev-ci image from GHCR via GITHUB_TOKEN.
packages: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
# Pre-baked image bundles Go, Node 24, pnpm 9.15.9 — see
# .github/docker/ci-base/Dockerfile. Uses the `build` tag (with Go)
# because this job compiles the backend.
container: ghcr.io/kdlbs/kandev-ci:build-latest
timeout-minutes: 10
# Container jobs default to `sh`; pin to bash for the few shell steps below.
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Mark workspace safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
# Inside the container the home dir is /root, so the pnpm store lives at
# /root/.local/share/pnpm/store. actions/cache resolves `~` against $HOME
# so the same path string works for both the host and container variants.
- name: Cache pnpm store
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('apps/pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies
working-directory: apps
run: pnpm install --frozen-lockfile
# `build-web-e2e`, not `build-web`: the production web build no longer
# bundles the pseudo QA catalog, and tests/i18n/pseudo-coverage.spec.ts
# needs it. See apps/web/lib/i18n/bundling.ts.
- name: Build backend and web
run: make build-backend build-web-e2e
# Fixture plugin package consumed by the plugin E2E specs. Built here
# (the build job has the Go toolchain) and shipped to the shards as its
# own artifact; global-setup fails fast if it is missing.
- name: Build E2E fixture plugin package
run: make -C apps/backend e2e-plugin-package
# Linux/amd64 helper binaries (agentctl + mock-agent) bind-mounted into
# containers by the Docker E2E project. Cheap to build (~1s each) so we
# always do it; the regular E2E job ignores them.
- name: Build Docker E2E helper binaries
run: make build-backend-linux-helpers
- name: Locate latest successful main timing profile
id: main-timing-run
env:
GH_TOKEN: ${{ github.token }}
GITHUB_API_URL: ${{ github.api_url }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
node <<'NODE'
const fs = require("node:fs");
(async () => {
const url =
process.env.GITHUB_API_URL +
"/repos/" +
process.env.GITHUB_REPOSITORY +
"/actions/workflows/e2e-tests.yml/runs?branch=main&status=success&per_page=20";
const response = await fetch(url, {
headers: {
accept: "application/vnd.github+json",
authorization: "Bearer " + process.env.GH_TOKEN,
},
});
if (!response.ok) {
console.log(
"::warning::Unable to query successful main E2E runs (" +
response.status +
"); using count fallback.",
);
fs.appendFileSync(process.env.GITHUB_OUTPUT, "run_id=\n");
return;
}
const payload = await response.json();
const run = (payload.workflow_runs ?? []).find(
(candidate) => candidate.head_branch === "main" && candidate.conclusion === "success",
);
fs.appendFileSync(process.env.GITHUB_OUTPUT, "run_id=" + (run?.id ?? "") + "\n");
console.log(
run
? "Using successful main E2E run " + run.id + " for timing history."
: "No successful main E2E run found; using count fallback.",
);
})().catch((error) => {
console.error(error);
fs.appendFileSync(process.env.GITHUB_OUTPUT, "run_id=\n");
});
NODE
- name: Download latest main timing profile
if: steps.main-timing-run.outputs.run_id != ''
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: e2e-timing-profile
path: e2e/previous-profile
repository: ${{ github.repository }}
run-id: ${{ steps.main-timing-run.outputs.run_id }}
github-token: ${{ github.token }}
- name: Upload selected timing baseline for report job
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-selected-main-timing-profile
path: e2e/previous-profile/timing-profile.json
if-no-files-found: ignore
retention-days: 3
- name: Generate duration-aware E2E shard manifests
working-directory: apps/web
run: |
set -euo pipefail
rm -rf "$GITHUB_WORKSPACE/e2e-manifests"
if [[ -f "$GITHUB_WORKSPACE/e2e/previous-profile/timing-profile.json" ]]; then
echo "Planning from the latest successful main timing profile."
pnpm exec tsx e2e/scripts/plan-shards.ts \
--web-root "$GITHUB_WORKSPACE/apps/web" \
--output-dir "$GITHUB_WORKSPACE/e2e-manifests" \
--profile "$GITHUB_WORKSPACE/e2e/previous-profile/timing-profile.json"
else
echo "Planning with deterministic count fallback; no usable main timing profile was downloaded."
pnpm exec tsx e2e/scripts/plan-shards.ts \
--web-root "$GITHUB_WORKSPACE/apps/web" \
--output-dir "$GITHUB_WORKSPACE/e2e-manifests"
fi
- name: Upload E2E shard manifests
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-shard-manifests
path: e2e-manifests/
retention-days: 3
- name: Upload backend build
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-backend-build
path: apps/backend/bin/
retention-days: 1
- name: Upload E2E fixture plugin package
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-plugin-package
path: apps/backend/.build/kandev-plugin-e2e-1.0.0.tar.gz
retention-days: 1
# Tar the Vite dist directory so shards can reuse the same static web build.
- name: Package web build
run: tar -cf apps/web/web-dist.tar -C apps/web dist
- name: Upload web build
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-web-build
path: apps/web/web-dist.tar
retention-days: 1
e2e:
name: E2E Shard ${{ matrix.shard }}/14
needs: build
runs-on: ubuntu-latest
# Pre-baked image bundles Node 24, pnpm 9.15.9, and the Playwright browser
# binaries (Chromium etc.) — see .github/docker/ci-base/Dockerfile. This is
# the biggest speedup since `npx playwright install chromium --with-deps`
# alone took ~1.5–2 min per shard.
#
# `--ipc=host` is required for Chromium: the default container `/dev/shm`
# is only ~64MiB, which causes tabs to slow to a crawl and renderers to
# crash mid-test.
# Uses the `runtime` tag — no Go toolchain needed; the shards consume the
# pre-built backend artifact from the `build` job. ~600 MB smaller pull
# than the build image, saves ~20s per shard at startup.
container:
image: ghcr.io/kdlbs/kandev-ci:runtime-latest
options: --ipc=host
# 25 min (was 22) — leaves room for the worst-case "every shard hits a few
# flake-retries" combination without blowing past the cap. Average shard
# runs ~10 min, so this only kicks in when something is going wrong.
timeout-minutes: 25
# Container jobs default to `sh`; pin to bash.
defaults:
run:
shell: bash
# Keep localhost resolution deterministic for Node fetches used by the
# Playwright fixtures and backend readiness polling.
env:
NODE_OPTIONS: --dns-result-order=ipv4first
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Mark workspace safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Cache pnpm store
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('apps/pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies
working-directory: apps
run: pnpm install --frozen-lockfile
- name: Download backend build
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: e2e-backend-build
path: apps/backend/bin/
- name: Make backend binaries executable
run: chmod +x apps/backend/bin/*
- name: Download E2E fixture plugin package
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: e2e-plugin-package
path: apps/backend/.build/
- name: Download web build
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: e2e-web-build
path: apps/web/
- name: Extract web build
working-directory: apps/web
run: tar -xf web-dist.tar && rm web-dist.tar
- name: Enable strict flaky-test diagnostics
if: github.event_name == 'workflow_dispatch' && inputs.fail_on_flaky
run: echo "E2E_FAIL_ON_FLAKY=1" >> "$GITHUB_ENV"
- name: Download E2E shard manifests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: e2e-shard-manifests
path: e2e-manifests
# Pinned to chromium + mobile-chrome so the dedicated `e2e-containers`
# job below owns the real-Docker project (which covers both the Docker
# executor and the SSH executor's sshd target). Without --project the
# container-bound specs would run here too, fail seeding (Docker not
# enabled for these shards), and spam every shard.
- name: Run planned E2E tests (shard ${{ matrix.shard }}/14)
working-directory: apps/web
env:
E2E_SHARD: ${{ matrix.shard }}
run: bash e2e/scripts/run-planned-shard.sh "$GITHUB_WORKSPACE/e2e-manifests/normal/${{ matrix.shard }}.json"
- name: Upload blob report
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: blob-report-${{ matrix.shard }}
path: apps/web/e2e/blob-report/
retention-days: 3
- name: Upload test results
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-results-${{ matrix.shard }}
path: apps/web/e2e/test-results/
retention-days: 7
# Real-Docker E2E: exercises the local_docker executor end-to-end.
# ubuntu-latest ships with Docker preinstalled, so no service container is
# required. Container-bound tests are slow (~2 min each), so we shard across
# 6 runners — the build job creates a duration-aware manifest for this
# cohort, and each runner executes its explicit file selection.
#
# This job runs the `containers` Playwright project, which covers both the
# Docker executor and the SSH executor (since the SSH executor's e2e tests
# also rely on Docker to host a real sshd container as the remote target).
# Sharded 6 ways — each shard is its own runner. See apps/web/e2e/README.md.
e2e-containers:
name: E2E Containers Shard ${{ matrix.shard }}/6
needs: build
# This job intentionally runs on the host ubuntu runner (NOT the kandev-ci
# container image): the containers project needs direct access to the
# host Docker daemon, and a docker-in-docker setup would break the tests'
# host-style bind mounts (paths under os.tmpdir() inside a runner container
# wouldn't exist on the host where the docker daemon resolves them).
# We still avoid the slow `playwright install --with-deps` step by copying
# browsers out of the kandev-ci image — see the extract step below.
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6]
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Verify Docker is available
run: docker info
- name: Set up pnpm
uses: pnpm/action-setup@a8198c4bff370c8506180b035930dea56dbd5288 # v5
with:
version: "9.15.9"
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: "24"
- name: Cache pnpm store
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('apps/pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies
working-directory: apps
run: pnpm install --frozen-lockfile
# The kandev-ci image is public, so fork PRs can pull it anonymously.
# Their read-only GITHUB_TOKEN can still be rejected by GHCR during an
# explicit login because it belongs to the base repository, not the
# contributor's fork. Keep authenticated pulls for trusted runs.
- name: Log in to GHCR
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Skip the Playwright CDN download (~7 min and an outage-prone path) by
# copying the prebaked chromium out of the kandev-ci image, which is
# `FROM mcr.microsoft.com/playwright:...` and already ships the matching
# browser at /ms-playwright. Pulling the `runtime` tag (matches the
# `e2e` / `e2e-report` jobs above) — the `build` tag has the same
# browser layer but is ~300 MB larger because of the Go toolchain.
- name: Extract Playwright browsers from kandev-ci image
run: |
set -euo pipefail
docker pull ghcr.io/kdlbs/kandev-ci:runtime-latest
mkdir -p /tmp/ms-playwright
docker run --rm \
-v /tmp/ms-playwright:/dest \
ghcr.io/kdlbs/kandev-ci:runtime-latest \
cp -a /ms-playwright/. /dest/
echo "PLAYWRIGHT_BROWSERS_PATH=/tmp/ms-playwright" >> "$GITHUB_ENV"
# Browser binaries come from the image above. GitHub's Ubuntu runners
# usually already have the shared libs Chromium needs, so smoke-test the
# copied browser first and only hit apt as a bounded fallback.
- name: Verify Playwright browser runtime
working-directory: apps/web
run: |
set -euo pipefail
smoke_test() {
node <<'NODE'
const { chromium } = require("@playwright/test");
(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
await page.goto("data:text/html,ok");
await browser.close();
})().catch((error) => {
console.error(error);
process.exit(1);
});
NODE
}
if smoke_test; then
echo "Playwright Chromium launches with existing runner packages."
exit 0
fi
echo "::warning::Playwright Chromium failed to launch; installing missing host packages."
timeout 180s npx playwright install-deps chromium
smoke_test
- name: Download backend build
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: e2e-backend-build
path: apps/backend/bin/
- name: Make backend binaries executable
run: chmod +x apps/backend/bin/*
- name: Download E2E fixture plugin package
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: e2e-plugin-package
path: apps/backend/.build/
- name: Download web build
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: e2e-web-build
path: apps/web/
- name: Extract web build
working-directory: apps/web
run: tar -xf web-dist.tar && rm web-dist.tar
- name: Enable strict flaky-test diagnostics
if: github.event_name == 'workflow_dispatch' && inputs.fail_on_flaky
run: echo "E2E_FAIL_ON_FLAKY=1" >> "$GITHUB_ENV"
- name: Download E2E shard manifests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: e2e-shard-manifests
path: e2e-manifests
- name: Run planned container-backed E2E tests shard ${{ matrix.shard }}/6 (Docker executor + SSH executor)
working-directory: apps/web
env:
KANDEV_E2E_CONTAINERS: "1"
E2E_SHARD: ${{ matrix.shard }}
run: bash e2e/scripts/run-planned-shard.sh "$GITHUB_WORKSPACE/e2e-manifests/containers/${{ matrix.shard }}.json"
# Named with the same `blob-report-*` prefix the merge job globs for
# so the containers results land in the unified HTML report alongside
# the sharded chromium/mobile-chrome runs.
- name: Upload containers blob report
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: blob-report-containers-${{ matrix.shard }}
path: apps/web/e2e/blob-report/
retention-days: 3
- name: Upload containers E2E results
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: containers-e2e-test-results-${{ matrix.shard }}
path: apps/web/e2e/test-results/
retention-days: 7
desktop-e2e:
name: Desktop E2E Smoke
runs-on: ubuntu-latest
# Includes Ubuntu WebKit/Tauri system package installation; GitHub apt mirrors
# can spend more than 20 minutes there before tests start.
timeout-minutes: 45
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Set up pnpm
uses: pnpm/action-setup@a8198c4bff370c8506180b035930dea56dbd5288 # v5
with:
version: "9.15.9"
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: "24"
cache: pnpm
cache-dependency-path: apps/pnpm-lock.yaml
- name: Set up Rust
run: rustup toolchain install stable --profile minimal
- name: Cache Rust build
uses: Swatinem/rust-cache@42dc69e1aa15d09112580998cf2ef0119e2e91ae # v2
with:
workspaces: apps/desktop/src-tauri -> target
key: desktop-e2e
- name: Install desktop system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config \
libglib2.0-dev \
libwebkit2gtk-4.1-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
patchelf \
xvfb
- name: Install dependencies
working-directory: apps
run: pnpm install --frozen-lockfile
- name: Run desktop smoke
working-directory: apps
run: pnpm --filter @kandev/desktop e2e
e2e-report:
name: Merge E2E Reports
needs: [e2e, e2e-containers, desktop-e2e]
if: always()
runs-on: ubuntu-latest
# Pre-baked image bundles Node 24, pnpm 9.15.9, and the Playwright CLI.
# `runtime` tag — no Go needed for merging blob reports.
container: ghcr.io/kdlbs/kandev-ci:runtime-latest
timeout-minutes: 5
# Container jobs default to `sh`; pin to bash.
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Mark workspace safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Cache pnpm store
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.local/share/pnpm/store
key: pnpm-${{ runner.os }}-${{ hashFiles('apps/pnpm-lock.yaml') }}
restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies
working-directory: apps
run: pnpm install --frozen-lockfile
# The published runtime image may predate the report-tool dependency;
# keep older images usable while the image rebuild adds unzip permanently.
- name: Ensure timing report tools are installed
run: |
if ! command -v unzip >/dev/null 2>&1; then
apt-get update
apt-get install -y --no-install-recommends unzip
rm -rf /var/lib/apt/lists/*
fi
- name: Download blob reports
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: apps/web/e2e/blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Download E2E shard manifests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
continue-on-error: true
with:
name: e2e-shard-manifests
path: e2e-manifests
- name: Download selected main timing profile
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
continue-on-error: true
with:
name: e2e-selected-main-timing-profile
path: e2e/previous-profile
- name: Collect timing and retry diagnostics
if: always()
working-directory: apps/web
run: |
set -euo pipefail
if [[ -f "$GITHUB_WORKSPACE/e2e/previous-profile/timing-profile.json" ]]; then
pnpm exec tsx e2e/scripts/e2e-timings.ts \
--input e2e/blob-reports \
--output e2e/timing-profile.json \
--web-root "$GITHUB_WORKSPACE/apps/web" \
--branch "$GITHUB_REF_NAME" \
--sha "$GITHUB_SHA" \
--run-id "$GITHUB_RUN_ID" \
--previous "$GITHUB_WORKSPACE/e2e/previous-profile/timing-profile.json"
else
pnpm exec tsx e2e/scripts/e2e-timings.ts \
--input e2e/blob-reports \
--output e2e/timing-profile.json \
--web-root "$GITHUB_WORKSPACE/apps/web" \
--branch "$GITHUB_REF_NAME" \
--sha "$GITHUB_SHA" \
--run-id "$GITHUB_RUN_ID"
fi
pnpm exec tsx e2e/scripts/retry-summary.ts \
--input e2e/blob-reports \
--output e2e/retry-summary.json \
--manifest-dir "$GITHUB_WORKSPACE/e2e-manifests" \
--attachment-output e2e/retry-artifacts \
--artifact-name e2e-timing-diagnostics \
--artifact-url "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID#artifacts"
- name: Write E2E timing summary
if: always()
working-directory: apps/web
run: |
node <<'NODE'
const fs = require("node:fs");
const summaryPath = "e2e/retry-summary.json";
if (!fs.existsSync(summaryPath)) process.exit(0);
const summary = JSON.parse(fs.readFileSync(summaryPath, "utf8"));
const counts = summary.counts;
const diagnosticTests = summary.tests.filter(
(test) => test.attempts > 1 || !["passed", "skipped"].includes(test.finalStatus),
);
const markdown = (value) => String(value).replaceAll("|", "\\|").replace(/\s+/g, " ");
const lines = [
"## E2E timing and retry summary",
"",
"- Plan mode: " + summary.planning.mode,
"- Unknown units: " + summary.planning.unknownUnits,
"- Warm units: " + summary.planning.warmUnits,
"- Stale profile units: " + summary.planning.staleUnits,
"- Passed after retry: " + counts.passedAfterRetry,
"- Final failures: " + (counts.failed + counts.timedOut),
"",
"| Cohort | Shard | Predicted (s) | Actual (s) | Delta (s) | Exit |",
"| --- | ---: | ---: | ---: | ---: | ---: |",
...summary.shards.map(
(shard) =>
"| " +
shard.cohort +
" | " +
shard.shard +
"/" +
shard.shardCount +
" | " +
shard.predictedSeconds.toFixed(1) +
" | " +
shard.actualSeconds.toFixed(1) +
" | " +
shard.deltaSeconds.toFixed(1) +
" | " +
shard.exitCode +
" |",
),
];
if (diagnosticTests.length > 0) {
lines.push(
"",
"### Retry and failure details",
"",
"| Test | Attempts | Final status | Error | Artifacts |",
"| --- | ---: | --- | --- | --- |",
...diagnosticTests.map((test) => {
const links = test.attachments
.map((attachment) =>
attachment.artifactUrl
? "[" + markdown(attachment.name + " — " + attachment.path) + "](" +
attachment.artifactUrl +
")"
: markdown(attachment.name),
)
.join(", ");
return (
"| `" +
markdown(test.key) +
"` | " +
test.attempts +
" | " +
test.finalStatus +
" | " +
test.errorCategory +
" | " +
(links || "Not captured") +
" |"
);
}),
);
}
fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY, lines.join("\n") + "\n");
NODE
- name: Upload timing profile candidate
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-timing-profile
path: apps/web/e2e/timing-profile.json
if-no-files-found: ignore
retention-days: 30
- name: Upload retry and shard timing summary
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-retry-summary
path: apps/web/e2e/retry-summary.json
if-no-files-found: ignore
retention-days: 14
- name: Upload timing diagnostics bundle
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-timing-diagnostics
path: |
apps/web/e2e/timing-profile.json
apps/web/e2e/retry-summary.json
apps/web/e2e/retry-artifacts/
apps/web/e2e/blob-reports/*metadata.json
if-no-files-found: ignore
retention-days: 14
- name: Merge reports
if: hashFiles('apps/web/e2e/blob-reports/**/*.zip') != ''
working-directory: apps/web
# `-c e2e/playwright.config.ts` is required because the blobs come from
# two different absolute checkout paths: the containerized `e2e` shards
# check out under `/__w/...` while `e2e-containers` runs on the host
# runner and checks out under `/home/runner/work/...`. Playwright
# embeds the absolute testDir in each blob and refuses to merge
# reports recorded with different test directories — passing the
# config makes it normalize against the config's `testDir` instead.
run: npx playwright merge-reports --config e2e/playwright.config.ts --reporter=html ./e2e/blob-reports
- name: Upload merged report
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: playwright-report
path: apps/web/playwright-report/
retention-days: 14
- name: Verify required E2E jobs passed
if: always()
env:
E2E_RESULT: ${{ needs.e2e.result }}
E2E_CONTAINERS_RESULT: ${{ needs['e2e-containers'].result }}
DESKTOP_E2E_RESULT: ${{ needs['desktop-e2e'].result }}
run: |
set -euo pipefail
if [ "$E2E_RESULT" != "success" ]; then
echo "e2e finished with result: $E2E_RESULT" >&2
exit 1
fi
if [ "$E2E_CONTAINERS_RESULT" != "success" ]; then
echo "e2e-containers finished with result: $E2E_CONTAINERS_RESULT" >&2
exit 1
fi
if [ "$DESKTOP_E2E_RESULT" != "success" ]; then
echo "desktop-e2e finished with result: $DESKTOP_E2E_RESULT" >&2
exit 1
fi