Skip to content

Commit c2f06a1

Browse files
committed
fix: review requests
1 parent c0c0782 commit c2f06a1

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

packages/beacon-node/test/spec/downloadTests.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@ import {downloadNightlyTests} from "@lodestar/spec-test-util/downloadNightlyTest
44
import {downloadTests} from "@lodestar/spec-test-util/downloadTests";
55
import {blsSpecTests, ethereumConsensusSpecsTests} from "./specTestVersioning.js";
66

7-
const onError = (e: Error): void => {
8-
console.error(e);
9-
process.exit(1);
10-
};
11-
12-
const [nightlyArg, repo, branch] = process.argv.slice(2);
7+
const [date, repo, branch] = process.argv.slice(2);
8+
const downloads = [downloadTests(blsSpecTests, console.log)];
139

14-
if (nightlyArg) {
10+
if (date) {
1511
config({path: path.join(import.meta.dirname, "../../../../.env")});
1612

1713
const opts = {
@@ -20,10 +16,12 @@ if (nightlyArg) {
2016
...(branch && {branch}),
2117
};
2218

23-
downloadTests(blsSpecTests, console.log).catch(onError);
24-
downloadNightlyTests(opts, console.log, nightlyArg).catch(onError);
19+
downloads.push(downloadNightlyTests(opts, console.log, date));
2520
} else {
26-
for (const opts of [ethereumConsensusSpecsTests, blsSpecTests]) {
27-
downloadTests(opts, console.log).catch(onError);
28-
}
21+
downloads.push(downloadTests(ethereumConsensusSpecsTests, console.log));
2922
}
23+
24+
await Promise.all(downloads).catch((e: Error) => {
25+
console.error(e);
26+
process.exit(1);
27+
});

packages/spec-test-util/src/downloadNightlyTests.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ async function ghApiFetch<T>(endpoint: string, token: string): Promise<T> {
2020
}
2121

2222
async function resolveNightlyRunId(repo: string, token: string, date?: string, branch?: string): Promise<number> {
23-
const query = "status=success&per_page=1" + (branch ? `&branch=${branch}` : "") + (date ? `&created=${date}` : "");
24-
const {workflow_runs} = await ghApiFetch<WorkflowRunsResponse>(
25-
`/repos/${repo}/actions/workflows/tests.yml/runs?${query}`,
23+
const params = new URLSearchParams({status: "success", per_page: "1"});
24+
if (branch) params.append("branch", branch);
25+
if (date) params.append("created", date);
26+
27+
const { workflow_runs } = await ghApiFetch<WorkflowRunsResponse>(
28+
`/repos/${repo}/actions/workflows/tests.yml/runs?${params}`,
2629
token
2730
);
2831

@@ -50,10 +53,7 @@ export async function downloadNightlyTests(
5053
const runId = await resolveNightlyRunId(repo, token, resolvedDate, opts.branch);
5154
log(`Resolved nightly${resolvedDate ? ` ${resolvedDate}` : ""} to run ${runId}`);
5255

53-
const {artifacts} = await ghApiFetch<ArtifactsListResponse>(
54-
`/repos/${repo}/actions/runs/${runId}/artifacts`,
55-
token
56-
);
56+
const {artifacts} = await ghApiFetch<ArtifactsListResponse>(`/repos/${repo}/actions/runs/${runId}/artifacts`, token);
5757

5858
const urlByTest: Record<string, string> = {};
5959
const available: string[] = [];

0 commit comments

Comments
 (0)