forked from Agoric/agoric-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (83 loc) · 3.84 KB
/
pre-check-integration.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Pre-check Integration Test
on:
workflow_call:
outputs:
should_run:
description: "'true' if the test should run"
value: "${{ jobs.check_and_cancel.outcome != 'skipped' && jobs.check_and_cancel.outputs.should_skip != 'true' }}"
previous_success:
description: "'true' if should not run because of a previous successful run"
value: "${{ jobs.check_and_cancel.outcome != 'skipped' && jobs.check_and_cancel.outputs.previous_success == 'true' }}"
merge_requested:
description: "'true' if pull_request was requested for merge"
value: >-
${{
github.event_name != 'pull_request' || (
(
github.event.pull_request.base.ref == 'master' ||
startsWith(github.event.pull_request.base.ref, 'release-') ||
startsWith(github.event.pull_request.base.ref, 'dev-') ||
github.event.pull_request.base.ref == 'beta'
) &&
github.event.pull_request.draft == false &&
(
contains(github.event.pull_request.labels.*.name, 'automerge:squash') ||
contains(github.event.pull_request.labels.*.name, 'automerge:no-update') ||
contains(github.event.pull_request.labels.*.name, 'automerge:rebase') ||
github.event.pull_request.auto_merge != null
)
)
}}
jobs:
check_and_cancel:
name: Check preconditions and cancel previous jobs
if: >-
github.event_name != 'pull_request' ||
contains(github.event.pull_request.labels.*.name, 'force:integration') || (
(
github.event.pull_request.base.ref == 'master' ||
startsWith(github.event.pull_request.base.ref, 'release-') ||
startsWith(github.event.pull_request.base.ref, 'dev-') ||
github.event.pull_request.base.ref == 'beta'
) &&
github.event.pull_request.draft == false &&
(
contains(github.event.pull_request.labels.*.name, 'automerge:squash') ||
contains(github.event.pull_request.labels.*.name, 'automerge:no-update') ||
contains(github.event.pull_request.labels.*.name, 'automerge:rebase') ||
github.event.pull_request.auto_merge != null
) &&
!contains(github.event.pull_request.labels.*.name, 'bypass:integration')
)
runs-on: ubuntu-latest
outputs:
should_skip: ${{ (steps.step2.outcome == 'skipped' || steps.step2.outputs.concurrent_conclusion == 'success') && steps.step1.outputs.should_skip || 'false' }}
previous_success: >-
${{
(steps.step2.outcome == 'skipped' && steps.step1.outputs.reason == 'skip_after_successful_duplicate' && 'true') ||
(steps.step2.outputs.concurrent_conclusion == 'success' && 'true') ||
'false'
}}
steps:
- id: step1
uses: fkirc/skip-duplicate-actions@v5
with:
cancel_others: "${{ github.event_name == 'pull_request' }}"
concurrent_skipping: 'same_content_newer'
- id: step2
name: Wait for concurrent run conclusion
if: >-
steps.step1.outputs.should_skip == 'true' &&
steps.step1.outputs.reason == 'concurrent_skipping' &&
fromJSON(steps.step1.outputs.skipped_by).status != 'completed'
run: |
while : ; do
conclusion="$(curl --fail --silent \
--url https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ fromJSON(steps.step1.outputs.skipped_by).id }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
| jq -r '.conclusion')"
[ "$conclusion" != "null" ] && break
sleep 10
done
echo "concurrent_conclusion=$conclusion" >> $GITHUB_OUTPUT