ci: simplify benchmark report publication

This commit is contained in:
ldm0
2026-08-28 04:00:49 +08:00
committed by Donough Liu
parent 2ec01c5401
commit 76b7f9be27
4 changed files with 33 additions and 54 deletions
+1 -27
View File
@@ -6,7 +6,6 @@ const DEFAULT_TIMEOUT_MS = 110 * 60_000;
async function pollWorkflowArtifact({
artifactName,
listArtifacts,
getTargetJob = async () => null,
getWorkflowRun,
now = Date.now,
sleep = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)),
@@ -27,14 +26,6 @@ async function pollWorkflowArtifact({
};
}
const targetJob = await getTargetJob();
if (targetJob?.status === 'completed') {
return {
artifactAvailable: false,
conclusion: targetJob.conclusion || 'failure',
};
}
const workflowRun = await getWorkflowRun();
if (workflowRun.status === 'completed') {
return {
@@ -59,7 +50,6 @@ async function waitForWorkflowArtifact({
context,
core,
artifactName,
targetJobName,
pollIntervalMs = DEFAULT_POLL_INTERVAL_MS,
timeoutMs = DEFAULT_TIMEOUT_MS,
}) {
@@ -87,19 +77,6 @@ async function waitForWorkflowArtifact({
});
return response.data.artifacts;
},
getTargetJob: async () => {
if (!targetJobName) {
return null;
}
const response = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: runId,
filter: 'latest',
per_page: 100,
});
return response.data.jobs.find((job) => job.name === targetJobName) || null;
},
getWorkflowRun: async () => {
const response = await github.rest.actions.getWorkflowRun({
owner,
@@ -110,15 +87,12 @@ async function waitForWorkflowArtifact({
},
});
const runUrl = run.html_url || `https://github.com/${owner}/${repo}/actions/runs/${runId}`;
core.setOutput('artifact_available', String(result.artifactAvailable));
core.setOutput('conclusion', result.conclusion);
core.setOutput('run_id', String(runId));
core.setOutput('run_url', runUrl);
if (!result.artifactAvailable) {
core.notice(
`The target job or workflow run ${runId} finished, or the wait timed out, before ${artifactName} was uploaded.`
`Workflow run ${runId} finished or the wait timed out before ${artifactName} was uploaded.`
);
}
}
@@ -57,22 +57,6 @@ test('reports a terminal workflow that never uploaded the artifact', async () =>
assert.deepEqual(result, { artifactAvailable: false, conclusion: 'failure' });
});
test('does not wait for unrelated jobs after the target job finishes', async () => {
let workflowLookups = 0;
const result = await pollWorkflowArtifact({
artifactName: 'benchmark-results',
listArtifacts: async () => [],
getTargetJob: async () => ({ status: 'completed', conclusion: 'skipped' }),
getWorkflowRun: async () => {
workflowLookups += 1;
return { status: 'in_progress', conclusion: null };
},
});
assert.deepEqual(result, { artifactAvailable: false, conclusion: 'skipped' });
assert.equal(workflowLookups, 0);
});
test('ignores expired artifacts and eventually times out', async () => {
let currentTime = 0;
const result = await pollWorkflowArtifact({