Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/release/release-status.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async function fetchText(fetchImpl, url, label, init = {}) {
}

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

Expand Down
34 changes: 30 additions & 4 deletions scripts/release/release-status.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,30 @@ function json(body, status = 200) {
});
}

function brewFormulaText(version) {
const tag = encodeURIComponent(`@pymodel/pythinker-code@${version}`);
return [
'class PythinkerCode < Formula',
` version "${version}"`,
` url "https://github.com/PyModel/pythinker-code/releases/download/${tag}/pythinker-code-darwin-arm64.tar.gz"`,
'',
].join('\n');
}

function fixtureFetch({
cliAssets = expectedCliAssets,
nightlyAssets = desktopAssets(desktopNightlyVersion, 'nightly'),
brewVersion = '1.3.0',
brewFormula,
} = {}) {
return async (input) => {
const url = new URL(String(input));
if (url.hostname === 'registry.npmjs.org') return json({ latest: '1.3.0' });
if (url.hostname === 'raw.githubusercontent.com') {
return new Response(
`url "https://registry.npmjs.org/@pymodel/pythinker-code/-/pythinker-code-${brewVersion}.tgz"\n`,
{ status: 200, headers: { 'content-type': 'text/plain' } },
);
return new Response(brewFormula ?? brewFormulaText(brewVersion), {
status: 200,
headers: { 'content-type': 'text/plain' },
});
}
if (url.hostname === 'code.pythinker.com') {
return json({
Expand Down Expand Up @@ -165,6 +176,21 @@ void test('fails when the Homebrew formula lags the published CLI version', asyn
assert.equal(brew?.observed, '1.2.0');
});

void test('fails when the Homebrew formula has no version stanza', async (t) => {
const rootDir = await fixtureRoot(t);
const result = await collectReleaseStatus({
rootDir,
desktopCommitCount,
fetchImpl: fixtureFetch({ brewFormula: 'class PythinkerCode < Formula\n' }),
});

assert.equal(result.ok, false);
const brew = result.rows.find((row) => row.lane === 'Homebrew');
assert.equal(brew?.ok, false);
assert.equal(brew?.observed, 'unavailable');
assert.match(brew?.details ?? '', /no pythinker-code tarball version/u);
});

void test('fails when the current desktop Nightly release is incomplete', async (t) => {
const rootDir = await fixtureRoot(t);
const result = await collectReleaseStatus({
Expand Down
Loading