ktx/scripts/standalone-ci-workflow.test.mjs

90 lines
3.1 KiB
JavaScript
Raw Permalink Normal View History

2026-05-10 23:12:26 +02:00
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { describe, it } from 'node:test';
async function readText(relativePath) {
return readFile(new URL(`../${relativePath}`, import.meta.url), 'utf8');
}
function assertIncludesAll(text, values) {
for (const value of values) {
assert.match(text, new RegExp(value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
}
}
2026-05-10 23:51:24 +02:00
describe('standalone KTX CI workflow', () => {
2026-05-12 01:44:15 +02:00
it('runs package checks in parallel jobs from the repository root', async () => {
2026-05-10 23:12:26 +02:00
const workflow = await readText('.github/workflows/ci.yml');
2026-05-10 23:51:24 +02:00
assert.match(workflow, /^name: KTX CI/m);
2026-05-10 23:12:26 +02:00
assertIncludesAll(workflow, [
'permissions:',
'contents: read',
'pre-commit-checks:',
'name: Pre-commit checks',
2026-05-12 01:44:15 +02:00
'typescript-checks:',
'name: TypeScript checks',
'slow-context-tests:',
'name: Slow context tests',
'slow-cli-tests:',
'name: Slow CLI tests',
'cli-smoke-tests:',
'name: CLI smoke tests',
'python-checks:',
'name: Python checks',
'artifact-checks:',
'name: Artifact checks',
2026-05-10 23:12:26 +02:00
'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd',
'pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093',
2026-05-12 01:44:15 +02:00
'actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e',
2026-05-10 23:12:26 +02:00
'node-version: "24"',
'cache-dependency-path: "pnpm-lock.yaml"',
'pnpm install --frozen-lockfile',
'pnpm run check',
2026-05-12 01:44:15 +02:00
'pnpm run build',
'pnpm --filter @ktx/context run test:slow',
'pnpm --filter @ktx/cli run test:slow',
'pnpm run smoke',
2026-05-10 23:12:26 +02:00
'actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405',
'python-version: "3.13"',
2026-05-12 01:44:15 +02:00
'astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b',
'version: "0.11.11"',
2026-05-10 23:12:26 +02:00
'cache-dependency-glob: "uv.lock"',
'uv sync --all-packages --all-groups',
'uv run pre-commit run --all-files',
2026-05-10 23:12:26 +02:00
'uv sync --all-packages',
'uv run pytest',
'pnpm run artifacts:check',
]);
assert.doesNotMatch(workflow, /sparse-checkout/);
2026-05-10 23:51:24 +02:00
assert.doesNotMatch(workflow, /cd ktx/);
assert.doesNotMatch(workflow, /ktx\/pnpm-lock\.yaml/);
assert.doesNotMatch(workflow, /ktx\/uv\.lock/);
2026-05-12 01:44:15 +02:00
assert.doesNotMatch(workflow, /run: pnpm run test:slow/);
2026-05-10 23:12:26 +02:00
});
it('uploads verified artifacts from root-relative paths', async () => {
const workflow = await readText('.github/workflows/ci.yml');
assertIncludesAll(workflow, [
2026-05-12 01:44:15 +02:00
'actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a',
2026-05-10 23:51:24 +02:00
'name: ktx-package-artifacts-${{ github.sha }}',
2026-05-10 23:12:26 +02:00
'dist/artifacts/manifest.json',
'dist/artifacts/npm/*.tgz',
'dist/artifacts/python/*.whl',
'dist/artifacts/python/*.tar.gz',
'if-no-files-found: error',
'retention-days: 7',
]);
2026-05-10 23:51:24 +02:00
assert.doesNotMatch(workflow, /ktx\/dist\/artifacts/);
2026-05-10 23:12:26 +02:00
});
it('syncs injected workspace packages after package builds', async () => {
const workspace = await readText('pnpm-workspace.yaml');
assert.match(workspace, /syncInjectedDepsAfterScripts:\n\s+- build/);
});
});