Skip to content

Commit 876511e

Browse files
committed
Merge branch 'js/ci-ghwf-dedup-tests'
GitHub Actions automated test improvement to skip tests on a tree identical to what has already been tested. * js/ci-ghwf-dedup-tests: ci: make the "skip-if-redundant" check more defensive ci: work around old records of GitHub runs
2 parents f9c0e74 + d6d6683 commit 876511e

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

.github/workflows/main.yml

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,39 @@ jobs:
4141
with:
4242
github-token: ${{secrets.GITHUB_TOKEN}}
4343
script: |
44-
// Figure out workflow ID, commit and tree
45-
const { data: run } = await github.actions.getWorkflowRun({
46-
owner: context.repo.owner,
47-
repo: context.repo.repo,
48-
run_id: context.runId,
49-
});
50-
const workflow_id = run.workflow_id;
51-
const head_sha = run.head_sha;
52-
const tree_id = run.head_commit.tree_id;
44+
try {
45+
// Figure out workflow ID, commit and tree
46+
const { data: run } = await github.actions.getWorkflowRun({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
run_id: context.runId,
50+
});
51+
const workflow_id = run.workflow_id;
52+
const head_sha = run.head_sha;
53+
const tree_id = run.head_commit.tree_id;
5354
54-
// See whether there is a successful run for that commit or tree
55-
const { data: runs } = await github.actions.listWorkflowRuns({
56-
owner: context.repo.owner,
57-
repo: context.repo.repo,
58-
per_page: 500,
59-
status: 'success',
60-
workflow_id,
61-
});
62-
for (const run of runs.workflow_runs) {
63-
if (head_sha === run.head_sha) {
64-
core.warning(`Successful run for the commit ${head_sha}: ${run.html_url}`);
65-
core.setOutput('enabled', ' but skip');
66-
break;
67-
}
68-
if (tree_id === run.head_commit.tree_id) {
69-
core.warning(`Successful run for the tree ${tree_id}: ${run.html_url}`);
70-
core.setOutput('enabled', ' but skip');
71-
break;
55+
// See whether there is a successful run for that commit or tree
56+
const { data: runs } = await github.actions.listWorkflowRuns({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
per_page: 500,
60+
status: 'success',
61+
workflow_id,
62+
});
63+
for (const run of runs.workflow_runs) {
64+
if (head_sha === run.head_sha) {
65+
core.warning(`Successful run for the commit ${head_sha}: ${run.html_url}`);
66+
core.setOutput('enabled', ' but skip');
67+
break;
68+
}
69+
if (run.head_commit && tree_id === run.head_commit.tree_id) {
70+
core.warning(`Successful run for the tree ${tree_id}: ${run.html_url}`);
71+
core.setOutput('enabled', ' but skip');
72+
break;
73+
}
7274
}
75+
} catch (e) {
76+
core.warning(e);
7377
}
7478
7579
windows-build:

0 commit comments

Comments
 (0)