Files
Vito 3d32e9183a ci: one single-pass gate on the pull request, the rest nightly (#666) (#667)
* ci: one single-pass gate on the pull request, the rest nightly (#666)

A change was tested twice: on the pull request and again in the merge
queue, which added Firefox, WebKit, Python 3.13/3.14 and real ComfyUI.
Of the last 50 queue entries 9 failed, none because of the change.

- ci.yml is the gate, on pull_request and workflow_dispatch only: the
  Python 3.12 suite once under the 85% coverage gate, black/flake8,
  bandit, frontend modules, tooling tests and pins, desktop Chromium
  page workflows with frontend coverage, and one required context,
  gate, that fails unless every job did what the change class asks.
- nightly.yml runs Firefox, WebKit, touch, Python 3.13/3.14, Windows,
  native trash, real ComfyUI and the perf budget, and reports by issue:
  one per failing job, closed by the next green run.
- No workflow has a merge_group trigger; a push to main starts only
  publish.yml, which now has a time limit.
- Change classes: docs and inert run only the classifier and gate; a
  release (only the version line of pyproject.toml) runs the
  package-content check; everything else runs the gate.
- @quarantine: left out of the gate, still run nightly. No retries in
  the gate; nightly retries once and lists flaky tests in the summary.
- Frontend coverage is measured with Chromium alone; every floor holds.
- branch-protection.json requires gate, strict.

test.yml, viewerjs-check.yml, portability.yml and code-quality.yml are
deleted.

* style(ci): make the nightly report's joined sentence one explicit item (#666)
2026-11-21 08:31:13 -08:00

57 lines
4.1 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
// Concept comparisons measure layout, and layout depends on the fonts a browser falls back to (the concept names Inter,
// which neither environment ships). Page-workflow jobs therefore run in the same pinned Playwright image as local runs,
// so CI and a developer machine resolve identical fonts and engines.
const workflows = {
'frontend-coverage': readFileSync(new URL('../../.github/workflows/ci.yml', import.meta.url), 'utf8'),
'browser-workflows': readFileSync(new URL('../../.github/workflows/nightly.yml', import.meta.url), 'utf8'),
};
const lock = JSON.parse(readFileSync(new URL('../../tools/vendor/package-lock.json', import.meta.url), 'utf8'));
const version = lock.packages['node_modules/@playwright/test'].version;
// The tag alone is not a pin: v1.64.1-noble was re-pushed with Node 26 (#609). The digest fixes the image's contents.
const pinnedImage = `^ container:\\n image: mcr\\.microsoft\\.com/playwright:v${version.replaceAll('.', '\\.')}-noble@sha256:[0-9a-f]{64}$`;
function job(name) {
const match = workflows[name].match(new RegExp(`^ ${name}:\\n([\\s\\S]*?)(?=^ [a-z][a-z-]*:\\n|(?![\\s\\S]))`, 'm'));
assert.ok(match, `${name} job exists`);
return match[1];
}
for (const name of Object.keys(workflows)) {
test(`${name} runs in the pinned Playwright image matching @playwright/test`, () => {
const body = job(name);
assert.match(body, new RegExp(pinnedImage, 'm'));
assert.doesNotMatch(body, /playwright install/, 'browsers and their fonts come from the image, not a runner install');
// Toolcache interpreters are the runner's own builds: their entry points name host paths that do not exist in
// the container (setup-python failed with `spawn .../bin/pip ENOENT`). Use the image's Python and Node.
assert.doesNotMatch(body, /actions\/setup-(python|node)@/);
assert.match(body, /python3 -m venv --without-pip /, 'a user-space venv on the image Python (no ensurepip, no root)');
assert.match(body, /sha256sum -c/, 'the pip wheel that bootstraps the venv is checksum-pinned');
assert.match(body, /node --version \| grep -q '\^v24\\\.'/, 'the image Node is the Node 24 the project requires');
});
}
// The real-host job drives Chromium against a managed ComfyUI. `playwright install --with-deps` pulled the browser's
// system packages from Ubuntu's apt mirror on every run, and three runs (#349, #378, #382) crawled at ~26 kB/s until
// the job hit its limit after every test had passed. The pinned image ships Chromium and its libraries, so the job runs
// there; the image Python must be the reviewed host Python from tools/vendor/comfyui-runtime.json.
test('real ComfyUI compatibility runs in the pinned Playwright image on the reviewed host Python', () => {
const testWorkflow = workflows['browser-workflows'];
const runtime = JSON.parse(readFileSync(new URL('../../tools/vendor/comfyui-runtime.json', import.meta.url), 'utf8'));
const match = testWorkflow.match(/^ {2}comfyui:\n([\s\S]*?)(?=^ {2}[a-z][a-z-]*:\n|(?![\s\S]))/m);
assert.ok(match, 'comfyui job exists');
const body = match[1];
assert.match(body, new RegExp(pinnedImage, 'm'));
assert.doesNotMatch(body, /playwright install/, 'Chromium and its system libraries come from the image, not apt');
assert.doesNotMatch(body, /apt-get|actions\/setup-(python|node)@/);
assert.match(body, /python3 -m venv --without-pip /, 'a user-space venv on the image Python');
assert.match(body, /sha256sum -c/, 'the pip wheel that bootstraps the venv is checksum-pinned');
assert.match(body, /node --version \| grep -q '\^v24\\\.'/, 'the image Node is Node 24');
// The image Python is checked against the pin at run time, so a pin or image bump that disagrees fails loudly.
assert.match(body, /steps\.runtime\.outputs\.pythonVersion/, 'the job compares the image Python with the reviewed pin');
assert.match(runtime.pythonVersion, /^3\.12$/, 'the reviewed host Python is the image Python (3.12 on noble)');
});