fix: accept nullable workflow metadata

This commit is contained in:
Viggo Phillips
2026-09-21 09:54:49 +02:00
parent 5b05a3f006
commit 32c10932fc
2 changed files with 21 additions and 8 deletions
+9 -6
View File
@@ -37,10 +37,13 @@ const tagSchema = {
},
},
};
const workflowRunsSchema = collectionSchema('workflow_runs');
const workflowRunsSchema = collectionSchema('workflow_runs', true);
const checkRunsSchema = collectionSchema('check_runs');
function collectionSchema(property) {
function collectionSchema(property, nullableWorkflowFields = false) {
const nameAndStatusSchema = nullableWorkflowFields
? { anyOf: [{ type: 'string' }, { type: 'null' }] }
: { type: 'string' };
return {
type: 'object',
required: [property],
@@ -52,9 +55,9 @@ function collectionSchema(property) {
required: ['id', 'name', 'head_sha', 'status', 'conclusion'],
properties: {
id: { type: 'integer' },
name: { type: 'string' },
name: nameAndStatusSchema,
head_sha: { type: 'string' },
status: { type: 'string' },
status: nameAndStatusSchema,
conclusion: { anyOf: [{ type: 'string' }, { type: 'null' }] },
},
},
@@ -129,11 +132,11 @@ function nextPageUrl(linkHeader, repository) {
}
async function githubApiPages(path, itemsKey, inputs, fetchImpl, schema) {
const items = [];
let items = [];
let next = path;
while (next) {
const page = await githubApiPage(next, inputs, fetchImpl, schema);
items.push(...page.payload[itemsKey]);
items = [...items, ...page.payload[itemsKey]];
next = page.next;
}
return items;
@@ -19,13 +19,16 @@ const lifecycleRunnerSource = load('tests/ci/packed-artifact-lifecycle.js');
let passed = 0;
let failed = 0;
const pendingTests = [];
let pendingTests = [];
function test(name, fn) {
try {
const result = fn();
if (result && typeof result.then === 'function') {
pendingTests.push(result.then(() => pass(name), error => fail(name, error)));
pendingTests = [
...pendingTests,
result.then(() => pass(name), error => fail(name, error)),
];
} else {
pass(name);
}
@@ -267,6 +270,13 @@ test('release gate verifier evaluates checks from every GitHub result page', asy
return response({
workflow_runs: [
{ id: 1, name: 'CI', head_sha: releaseSha, status: 'completed', conclusion: 'success' },
{
id: 3,
name: null,
head_sha: 'b'.repeat(40),
status: null,
conclusion: null,
},
],
});
}