Skip to content

Commit f066593

Browse files
committed
test(ui): judge the published-dist no-per-PR-build pin per job, and pin the full-battery carrier
The ruling on objectui#4846 forbade a per-PR full-repo build. The pin read it per workflow FILE, which a full-battery job in ci.yml (a file that subscribes pull_request) cannot satisfy although it costs a pull request nothing. It now reads each job of a per-PR or queue workflow: a job that runs the scan must deny both events in its own if:. The retired "runs nightly" pin comes back against the root job that schedules the scan. Claude-Session: https://claude.ai/code/session_01ADHkmNiJfZmoXAbfcJSAfx Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3b48507 commit f066593

1 file changed

Lines changed: 42 additions & 10 deletions

File tree

‎ui/scripts/__tests__/check-published-dist-tooling.test.ts‎

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
packedFiles,
2020
toolingConventionFrom,
2121
} from '../check-published-dist-tooling.mjs';
22-
import { rootWorkflow, rootWorkflowFiles } from './helpers/root-ci';
22+
import { jobBlock, rootCi, rootWorkflow, rootWorkflowFiles, uiRun, withoutComments } from './helpers/root-ci';
2323

2424
/**
2525
* objectui#4846 — no published package's build output may carry tooling material.
@@ -473,20 +473,52 @@ describe('wiring', () => {
473473
);
474474
});
475475

476-
// `runs nightly` retired with objectstack#25712. It read objectui's
477-
// `published-dist-gate.yml`, which runs nowhere under the monorepo: GitHub
478-
// runs the root `.github/workflows/` alone. That workflow is row 23 of the
479-
// objectstack#25697 workflow roster, "kept, follow-up port", and the port
480-
// brings the pin back against the root file that schedules the scan.
476+
// The full-battery half (objectstack#26717). objectui scheduled the scan
477+
// nightly in `published-dist-gate.yml` (roster row 23 of objectstack#25697);
478+
// under the monorepo it runs in root `ci.yml`'s `ui-published-artifacts` job,
479+
// which a pull request and a queue entry skip, over the release's own build.
480+
const FULL_BATTERY_JOB = 'ui-published-artifacts';
481+
const PER_PR_EVENTS = ['pull_request', 'merge_group'];
481482

482-
it('is NOT wired into any per-PR workflow — the ruling forbade a per-PR full-repo build', () => {
483+
/** A job's own `if:` line, at the job's indent; '' when it has none. */
484+
const jobIf = (block: string) => block.match(/^ {4}if: (.*)$/m)?.[1] ?? '';
485+
const deniesPerPrEvents = (condition: string) =>
486+
PER_PR_EVENTS.every((event) => condition.includes(`github.event_name != '${event}'`));
487+
488+
it("runs in ci.yml's full battery, after the release's build, with --no-build", () => {
489+
const block = withoutComments(jobBlock(rootCi(), FULL_BATTERY_JOB));
490+
expect(block).toContain(`run: ${uiRun('check:published-dist')} --no-build`);
491+
expect(block.indexOf('run: pnpm build\n')).toBeGreaterThan(-1);
492+
expect(block.indexOf('run: pnpm build\n')).toBeLessThan(block.indexOf(uiRun('check:published-dist')));
493+
expect(deniesPerPrEvents(jobIf(block)), jobIf(block)).toBe(true);
494+
});
495+
496+
it('is NOT run by any per-PR or queue job — the ruling forbade a per-PR full-repo build', () => {
483497
// Asked of the root `.github/workflows/`, the only workflows GitHub runs
484-
// under the monorepo (objectstack#25712); `ui/.github/` runs nowhere.
485-
const perPr = rootWorkflowFiles().filter((file) => /^on:[\s\S]*?\bpull_request:/m.test(rootWorkflow(file)));
498+
// under the monorepo (objectstack#25712); `ui/.github/` runs nowhere. A
499+
// workflow that subscribes a per-PR event may carry the scan only in a job
500+
// whose own `if:` denies both of them: the ruling is about the build a
501+
// pull request pays for, and such a job costs it nothing.
502+
const perPr = rootWorkflowFiles().filter((file) =>
503+
new RegExp(`^on:[\\s\\S]*?\\b(${PER_PR_EVENTS.join('|')}):`, 'm').test(rootWorkflow(file)),
504+
);
486505
expect(perPr.length).toBeGreaterThan(0); // the scan itself must not be empty
506+
let carriers = 0;
487507
for (const file of perPr) {
488508
const text = rootWorkflow(file);
489-
expect(text.includes(GATE) || text.includes('check:published-dist'), file).toBe(false);
509+
const jobsAt = text.search(/^jobs:[ \t]*$/m);
510+
expect(jobsAt, file).toBeGreaterThan(-1);
511+
const keys = [...text.slice(jobsAt).matchAll(/^ {2}([a-z0-9][a-z0-9_-]*):[ \t]*$/gm)].map((m) => m[1]);
512+
expect(keys.length, file).toBeGreaterThan(0);
513+
for (const key of keys) {
514+
const block = withoutComments(jobBlock(text, key));
515+
if (!block.includes(GATE) && !block.includes('check:published-dist')) continue;
516+
carriers += 1;
517+
expect(deniesPerPrEvents(jobIf(block)), `${file} job ${key}: if: ${jobIf(block)}`).toBe(true);
518+
}
490519
}
520+
// The carrier the case above pins is seen here too, so this loop cannot
521+
// pass by reading no job at all.
522+
expect(carriers).toBeGreaterThan(0);
491523
});
492524
});

0 commit comments

Comments
 (0)