diff --git a/.github/workflows/install-e2e-macos-run.yml b/.github/workflows/install-e2e-macos-run.yml index 61b5335c81..e2d1895105 100644 --- a/.github/workflows/install-e2e-macos-run.yml +++ b/.github/workflows/install-e2e-macos-run.yml @@ -34,10 +34,14 @@ on: type: string default: refs/heads/main tag-has-desktop: - description: "Whether install-ref ships the desktop app (apps/desktop). Desktop-method legs from pre-desktop releases natively skip." + description: "Whether install-ref ships the desktop app (apps/desktop). The caller annotates this from the tag's own tree; desktop-method legs from pre-desktop releases natively skip." required: false type: boolean default: true + leg-id: + description: 'Artifact-safe matrix leg id (from generate-e2e-matrix.mjs legId). Names this leg''s logs + player artifacts so the report job can link a row to its zip.' + required: true + type: string dmg-url: description: 'Bootstrap dmg to install OLD with. Default: the latest published one — what a user downloads today.' required: false @@ -67,6 +71,7 @@ jobs: update-method: ${{ inputs.update-method }} install-ref: ${{ inputs.install-ref }} tag-has-desktop: ${{ inputs.tag-has-desktop }} + leg-id: ${{ inputs.leg-id }} runner: macos-latest timeout-minutes: ${{ inputs.timeout-minutes }} @@ -88,6 +93,16 @@ jobs: with: fetch-depth: 0 + - name: Upload leg player + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: install-e2e-player-${{ inputs.leg-id }} + path: tests/install/e2e-assets/playback.html + archive: false + retention-days: 14 + if-no-files-found: error + - name: Start screen recording uses: ./.github/actions/e2e-screen-record with: @@ -145,8 +160,7 @@ jobs: id: artifact if: always() run: | - safe_ref="$(printf '%s' '${{ inputs.install-ref }}' | tr '/:' '--')" - echo "name=install-e2e-macos-dmg-${{ inputs.update-method }}-${safe_ref}-${{ github.sha }}" >> "$GITHUB_OUTPUT" + echo "name=install-e2e-logs-${{ inputs.leg-id }}" >> "$GITHUB_OUTPUT" - name: Upload logs if: always() diff --git a/.github/workflows/install-e2e-run.yml b/.github/workflows/install-e2e-run.yml index 226e7aeb81..f47aea2c8d 100644 --- a/.github/workflows/install-e2e-run.yml +++ b/.github/workflows/install-e2e-run.yml @@ -50,6 +50,10 @@ on: required: false type: string default: refs/heads/main + leg-id: + description: 'Artifact-safe matrix leg id (from generate-e2e-matrix.mjs legId). Names this leg''s logs + player artifacts so the report job can link a row to its zip.' + required: true + type: string tag-has-desktop: description: "Whether install-ref ships the desktop app (apps/desktop). The caller annotates this from the tag's own tree; desktop-method legs from pre-desktop releases natively skip." required: false @@ -130,6 +134,19 @@ jobs: -c copy "${{ runner.temp }}/e2e-logs/recording.mp4" fi + # The leg player: one static HTML, uploaded BEFORE the driver runs + # (if: always() covers failures too). Single file, no zip, so the + # artifacts URL serves playback.html directly. + - name: Upload leg player + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: install-e2e-player-${{ inputs.leg-id }} + path: tests/install/e2e-assets/playback.html + archive: false + retention-days: 14 + if-no-files-found: error + # Artifact names cannot contain '/', and install-ref may be a full ref # like refs/heads/main. GitHub Actions expressions have no string-replace # function, so build the safe name here. Runs even on failure -- that is @@ -139,9 +156,7 @@ jobs: id: artifact run: | set -euo pipefail - safe_ref='${{ inputs.install-ref }}' - safe_ref="${safe_ref//\//-}" - echo "name=install-e2e-${{ runner.os }}-${{ inputs.update-method }}-${safe_ref}" >> "$GITHUB_OUTPUT" + echo "name=install-e2e-logs-${{ inputs.leg-id }}" >> "$GITHUB_OUTPUT" # The installer's own transcripts say far more than the assertion that # tripped when a real install breaks. diff --git a/.github/workflows/install-e2e-windows-run.yml b/.github/workflows/install-e2e-windows-run.yml index 13fed4d1fd..ea67fafb7a 100644 --- a/.github/workflows/install-e2e-windows-run.yml +++ b/.github/workflows/install-e2e-windows-run.yml @@ -63,6 +63,10 @@ on: required: false type: boolean default: true + leg-id: + description: 'Artifact-safe matrix leg id (from generate-e2e-matrix.mjs legId). Names this leg''s logs + player artifacts so the report job can link a row to its zip.' + required: true + type: string setup-exe-url: description: 'Bootstrap installer to install OLD with. Default: the latest published one — what a user downloads today.' required: false @@ -115,6 +119,16 @@ jobs: with: fetch-depth: 0 + - name: Upload leg player + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: install-e2e-player-${{ inputs.leg-id }} + path: tests/install/e2e-assets/playback.html + archive: false + retention-days: 14 + if-no-files-found: error + # One recording mechanism on every OS: the composite action installs # ffmpeg (cached - winget's download is the slow part), starts the # capture, and record-stop fails on a zero-frame file so a silently @@ -175,7 +189,7 @@ jobs: if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: - name: install-e2e-windows-${{ inputs.install-method }}-${{ inputs.update-method }}-${{ inputs.install-ref }}-${{ github.sha }} + name: install-e2e-logs-${{ inputs.leg-id }} path: gui-e2e-proof retention-days: 14 if-no-files-found: ignore diff --git a/.github/workflows/install-e2e.yml b/.github/workflows/install-e2e.yml index 5ee1b119a9..eddeec299c 100644 --- a/.github/workflows/install-e2e.yml +++ b/.github/workflows/install-e2e.yml @@ -160,6 +160,7 @@ jobs: update-method: ${{ matrix.update_method }} install-ref: ${{ matrix.install_ref }} tag-has-desktop: ${{ matrix.tag_has_desktop }} + leg-id: ${{ matrix.leg_id }} windows: name: ${{ matrix.name }} @@ -174,6 +175,7 @@ jobs: update-method: ${{ matrix.update_method }} install-ref: ${{ matrix.install_ref }} tag-has-desktop: ${{ matrix.tag_has_desktop }} + leg-id: ${{ matrix.leg_id }} macos: name: ${{ matrix.name }} @@ -190,6 +192,7 @@ jobs: update-method: ${{ matrix.update_method }} install-ref: ${{ matrix.install_ref }} tag-has-desktop: ${{ matrix.tag_has_desktop }} + leg-id: ${{ matrix.leg_id }} # The outcome, human-readable: the plan chart again, with each cell # replaced by how that leg actually concluded. Per-leg conclusions are @@ -218,7 +221,12 @@ jobs: # The tag annotations let the chart say WHY a cell skipped # (pre-desktop vs declared TODO) instead of a flat "skip". gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs?per_page=100" \ - --paginate --jq '.jobs[] | {name, conclusion}' | - node scripts/sandbox/generate-e2e-matrix.mjs --format results \ - --tags '${{ needs.pick-releases.outputs.tags }}' + --paginate --jq '.jobs[] | {name, conclusion}' > /tmp/e2e-jobs.ndjson + gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts?per_page=100" \ + --paginate --jq '.artifacts[] | {name, id}' > /tmp/e2e-artifacts.ndjson + echo 'Legend: ✅ ran green · ❌ ran red · pre-desktop / TODO = why a leg skipped · 📼 opens the leg player (recording + synced logs)' + echo + node scripts/sandbox/generate-e2e-matrix.mjs --format results \ + --tags '${{ needs.pick-releases.outputs.tags }}' \ + --artifacts /tmp/e2e-artifacts.ndjson < /tmp/e2e-jobs.ndjson } >> "$GITHUB_STEP_SUMMARY" diff --git a/scripts/sandbox/generate-e2e-matrix.mjs b/scripts/sandbox/generate-e2e-matrix.mjs index bba6a435df..00fa1b110a 100644 --- a/scripts/sandbox/generate-e2e-matrix.mjs +++ b/scripts/sandbox/generate-e2e-matrix.mjs @@ -26,6 +26,7 @@ * predate the desktop app). */ +import fs from 'node:fs'; import path from 'node:path'; import { parseArgs } from 'node:util'; import { fileURLToPath } from 'node:url'; @@ -72,10 +73,24 @@ import { fileURLToPath } from 'node:url'; * A picked release tag plus what its own tree ships (annotated by * pick-releases in install-e2e.yml). * - * @typedef {{name: string, install_method: string, update_method: string, + * @typedef {{name: string, leg_id: string, install_method: string, update_method: string, * install_ref: string, tag_has_desktop?: boolean}} MatrixEntry */ +/** + * Artifact-safe key for one leg: the matrix name with every character + * outside [A-Za-z0-9._-] collapsed to '-'. Reconstructed by the results + * renderer from the parsed job name (same formula, same bytes), and used + * by every run workflow to name its logs/player artifacts, so the report + * job can map a concluded leg back to its artifacts without GitHub + * linking jobs to artifacts. + * @param {string} name + * @returns {string} + */ +export function legId(name) { + return name.replace(/[^A-Za-z0-9._-]+/g, '-'); +} + /** @type {Record} */ export const SPEC = { windows: { @@ -189,6 +204,7 @@ export function buildMatrices(envs, tags) { /** @type {MatrixEntry} */ const entry = { name: `${env.os}: ${env.install} -> ${env.update} (${tag.ref} -> HEAD)`, + leg_id: legId(`${env.os}: ${env.install} -> ${env.update} (${tag.ref} -> HEAD)`), install_method: env.install, update_method: env.update, install_ref: tag.ref, @@ -265,10 +281,16 @@ export function renderMarkdownPlan(envs, tags) { * plan got), skipped cells carry their REASON: `pre-desktop` when a * desktop-surface method meets a tag that predates apps/desktop, `TODO` * when the pair is declared but no driver arm runs it yet. + * @param {Map} [artifactById] Artifact name -> id for this + * run (the report job's --artifacts). Legs that RAN (success or failure) + * get a 📼 link: the leg's player artifact (playback.html, archive:false) + * with ?zip= pointing at the leg's logs artifact. Both artifacts are + * named install-e2e-{player,logs}-; leg_id is rebuilt from the + * parsed job name with the same formula the generator mints (legId). * @returns {string} */ -export function renderMarkdownResults(jobs, tagAnnotations = []) { - const LEG = /^(linux|windows|macos): (\S+) -> (\S+) \((\S+) -> HEAD\) \//; +export function renderMarkdownResults(jobs, tagAnnotations = [], artifactById = new Map()) { + const LEG = /^(linux|windows|macos): (\S+) -> (\S+) \(([^)]+) -> HEAD\) \//; /** @type {Map} */ const desktopByTag = new Map(tagAnnotations.map((t) => [t.ref, t.desktop])); /** @@ -303,14 +325,20 @@ export function renderMarkdownResults(jobs, tagAnnotations = []) { if (!tags.includes(tag)) tags.push(tag); if (!rows.has(combo)) rows.set(combo, new Map()); const cell = (() => { - switch (job.conclusion) { - case 'success': return '✅'; - case 'failure': return '❌'; - case 'skipped': return skipLabel(m[2], m[3], tag); - case 'cancelled': return 'cancelled'; - default: return 'running'; - } - })(); + const legId2 = legId(`${m[1]}: ${m[2]} -> ${m[3]} (${m[4]} -> HEAD)`); + const playerId = artifactById.get(`install-e2e-player-${legId2}`); + const logsId = artifactById.get(`install-e2e-logs-${legId2}`); + const reel = (playerId !== undefined && logsId !== undefined) + ? ` [📼](https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${playerId}?zip=${encodeURIComponent(`https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${logsId}`)})` + : ''; + switch (job.conclusion) { + case 'success': return `✅${reel}`; + case 'failure': return `❌${reel}`; + case 'skipped': return skipLabel(m[2], m[3], tag); + case 'cancelled': return 'cancelled'; + default: return 'running'; + } + })(); const byTag = /** @type {Map} */ (rows.get(combo)); const prev = byTag.get(tag); if (prev === undefined || RANK.indexOf(cell) > RANK.indexOf(prev)) { @@ -351,12 +379,22 @@ async function main() { options: { tags: { type: 'string', default: '[]' }, format: { type: 'string', default: 'json' }, + artifacts: { type: 'string' }, }, }); if (values.format === 'results') { const jobs = (await readStdin()).split('\n').filter((l) => l.trim()).map((l) => JSON.parse(l)); const annotations = /** @type {TagAnnotation[]} */ (JSON.parse(values.tags)); - process.stdout.write(renderMarkdownResults(jobs, annotations)); + /** @type {Map} */ + const artifactById = new Map(); + if (values.artifacts) { + for (const line of (await fs.promises.readFile(values.artifacts, 'utf8')).split('\n')) { + if (!line.trim()) continue; + const a = JSON.parse(line); + if (typeof a.name === 'string' && typeof a.id === 'number') artifactById.set(a.name, a.id); + } + } + process.stdout.write(renderMarkdownResults(jobs, annotations, artifactById)); return; } const tags = /** @type {TagAnnotation[]} */ (JSON.parse(values.tags)); diff --git a/tests/install/e2e-assets/playback.html b/tests/install/e2e-assets/playback.html index 405bfb221c..4bece90d7b 100644 --- a/tests/install/e2e-assets/playback.html +++ b/tests/install/e2e-assets/playback.html @@ -227,11 +227,8 @@ function syncPane() { } /* ── zip loading ───────────────────────────────────────────────────────── */ -async function loadZip(url) { - statusEl.textContent = `fetching ${url} …`; - const resp = await fetch(url, { credentials: 'same-origin' }); - if (!resp.ok) throw new Error(`zip fetch failed: ${resp.status} ${resp.statusText}`); - const zip = await JSZip.loadAsync(await resp.arrayBuffer()); +async function loadZipFromBlob(blob, label) { + const zip = await JSZip.loadAsync(await blob.arrayBuffer()); const names = Object.keys(zip.files).filter((n) => !zip.files[n].dir); const videoName = names.find((n) => n === 'recording.mp4') || @@ -245,26 +242,64 @@ async function loadZip(url) { state.logs.set(n, { lines, hasTs: lines.some((l) => l.ts !== null) }); } if (state.logs.size === 0) throw new Error('no *.log files in the zip'); - state.zipName = url.split('/').pop() || url; + state.zipName = label || 'leg artifact'; state.activeTab = [...state.logs.keys()][0]; } -/* ── boot ──────────────────────────────────────────────────────────────── */ -async function main() { - const params = new URLSearchParams(location.search); - const zipUrl = params.get('zip'); - if (!zipUrl) { - fail('no ?zip= param — pass the artifact zip URL, e.g.\n' + - 'playback.html?zip=https://github.com//actions/runs//artifacts/'); - return; - } +async function loadZip(url) { + statusEl.textContent = `fetching ${url} …`; try { - await loadZip(zipUrl); + const resp = await fetch(url, { credentials: 'same-origin' }); + if (!resp.ok) throw new Error(`zip fetch failed: ${resp.status} ${resp.statusText}`); + await loadZipFromBlob(await resp.blob(), url.split('/').pop()); + } catch (e) { + // GitHub artifact downloads are auth-gated: a cross-origin page (this + // file opened locally) cannot fetch them. The page then becomes the + // download-and-drop path — a normal link click DOES carry the user's + // GitHub session. + statusEl.className = 'error'; + statusEl.innerHTML = + `Could not fetch the zip directly (GitHub artifact downloads need your session — ` + + `a locally-opened page cannot send it). ` + + `Download the leg zip: ${url.split('/').pop()} ` + + `— then drop it anywhere on this page (or click here to pick the file).`; + statusEl.onclick = () => fileInput.click(); + return false; + } + return true; +} + +/* drag-drop + file picker: the universal transport for auth-gated zips */ +const fileInput = document.createElement('input'); +fileInput.type = 'file'; +fileInput.accept = '.zip,application/zip'; +fileInput.style.display = 'none'; +fileInput.addEventListener('change', async () => { + const f = fileInput.files && fileInput.files[0]; + if (!f) return; + try { + await loadZipFromBlob(f, f.name); + boot(); } catch (e) { fail(`could not load zip: ${e.message}`); - return; } +}); +document.body.appendChild(fileInput); +document.addEventListener('dragover', (e) => e.preventDefault()); +document.addEventListener('drop', async (e) => { + e.preventDefault(); + const f = [...(e.dataTransfer?.files ?? [])][0]; + if (!f || !/\.zip$/i.test(f.name)) { fail('drop a .zip artifact file'); return; } + try { + await loadZipFromBlob(f, f.name); + boot(); + } catch (err) { + fail(`could not load zip: ${err.message}`); + } +}); +/* ── boot ──────────────────────────────────────────────────────────────── */ +function boot() { statusEl.style.display = 'none'; $('app').style.display = 'flex'; $('zipName').textContent = state.zipName; @@ -302,6 +337,21 @@ async function main() { renderTabs(); renderPane(true); } + +async function main() { + const params = new URLSearchParams(location.search); + const zipUrl = params.get('zip'); + if (zipUrl) { + if (await loadZip(zipUrl)) boot(); + } else { + // No ?zip=: this is the manual path — the leg player artifact page or + // a local copy. Drop or pick a leg zip. + statusEl.className = 'error'; + statusEl.innerHTML = + 'Drop a leg artifact zip anywhere on this page (or click here to pick the file).'; + statusEl.onclick = () => fileInput.click(); + } +} main();