Skip to content

Commit 20a00ab

Browse files
committed
Merge branch 'js/ci-ghwf-dedup-tests'
The logic to skip testing on the tagged commit and the tag itself was not quite consistent which led to failure of Windows test tasks. It has been revamped to consistently skip revisions that have already been tested, based on the tree object of the revision. * js/ci-ghwf-dedup-tests: ci: do not skip tagged revisions in GitHub workflows ci: skip GitHub workflow runs for already-tested commits/trees
2 parents d620daa + 4463ce7 commit 20a00ab

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

.github/workflows/main.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
ci-config:
1010
runs-on: ubuntu-latest
1111
outputs:
12-
enabled: ${{ steps.check-ref.outputs.enabled }}
12+
enabled: ${{ steps.check-ref.outputs.enabled }}${{ steps.skip-if-redundant.outputs.enabled }}
1313
steps:
1414
- name: try to clone ci-config branch
1515
run: |
@@ -34,6 +34,43 @@ jobs:
3434
enabled=no
3535
fi
3636
echo "::set-output name=enabled::$enabled"
37+
- name: skip if the commit or tree was already tested
38+
id: skip-if-redundant
39+
uses: actions/github-script@v3
40+
if: steps.check-ref.outputs.enabled == 'yes'
41+
with:
42+
github-token: ${{secrets.GITHUB_TOKEN}}
43+
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;
53+
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;
72+
}
73+
}
3774
3875
windows-build:
3976
needs: ci-config

ci/lib.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ then
149149
CI_REPO_SLUG="$GITHUB_REPOSITORY"
150150
CI_JOB_ID="$GITHUB_RUN_ID"
151151
CC="${CC:-gcc}"
152+
DONT_SKIP_TAGS=t
152153

153154
cache_dir="$HOME/none"
154155

@@ -167,6 +168,7 @@ good_trees_file="$cache_dir/good-trees"
167168

168169
mkdir -p "$cache_dir"
169170

171+
test -n "${DONT_SKIP_TAGS-}" ||
170172
skip_branch_tip_with_tag
171173
skip_good_tree
172174

0 commit comments

Comments
 (0)