background tests: ci.yml runs the CI and the acceptance matrix on every push again but nothing waits for them (the gate no longer waits for the parent's run, which a release's own bump push cancels; the record job needs only the installers); tools/ci-status.ts reports main's newest test run and release.ts prints a red one as a warning

This commit is contained in:
CRTkafa 2026-10-16 07:17:19 +08:00
parent b84538e4cb
commit 9059b2b32a
5 changed files with 69 additions and 10 deletions

12
tests/ci-status.test.ts Normal file
View file

@ -0,0 +1,12 @@
import { expect, test } from 'bun:test';
import { testState } from '../tools/ci-status';
const t = (name: string, status: string, run: number, sha: string) => ({ id: 1, name, run_number: run, workflow_id: 'ci.yml', head_sha: sha, status });
const url = (n: number) => `run/${n}`;
test('background test state: newest commit with test jobs; a cancelled run falls back to the older commit', () => {
expect(testState([t('ci', 'success', 2, 'b'), t('acceptance (bun)', 'failure', 2, 'b'), t('linux', 'success', 2, 'b')], ['b'], url)).toEqual({ sha: 'b', run: 'run/2', state: 'red', failed: ['acceptance (bun)'], running: [] });
expect(testState([t('ci', 'cancelled', 3, 'c'), t('ci', 'success', 2, 'b')], ['c', 'b'], url).state).toBe('green');
expect(testState([t('ci', 'running', 3, 'c')], ['c'], url)).toMatchObject({ state: 'running', running: ['ci'] });
expect(testState([t('linux', 'success', 3, 'c')], ['c'], url).state).toBe('none');
});