Skip to content

Commit 5097150

Browse files
committed
fix(release): read the Homebrew lane version from the formula's version stanza
1 parent 0f518b5 commit 5097150

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

‎scripts/release/release-status.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async function fetchText(fetchImpl, url, label, init = {}) {
8383
}
8484

8585
function brewFormulaVersion(formula) {
86-
const match = typeof formula === 'string' ? /pythinker-code-(\d+\.\d+\.\d+)\.tgz/u.exec(formula) : null;
86+
const match = typeof formula === 'string' ? /^\s*version "([^"]+)"\s*$/mu.exec(formula) : null;
8787
return match === null ? undefined : validVersion(match[1]);
8888
}
8989

‎scripts/release/release-status.test.mjs‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,30 @@ function json(body, status = 200) {
4747
});
4848
}
4949

50+
function brewFormulaText(version) {
51+
const tag = encodeURIComponent(`@pymodel/pythinker-code@${version}`);
52+
return [
53+
'class PythinkerCode < Formula',
54+
` version "${version}"`,
55+
` url "https://github.com/PyModel/pythinker-code/releases/download/${tag}/pythinker-code-darwin-arm64.tar.gz"`,
56+
'',
57+
].join('\n');
58+
}
59+
5060
function fixtureFetch({
5161
cliAssets = expectedCliAssets,
5262
nightlyAssets = desktopAssets(desktopNightlyVersion, 'nightly'),
5363
brewVersion = '1.3.0',
64+
brewFormula,
5465
} = {}) {
5566
return async (input) => {
5667
const url = new URL(String(input));
5768
if (url.hostname === 'registry.npmjs.org') return json({ latest: '1.3.0' });
5869
if (url.hostname === 'raw.githubusercontent.com') {
59-
return new Response(
60-
`url "https://registry.npmjs.org/@pymodel/pythinker-code/-/pythinker-code-${brewVersion}.tgz"\n`,
61-
{ status: 200, headers: { 'content-type': 'text/plain' } },
62-
);
70+
return new Response(brewFormula ?? brewFormulaText(brewVersion), {
71+
status: 200,
72+
headers: { 'content-type': 'text/plain' },
73+
});
6374
}
6475
if (url.hostname === 'code.pythinker.com') {
6576
return json({
@@ -165,6 +176,21 @@ void test('fails when the Homebrew formula lags the published CLI version', asyn
165176
assert.equal(brew?.observed, '1.2.0');
166177
});
167178

179+
void test('fails when the Homebrew formula has no version stanza', async (t) => {
180+
const rootDir = await fixtureRoot(t);
181+
const result = await collectReleaseStatus({
182+
rootDir,
183+
desktopCommitCount,
184+
fetchImpl: fixtureFetch({ brewFormula: 'class PythinkerCode < Formula\n' }),
185+
});
186+
187+
assert.equal(result.ok, false);
188+
const brew = result.rows.find((row) => row.lane === 'Homebrew');
189+
assert.equal(brew?.ok, false);
190+
assert.equal(brew?.observed, 'unavailable');
191+
assert.match(brew?.details ?? '', /no pythinker-code tarball version/u);
192+
});
193+
168194
void test('fails when the current desktop Nightly release is incomplete', async (t) => {
169195
const rootDir = await fixtureRoot(t);
170196
const result = await collectReleaseStatus({

0 commit comments

Comments
 (0)