Skip to content

Commit 443bcd4

Browse files
committed
fixing release flow
1 parent b713bf7 commit 443bcd4

2 files changed

Lines changed: 57 additions & 20 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ jobs:
118118
runs-on: ubuntu-latest
119119
steps:
120120
- uses: actions/checkout@v7
121+
with:
122+
# This job runs the built terminal tests, which assert the CLI renders
123+
# the latest stable release tag found via `git tag --merged HEAD`. The
124+
# default shallow checkout fetches no tags.
125+
fetch-depth: 0
121126

122127
- name: Setup Bun
123128
uses: oven-sh/setup-bun@v2

‎tests/ci/workflowCheckout.test.ts‎

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,72 @@
33
* Copyright 2026 Autohand AI LLC
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
import { readFileSync } from 'node:fs';
6+
import { readdirSync, readFileSync } from 'node:fs';
77
import path from 'node:path';
88
import { describe, expect, it } from 'vitest';
99

10-
const WORKFLOW_PATH = path.resolve(import.meta.dirname, '../../.github/workflows/ci.yml');
10+
const WORKFLOW_DIR = path.resolve(import.meta.dirname, '../../.github/workflows');
1111

12-
function readWorkflow(): string {
13-
return readFileSync(WORKFLOW_PATH, 'utf8');
12+
interface WorkflowJob {
13+
workflow: string;
14+
name: string;
15+
body: string;
16+
}
17+
18+
/** Split every workflow into its top-level jobs, keyed by `<file>:<job>`. */
19+
function readWorkflowJobs(): WorkflowJob[] {
20+
const jobs: WorkflowJob[] = [];
21+
22+
for (const file of readdirSync(WORKFLOW_DIR).filter((name) => name.endsWith('.yml'))) {
23+
const contents = readFileSync(path.join(WORKFLOW_DIR, file), 'utf8');
24+
const jobsIndex = contents.indexOf('\njobs:');
25+
if (jobsIndex === -1) continue;
26+
27+
const body = contents.slice(jobsIndex);
28+
// Job names sit at exactly two spaces of indentation under `jobs:`.
29+
const headers = [...body.matchAll(/^ {2}([A-Za-z0-9_-]+):$/gmu)];
30+
for (const [index, header] of headers.entries()) {
31+
const start = header.index!;
32+
const end = headers[index + 1]?.index ?? body.length;
33+
jobs.push({ workflow: file, name: header[1]!, body: body.slice(start, end) });
34+
}
35+
}
36+
37+
return jobs;
38+
}
39+
40+
function hasFullHistoryCheckout(job: WorkflowJob): boolean {
41+
return /actions\/checkout@v\d+\s*\n\s*with:\s*\n(?:\s*#[^\n]*\n)*\s*fetch-depth:\s*0/u.test(job.body);
1442
}
1543

1644
/**
1745
* Regression: the Tuistory suite asserts the CLI renders the latest stable
1846
* release tag, which it discovers with `git tag --merged HEAD`. actions/checkout
19-
* fetches no tags by default, so the job failed in CI while passing locally
20-
* against a full clone.
47+
* fetches no tags by default, so those jobs failed in CI while passing locally
48+
* against a full clone. This was originally fixed in ci.yml alone, and the
49+
* release workflow kept failing because it runs the same suite from its own job.
2150
*/
2251
describe('CI workflow checkout', () => {
23-
it('fetches full history for the job that runs the built terminal tests', () => {
24-
const workflow = readWorkflow();
25-
const testJob = workflow.slice(
26-
workflow.indexOf(' test:'),
27-
workflow.indexOf(' build-test:'),
28-
);
29-
30-
expect(testJob).toContain('bun run test:tuistory');
31-
expect(testJob).toMatch(/actions\/checkout@v\d+\s*\n\s*with:\s*\n(?:\s*#[^\n]*\n)*\s*fetch-depth:\s*0/);
52+
it('finds at least one job running the built terminal tests', () => {
53+
const tuistoryJobs = readWorkflowJobs().filter((job) => job.body.includes('test:tuistory'));
54+
expect(tuistoryJobs.length).toBeGreaterThan(0);
3255
});
3356

34-
it('keeps every checkout in the workflow pinned to a major version', () => {
35-
const checkouts = readWorkflow().match(/actions\/checkout@v\d+/g) ?? [];
57+
it('fetches full history in every job that runs the built terminal tests', () => {
58+
const offenders = readWorkflowJobs()
59+
.filter((job) => job.body.includes('test:tuistory'))
60+
.filter((job) => !hasFullHistoryCheckout(job))
61+
.map((job) => `${job.workflow}:${job.name}`);
62+
63+
expect(offenders).toEqual([]);
64+
});
3665

37-
expect(checkouts.length).toBeGreaterThan(0);
38-
for (const checkout of checkouts) {
39-
expect(checkout).toMatch(/actions\/checkout@v\d+$/);
66+
it('keeps every checkout pinned to a major version', () => {
67+
for (const file of readdirSync(WORKFLOW_DIR).filter((name) => name.endsWith('.yml'))) {
68+
const contents = readFileSync(path.join(WORKFLOW_DIR, file), 'utf8');
69+
for (const checkout of contents.match(/actions\/checkout@[^\s]+/gu) ?? []) {
70+
expect(checkout, `${file} pins ${checkout}`).toMatch(/actions\/checkout@v\d+$/u);
71+
}
4072
}
4173
});
4274
});

0 commit comments

Comments
 (0)