ci: remove development-only bootstrap tests
diff --git a/.github/intentional-ci.md b/.github/intentional-ci.md index 69fe20f..cab0d59 100644 --- a/.github/intentional-ci.md +++ b/.github/intentional-ci.md
@@ -41,9 +41,3 @@ Implementation changes can stay on the development branch while the listener and ordinary workflows on `master` remain stable. Submit the completed design and any proposed project-wide rollout together for review. - -Run the listener regression tests locally with: - -```sh -node --test .github/tests/intentional-ci.test.cjs -```
diff --git a/.github/tests/intentional-ci.test.cjs b/.github/tests/intentional-ci.test.cjs deleted file mode 100644 index 0f4d287..0000000 --- a/.github/tests/intentional-ci.test.cjs +++ /dev/null
@@ -1,96 +0,0 @@ -const assert = require('node:assert/strict'); -const fs = require('node:fs'); -const path = require('node:path'); -const {test} = require('node:test'); - -// Exercise the actual inline github-script without checking out or running PR code. -const workflow = fs.readFileSync(path.join(__dirname, '../workflows/intentional-ci.yml'), 'utf8'); -const block = workflow.match(/ script: \|\n((?: .*\n|\n)+)/)[1]; -const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; -const dispatch = new AsyncFunction('github', 'context', 'core', - block.split('\n').map(line => line.slice(12)).join('\n')); - -async function run({command = '/ci full', pr = {}, commenter = 'rwgk', status} = {}) { - const requests = []; - const failures = []; - const summaries = []; - const summary = { - addHeading(value) { summaries.push(value); return this; }, - addRaw() { return this; }, - addCodeBlock() { return this; }, - async write() {}, - }; - const github = {rest: { - pulls: {async get() { return {data: { - number: 123, state: 'open', user: {login: 'rwgk'}, - labels: [{name: 'ci:intentional'}], - head: {sha: '1'.repeat(40)}, base: {sha: '2'.repeat(40)}, ...pr, - }}; }}, - actions: {async createWorkflowDispatch(request) { - if (status) throw Object.assign(new Error('API failure'), {status}); - requests.push(request); - }}, - }}; - const context = { - repo: {owner: 'pybind', repo: 'pybind11'}, issue: {number: 123}, - payload: {comment: {body: command, id: 456, user: {login: commenter}}}, - }; - await dispatch(github, context, {summary, setFailed(message) { failures.push(message); }}); - return {requests, failures, summaries}; -} - -for (const profile of ['full', 'quick']) { - test(`dispatch ${profile} with frozen revisions to the fixed worker`, async () => { - const {requests} = await run({command: `/ci ${profile}`}); - assert.equal(requests.length, 1); - const {inputs, ...destination} = requests[0]; - assert.deepEqual(destination, { - owner: 'pybind', repo: 'pybind11', workflow_id: 'intentional-ci.yml', - ref: 'intentional-ci-experiment', - }); - assert.deepEqual(JSON.parse(inputs.request), { - pr: 123, profile, head_sha: '1'.repeat(40), base_sha: '2'.repeat(40), comment_id: 456, - }); - }); -} - -for (const command of ['/ci', '/ci all', '/ci full extra', '> /ci full', '/ci full\nplease', '/ci full; echo unsafe']) { - test(`ignore unrecognized command ${JSON.stringify(command)}`, async () => { - assert.deepEqual((await run({command})).requests, []); - }); -} - -for (const pr of [{state: 'closed'}, {user: {login: 'someone-else'}}, {labels: []}, {labels: [{name: 'ci:manual'}]}]) { - test(`ignore PR outside the pilot: ${JSON.stringify(pr)}`, async () => { - assert.deepEqual((await run({pr})).requests, []); - }); -} - -test('other PR authors can request CI on their own opted-in PRs', async () => { - const result = await run({commenter: 'contributor', pr: {user: {login: 'contributor'}}}); - assert.equal(result.requests.length, 1); - assert.deepEqual(result.failures, []); -}); - -test('reject requests from someone other than the PR author', async () => { - assert.deepEqual((await run({commenter: 'someone-else'})).requests, []); -}); - -test('help explains the pilot without dispatching', async () => { - const result = await run({command: '/ci help'}); - assert.deepEqual(result.requests, []); - assert.deepEqual(result.summaries, ['Intentional CI experiment']); -}); - -for (const status of [404, 422]) { - test(`missing or incompatible worker fails clearly (${status})`, async () => { - const result = await run({status}); - assert.deepEqual(result.requests, []); - assert.match(result.failures[0], /intentional-ci-experiment/); - assert.deepEqual(result.summaries, []); - }); -} - -test('unexpected API errors propagate', async () => { - await assert.rejects(run({status: 503}), /API failure/); -});
diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index bfbbb94..76d64ad 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml
@@ -34,9 +34,6 @@ run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json" - uses: pre-commit/action@v3.0.1 - - name: Test intentional CI bootstrap - run: node --test .github/tests/intentional-ci.test.cjs - clang-tidy: if: (github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'ci:intentional')) # When making changes here, please also review the "Clang-Tidy" section