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
46 changes: 18 additions & 28 deletions scripts/ci/test-cli-release-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,46 +47,37 @@ test('a prerelease tag exposed as a stable GitHub Release fails closed', () => {
);
});

test('channel classification supports prerelease and stable transition records', () => {
test('channel classification reads the public stable release authority', () => {
assert.deepEqual(
validateChannel({
schema: AUTHORITY_SCHEMA,
schema_version: 2,
outcome: 'pass',
qualified_artifact_versions: {cli: '2.0.0-rc.31'},
schema_version: 1,
artifacts: {cli: '2.0.0'},
}),
{
schema: AUTHORITY_SCHEMA,
channel: 'prerelease',
version: '2.0.0-rc.31',
channel: 'stable',
version: '2.0.0',
},
);
assert.equal(validateChannel({
schema: AUTHORITY_SCHEMA,
schema_version: 2,
outcome: 'pass',
qualified_artifact_versions: {cli: '2.0.0'},
}).version, '2.0.0');

assert.throws(
() => validateChannel({
schema: AUTHORITY_SCHEMA,
schema_version: 2,
outcome: 'pass',
qualified_artifact_versions: {cli: '2.0.0-preview.1'},
schema_version: 1,
artifacts: {cli: '2.0.0-rc.1'},
}),
/must be an alpha, beta, or rc/,
/must be exact MAJOR.MINOR.PATCH/,
);
});

test('the supported prerelease must remain publicly discoverable with complete assets', async () => {
test('the current stable channel remains publicly discoverable with complete assets', async () => {
const releaseTag = '2.0.0-rc.32';
const supportedTag = '2.0.0-rc.12';
const supportedTag = '2.0.0';
const channel = {
schema: AUTHORITY_SCHEMA,
schema_version: 2,
outcome: 'pass',
qualified_artifact_versions: {cli: supportedTag},
schema_version: 1,
artifacts: {cli: supportedTag},
};
const fetchImpl = async url => {
if (url === 'https://example.test/channel.json') {
Expand All @@ -96,7 +87,7 @@ test('the supported prerelease must remain publicly discoverable with complete a
return jsonResponse(release(releaseTag, true));
}
if (url.endsWith(`/releases/tags/${supportedTag}`)) {
return jsonResponse(release(supportedTag, true));
return jsonResponse(release(supportedTag, false));
}
return jsonResponse({}, 404);
};
Expand All @@ -109,7 +100,7 @@ test('the supported prerelease must remain publicly discoverable with complete a
releaseTag,
}),
{
channel: 'prerelease',
channel: 'stable',
channel_version: supportedTag,
release_prerelease: true,
release_tag: releaseTag,
Expand All @@ -123,7 +114,7 @@ test('the supported prerelease must remain publicly discoverable with complete a
if (url.endsWith(`/releases/tags/${releaseTag}`)) {
return jsonResponse(release(releaseTag, true));
}
const incompleteSupportedRelease = release(supportedTag, true);
const incompleteSupportedRelease = release(supportedTag, false);
incompleteSupportedRelease.assets = incompleteSupportedRelease.assets.filter(
asset => asset.name !== 'SHA256SUMS',
);
Expand Down Expand Up @@ -155,7 +146,7 @@ test('the supported prerelease must remain publicly discoverable with complete a
fetchImpl: unavailableFetch,
releaseTag,
}),
/HTTP 404 fetching .*2\.0\.0-rc\.12/,
/HTTP 404 fetching .*2\.0\.0/,
);
});

Expand All @@ -164,9 +155,8 @@ test('stable transition resolution requires stable public metadata', async () =>
if (url === 'https://example.test/channel.json') {
return jsonResponse({
schema: AUTHORITY_SCHEMA,
schema_version: 2,
outcome: 'pass',
qualified_artifact_versions: {cli: '2.0.0'},
schema_version: 1,
artifacts: {cli: '2.0.0'},
});
}
return jsonResponse(release('2.0.0', false));
Expand Down
27 changes: 8 additions & 19 deletions scripts/ci/verify-cli-release-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

const {parseReleaseVersion} = require('./release-version');

const AUTHORITY_SCHEMA = 'durable-workflow.docs.public-artifact-compatibility-evidence';
const AUTHORITY_SCHEMA = 'durable-workflow.docs.stable-releases';
const DEFAULT_CHANNEL_URL =
'https://durable-workflow.com/public-artifact-compatibility-evidence.json';
'https://durable-workflow.com/stable-releases.json';
const DEFAULT_API_BASE = 'https://api.github.com/repos/durable-workflow/cli';
const REQUIRED_ASSETS = Object.freeze([
'SHA256SUMS',
Expand Down Expand Up @@ -32,29 +32,18 @@ function validateChannel(value) {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
throw new Error('CLI release authority must be a JSON object');
}
if (value.schema !== AUTHORITY_SCHEMA || value.schema_version !== 2 || value.outcome !== 'pass') {
throw new Error('CLI release authority must be a passing schema-v2 document');
if (value.schema !== AUTHORITY_SCHEMA || value.schema_version !== 1) {
throw new Error('CLI release authority must use the stable-releases schema v1');
}

const version = value.qualified_artifact_versions?.cli;
const version = value.artifacts?.cli;
const parsed = parseReleaseVersion(version);
if (parsed === null) {
throw new Error(`qualified CLI version is not valid SemVer: ${String(version)}`);
}

const channel = parsed.prerelease === null ? 'stable' : 'prerelease';
if (channel === 'prerelease') {
const [label, sequence, ...rest] = parsed.prerelease;
if (!['alpha', 'beta', 'rc'].includes(label)) {
throw new Error('qualified CLI prerelease must be an alpha, beta, or rc version');
}
if (rest.length > 0 || sequence === undefined || !/^(0|[1-9][0-9]*)$/.test(sequence)) {
throw new Error('qualified CLI prerelease must use a numeric sequence');
}
if (parsed === null || parsed.prerelease !== null || parsed.build !== null) {
throw new Error(`stable CLI version must be exact MAJOR.MINOR.PATCH: ${String(version)}`);
}

return Object.freeze({
channel,
channel: 'stable',
schema: value.schema,
version,
});
Expand Down
Loading