Doubao-powered voice input for Linux, Wayland and Omarchy
fix(workflow): publish failed Midscene report previews (#23)
Leyang6999ddf2f841
diff --git a/.github/workflows/deploy-midscene-report.yml b/.github/workflows/deploy-midscene-report.ymlindex aea8684..9f92965 100644--- a/.github/workflows/deploy-midscene-report.yml+++ b/.github/workflows/deploy-midscene-report.yml@@ -11,6 +11,11 @@ on:description: Distribution label shown in report historyrequired: truetype: string+ run-result:+ description: Result of the job that produced the report artifact+ required: false+ default: success+ type: stringjobs:deploy:@@ -101,12 +106,35 @@ jobs:REPORT_URL: ${{ steps.pages.outputs.base_url }}/reports/${{ github.run_id }}/index.htmlONBOARDING_URL: ${{ steps.pages.outputs.base_url }}/reports/${{ github.run_id }}/onboarding-report.htmlREPORT_PREVIEW_URL: ${{ steps.pages.outputs.base_url }}/reports/${{ github.run_id }}/report-preview.png+ PRODUCER_RESULT: ${{ inputs.run-result }}run: |if [[ "${{ inputs.report-label }}" == Omarchy* ]]; then+ SUCCESS_RATE=$(jq -r '.reports[0].successRate' "$RUNNER_TEMP/pages-site/reports/manifest.json")+ HAS_SHELL_REPORT=false+ if [[ -f "$RUNNER_TEMP/pages-site/reports/$GITHUB_RUN_ID/onboarding-report.html" ]]; then+ HAS_SHELL_REPORT=true+ fi++ if [[ "$PRODUCER_RESULT" == "success" && "$SUCCESS_RATE" == "100" && "$HAS_SHELL_REPORT" == "true" ]]; then+ TITLE="Omarchy × Midscene · passed"+ RESULT_LINE="**3/3 shell visual checks and all published scenarios passed.**"+ else+ TITLE="Omarchy × Midscene · failure captured"+ RESULT_LINE="**The producing job finished as ${PRODUCER_RESULT}; the latest completed cases are ${SUCCESS_RATE}% passing.**"+ fi++ if [[ "$HAS_SHELL_REPORT" == "true" ]]; then+ REPORT_LINKS="[Omarchy shell report: system menu and bar]($REPORT_URL) · [Onboarding report: install flow]($ONBOARDING_URL) · [Report history]($HISTORY_URL)"+ else+ REPORT_LINKS="[Open the failed Midscene Test report]($REPORT_URL) · [Report history]($HISTORY_URL)"+ fi+cat >> "$GITHUB_STEP_SUMMARY" <<EOF- ## Omarchy × Midscene · 3/3 visual checks passed+ ## $TITLE++ $RESULT_LINE- [Omarchy shell report: system menu and bar]($REPORT_URL) · [Onboarding report: install flow]($ONBOARDING_URL) · [Report history]($HISTORY_URL)+ $REPORT_LINKS[]($REPORT_URL)diff --git a/.github/workflows/midscene-omarchy-4.0.3.yml b/.github/workflows/midscene-omarchy-4.0.3.ymlindex eac4679..6c63e5e 100644--- a/.github/workflows/midscene-omarchy-4.0.3.yml+++ b/.github/workflows/midscene-omarchy-4.0.3.yml@@ -181,3 +181,4 @@ jobs:with:artifact-name: omarchy-midscene-e2e-reportreport-label: Omarchy 4.0.3+ run-result: ${{ needs.omarchy-vm.result }}diff --git a/scripts/build-pages-report.mjs b/scripts/build-pages-report.mjsindex 9b58ff4..5d75ed6 100644--- a/scripts/build-pages-report.mjs+++ b/scripts/build-pages-report.mjs@@ -13,6 +13,7 @@ import {extractShellEvidence,findHtmlFiles,reportDumps,+ testRunDump,} from './omarchy-shell-evidence.mjs';const MANIFEST_VERSION = 1;@@ -273,46 +274,69 @@ export async function buildPagesReport(options) {throw new Error('Site output directory must be empty');}- const htmlFiles = await findHtmlFiles(reportDirectory);- if (htmlFiles.length < 1 || htmlFiles.length > 2) {- throw new Error(- `Expected one or two report HTML files, found ${htmlFiles.length}`,- );- }- const htmlReports = await Promise.all(- htmlFiles.map(async (file) => ({+ const reportCandidates = await Promise.all(+ (await findHtmlFiles(reportDirectory)).map(async (file) => ({file,html: await readFile(file, 'utf8'),})),);- const shellReport = htmlReports.find((report) =>- report.html.includes('The Omarchy system menu is open'),+ const latestByProject = new Map();+ for (const report of reportCandidates) {+ report.run = testRunDump(report.html);+ report.startedAt = Date.parse(report.run?.startedAt ?? '') || 0;+ const projectKey =+ report.run?.projects?.map((project) => project.name).join(',') ||+ path.basename(report.file);+ const previous = latestByProject.get(projectKey);+ if (!previous || report.startedAt >= previous.startedAt) {+ latestByProject.set(projectKey, report);+ }+ }+ const htmlReports = [...latestByProject.values()].sort(+ (left, right) => left.startedAt - right.startedAt,);- if (htmlFiles.length === 2 && !shellReport) {+ if (htmlReports.length < 1 || htmlReports.length > 2) {throw new Error(- 'Two reports were found but the Omarchy shell report is missing',+ `Expected reports for one or two projects, found ${htmlReports.length}`,);}+ const shellReport = htmlReports.find((report) =>+ report.html.includes('The Omarchy system menu is open'),+ );const checks = shellReport? extractShellEvidence(shellReport.html, { allowIncomplete: true }): null;const usage = collectModelUsage(htmlReports.map((report) => report.html).join('\n'),);+ const result = htmlReports.reduce(+ (total, report) => ({+ passed: total.passed + (report.run?.summary?.passed ?? 0),+ tests: total.tests + (report.run?.summary?.total ?? 0),+ }),+ { passed: 0, tests: 0 },+ );+ const isOmarchy = label.startsWith('Omarchy');const reportPrefix = `reports/${runId}`;- const files = htmlFiles.length === 2+ const files = shellReport && htmlReports.length === 2? ['index.html', 'onboarding-report.html', 'report-preview.png'].map((name) => `${reportPrefix}/${name}`)- : [`${reportPrefix}/index.html`];+ : [+ `${reportPrefix}/index.html`,+ ...(isOmarchy ? [`${reportPrefix}/report-preview.png`] : []),+ ];const current = {runId,generatedAt,label,- successRate: checks- ? Math.round(- (checks.filter((check) => check.passed).length / checks.length) * 100,- )- : 100,- testCount: htmlFiles.length === 2 ? 2 : 1,+ successRate: result.tests+ ? Math.round((result.passed / result.tests) * 100)+ : checks+ ? Math.round(+ (checks.filter((check) => check.passed).length / checks.length) *+ 100,+ )+ : 0,+ testCount: result.tests || htmlReports.length,...usage,workflowUrl,reportPath: `reports/${runId}/index.html`,@@ -330,13 +354,19 @@ export async function buildPagesReport(options) {const currentDirectory = path.join(siteDirectory, reportPrefix);await mkdir(currentDirectory, { recursive: true });- if (shellReport) {+ if (shellReport && htmlReports.length === 2) {const onboardingReport = htmlReports.find((report) => report !== shellReport);await copyFile(shellReport.file, path.join(currentDirectory, 'index.html'));await copyFile(onboardingReport.file, path.join(currentDirectory, 'onboarding-report.html'));await copyFile(path.join(reportDirectory, 'report-preview.png'), path.join(currentDirectory, 'report-preview.png'));} else {- await copyFile(htmlFiles[0], path.join(currentDirectory, 'index.html'));+ await copyFile(htmlReports.at(-1).file, path.join(currentDirectory, 'index.html'));+ if (isOmarchy) {+ await copyFile(+ path.join(reportDirectory, 'report-preview.png'),+ path.join(currentDirectory, 'report-preview.png'),+ );+ }}const reports = [current, ...history];diff --git a/scripts/omarchy-shell-evidence.mjs b/scripts/omarchy-shell-evidence.mjsindex c5e53c5..b5641b7 100644--- a/scripts/omarchy-shell-evidence.mjs+++ b/scripts/omarchy-shell-evidence.mjs@@ -74,6 +74,33 @@ export function reportDumps(html) {].map((match) => JSON.parse(normalizeJsonControlCharacters(match[1])));}+export function testRunDump(html) {+ const match = html.match(+ /<script\s+type=["']midscene_test_run_dump["'][^>]*>\s*(\{[\s\S]*?)<\/script>/,+ );+ return match+ ? JSON.parse(normalizeJsonControlCharacters(match[1]))+ : null;+}++export async function findLatestTestReport(directory) {+ const reports = await Promise.all(+ (await findHtmlFiles(directory)).map(async (file) => {+ const html = await readFile(file, 'utf8');+ const run = testRunDump(html);+ return {+ file,+ html,+ run,+ startedAt: Date.parse(run?.startedAt ?? '') || 0,+ };+ }),+ );+ const latest = reports.sort((left, right) => left.startedAt - right.startedAt).at(-1);+ if (!latest) throw new Error('No Midscene Test HTML report found');+ return latest;+}+export function extractShellEvidence(html, { allowIncomplete = false } = {}) {const images = new Map();for (const match of html.matchAll(diff --git a/tests/midscene/capture-report-preview.mjs b/tests/midscene/capture-report-preview.mjsindex 8756dee..122583d 100644--- a/tests/midscene/capture-report-preview.mjs+++ b/tests/midscene/capture-report-preview.mjs@@ -5,8 +5,7 @@ import { pathToFileURL } from 'node:url';import puppeteer from 'puppeteer-core';import {- findShellReport,- normalizeJsonControlCharacters,+ findLatestTestReport,} from '../../scripts/omarchy-shell-evidence.mjs';const reportDirectory = path.resolve(@@ -36,14 +35,9 @@ if (!executablePath) {throw new Error('Chrome executable was not found');}-const shellReport = await findShellReport(reportDirectory);-const runnerDumpMatch = shellReport.html.match(- /<script\s+type=["']midscene_test_run_dump["'][^>]*>\s*(\{[\s\S]*?)<\/script>/,-);-if (!runnerDumpMatch) throw new Error('Midscene Test runner dump was not found');-const runnerDump = JSON.parse(- normalizeJsonControlCharacters(runnerDumpMatch[1]),-);+const report = await findLatestTestReport(reportDirectory);+const runnerDump = report.run;+if (!runnerDump) throw new Error('Midscene Test runner dump was not found');const executedSteps = (runnerDump.projects ?? []).flatMap((project) =>(project.documents ?? []).flatMap((document) =>(document.cases ?? []).flatMap((testCase) =>@@ -54,12 +48,12 @@ const executedSteps = (runnerDump.projects ?? []).flatMap((project) =>),);const finalStep = executedSteps.at(-1);-if (!finalStep) throw new Error('Midscene Test report has no executed steps');--const previewUrl = new URL(pathToFileURL(shellReport.file));-const previewHash = new URLSearchParams({ 'runner-step': finalStep.id });-if (finalStep.agentDetails?.length) previewHash.set('runner-trace', 'page');-previewUrl.hash = previewHash.toString();+const previewUrl = new URL(pathToFileURL(report.file));+if (finalStep) {+ const previewHash = new URLSearchParams({ 'runner-step': finalStep.id });+ if (finalStep.agentDetails?.length) previewHash.set('runner-trace', 'page');+ previewUrl.hash = previewHash.toString();+}await mkdir(path.dirname(outputFile), { recursive: true });const browser = await puppeteer.launch({@@ -74,10 +68,10 @@ try {await page.goto(previewUrl.href, {waitUntil: 'networkidle0',});- if (finalStep.agentDetails?.length) {+ if (finalStep?.agentDetails?.length) {await page.waitForFunction(() => document.body.innerText.includes('AI TRACE'));await page.evaluate(() => window.scrollTo(0, 0));- } else {+ } else if (finalStep) {await page.waitForSelector('[aria-label="Execution steps"]');}await page.waitForFunction(() =>@@ -85,7 +79,7 @@ try {);await page.screenshot({ path: outputFile, type: 'png' });console.log(- `Captured final Midscene report node (${finalStep.status}): ${outputFile}`,+ `Captured final Midscene report node (${finalStep?.status ?? runnerDump.status}): ${outputFile}`,);} finally {await browser.close();diff --git a/tests/test_pages_report_history.mjs b/tests/test_pages_report_history.mjsindex 7559099..ff51d75 100644--- a/tests/test_pages_report_history.mjs+++ b/tests/test_pages_report_history.mjs@@ -7,10 +7,24 @@ import test from 'node:test';import { buildPagesReport } from '../scripts/build-pages-report.mjs';+function runnerScript({ project, status = 'success', startedAt }) {+ return `<script type="midscene_test_run_dump">${JSON.stringify({+ startedAt,+ status,+ summary: {+ total: 1,+ passed: status === 'success' ? 1 : 0,+ failed: status === 'success' ? 0 : 1,+ },+ projects: [{ name: project }],+ })}</script>`;+}+const fixtureHtml = `<!doctype html><html><body>report<script type="midscene_web_dump">{"usage":{"_midscene_call_id":"call-1","time_cost":2500,"total_tokens":120}}</script><script type="midscene_web_dump">{"message":"rawcontrol character","usage":{"_midscene_call_id":"call-2","time_cost":3500,"total_tokens":180}}</script>+${runnerScript({ project: 'ubuntu-onboarding', startedAt: '2026-09-15T12:00:00Z' })}</body></html>`;const shellPrompts = [@@ -38,7 +52,7 @@ const shellFixtureHtml = `<!doctype html><html><body>${shellPrompts})}</script><script type="midscene-image" data-id="image-${index}">data:image/jpeg;base64,/9j/2Q==</script>`,)- .join('')}</body></html>`;+ .join('')}${runnerScript({ project: 'omarchy-shell', startedAt: '2026-09-15T12:05:00Z' })}</body></html>`;async function fixtureDirectory(root) {const reportDirectory = path.join(root, 'artifact', 'report');@@ -154,7 +168,12 @@ test('publishes a failed shell report with its result in history', async (contexconst reportDirectory = await fixtureDirectory(root);await writeFile(path.join(reportDirectory, 'report', 'test-run-shell.html'),- shellFixtureHtml.replace('"output":true', '"output":false'),+ shellFixtureHtml+ .replace('"output":true', '"output":false')+ .replace(+ '"status":"success","summary":{"total":1,"passed":1,"failed":0}',+ '"status":"failed","summary":{"total":1,"passed":0,"failed":1}',+ ),);await writeFile(path.join(reportDirectory, 'report-preview.png'), 'failed');const siteDirectory = path.join(root, 'site');@@ -167,7 +186,7 @@ test('publishes a failed shell report with its result in history', async (contexoptions(reportDirectory, siteDirectory, server.url),);- assert.equal(manifest.reports[0].successRate, 67);+ assert.equal(manifest.reports[0].successRate, 50);assert.equal(await readFile(path.join(siteDirectory, 'reports', '200', 'report-preview.png'),@@ -177,6 +196,42 @@ test('publishes a failed shell report with its result in history', async (contex);});+test('keeps only the latest failed retry for an Omarchy project', async (context) => {+ const root = await mkdtemp(path.join(os.tmpdir(), 'pages-retries-'));+ const reportDirectory = path.join(root, 'artifact');+ const reportPath = path.join(reportDirectory, 'report');+ await mkdir(reportPath, { recursive: true });+ const firstFailure = `<!doctype html><html><body>first failure${runnerScript({ project: 'omarchy-onboarding', status: 'failed', startedAt: '2026-09-15T13:00:00Z' })}</body></html>`;+ const finalFailure = `<!doctype html><html><body>final failure${runnerScript({ project: 'omarchy-onboarding', status: 'failed', startedAt: '2026-09-15T14:00:00Z' })}</body></html>`;+ await writeFile(path.join(reportPath, 'test-run-retry-1.html'), firstFailure);+ await writeFile(path.join(reportPath, 'test-run-retry-2.html'), finalFailure);+ await writeFile(path.join(reportDirectory, 'report-preview.png'), 'failed');+ const siteDirectory = path.join(root, 'site');+ const server = await startServer((_request, response) =>+ response.writeHead(404).end(),+ );+ context.after(server.close);++ const manifest = await buildPagesReport({+ ...options(reportDirectory, siteDirectory, server.url),+ label: 'Omarchy 4.0.3',+ });++ assert.equal(manifest.reports[0].successRate, 0);+ assert.equal(manifest.reports[0].testCount, 1);+ assert.deepEqual(manifest.reports[0].files, [+ 'reports/200/index.html',+ 'reports/200/report-preview.png',+ ]);+ assert.equal(+ await readFile(+ path.join(siteDirectory, 'reports', '200', 'index.html'),+ 'utf8',+ ),+ finalFailure,+ );+});+test('restores retained history before adding the new run', async (context) => {const root = await mkdtemp(path.join(os.tmpdir(), 'pages-history-'));const reportDirectory = await fixtureDirectory(root);