-
Notifications
You must be signed in to change notification settings - Fork 1
190 lines (163 loc) · 5.8 KB
/
_dispatcher.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# This file is the dispatcher for the rest of the workflows that have complex dependencies.
# The `cli.yml` doesn't need to be dispatched via this dispatcher because it is only run manually.
name: Dispatcher
env:
GITHUB_OUTPUT: ""
on:
push:
branches:
- main
paths:
- "docker/**"
- ".github/**"
- "!.github/workflows/cli.yml"
- "!docker/psibase.Dockerfile"
- "!docker/psinode.Dockerfile"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "docker/**"
- ".github/**"
- "!.github/workflows/cli.yml"
- "!docker/psibase.Dockerfile"
- "!docker/psinode.Dockerfile"
jobs:
determine-actions:
name: Set up the dispatching variables
runs-on: ubuntu-latest
outputs:
pr: ${{ steps.conditionals.outputs.pr }}
build_strategy: ${{ steps.schedule-builders.outputs.builder_strategy }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 0
- name: Determine artifact registry
id: conditionals
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "pr=true" >> $GITHUB_OUTPUT
fi
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v42
- name: Print changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
for file in $ALL_CHANGED_FILES; do
echo $file
done
- name: Determine what to dispatch
id: schedule-builders
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
chmod +x .github/scripts/check-patterns.sh
echo "builder_strategy=$(./.github/scripts/check-patterns.sh "$ALL_CHANGED_FILES")" >> $GITHUB_OUTPUT
# Possible dispatching scenarios
# 0: don't run anything
# 1: run tool config (and all dependent workflows)
# 2: run 2004 builder
# 3: run 2204 builder (and dependent)
# 4: run both builders (and dependent)
# 5: run contributor
# CASE 0
do-nothing:
name: "Not building anything"
needs: determine-actions
if: ${{ needs.determine-actions.outputs.build_strategy == '0' }}
runs-on: ubuntu-latest
steps:
- name: noop
run: true
# CASE 1
start-with-tool-config-1:
name: "Build tool-config"
needs: determine-actions
if: ${{ needs.determine-actions.outputs.build_strategy == '1' }}
uses: ./.github/workflows/tool-config.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}
start-with-tool-config-2:
name: "Build 20.04 builder"
needs: [determine-actions, start-with-tool-config-1]
if: ${{ needs.determine-actions.outputs.build_strategy == '1' }}
uses: ./.github/workflows/builder-ubuntu.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}
ubuntu_version: "2004"
start-with-tool-config-3:
name: "Build 22.04 builder"
needs: [determine-actions, start-with-tool-config-1]
if: ${{ needs.determine-actions.outputs.build_strategy == '1' }}
uses: ./.github/workflows/builder-ubuntu.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}
ubuntu_version: "2204"
start-with-tool-config-4:
name: "Build psibase contributor"
needs: [determine-actions, start-with-tool-config-3]
if: ${{ needs.determine-actions.outputs.build_strategy == '1' }}
uses: ./.github/workflows/contributor.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}
# CASE 2
run-only-2004-builder:
name: "Build 20.04 builder"
needs: determine-actions
if: ${{ needs.determine-actions.outputs.build_strategy == '2' }}
uses: ./.github/workflows/builder-ubuntu.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}
ubuntu_version: "2004"
# CASE 3
start-with-2204-builder-1:
name: "Build 22.04 builder"
needs: determine-actions
if: ${{ needs.determine-actions.outputs.build_strategy == '3' }}
uses: ./.github/workflows/builder-ubuntu.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}
ubuntu_version: "2204"
start-with-2204-builder-2:
name: "Build psibase contributor"
needs: [determine-actions, start-with-2204-builder-1]
if: ${{ needs.determine-actions.outputs.build_strategy == '3' }}
uses: ./.github/workflows/contributor.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}
# CASE 4
start-with-builders-1:
name: "Build 20.04 builder"
needs: determine-actions
if: ${{ needs.determine-actions.outputs.build_strategy == '4' }}
uses: ./.github/workflows/builder-ubuntu.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}
ubuntu_version: "2004"
start-with-builders-2:
name: "Build 22.04 builder"
needs: determine-actions
if: ${{ needs.determine-actions.outputs.build_strategy == '4' }}
uses: ./.github/workflows/builder-ubuntu.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}
ubuntu_version: "2204"
start-with-builders-3:
name: "Build psibase contributor"
needs: [determine-actions, start-with-builders-2]
if: ${{ needs.determine-actions.outputs.build_strategy == '4' }}
uses: ./.github/workflows/contributor.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}
# CASE 5
run-only-contributor:
name: "Build psibase contributor"
needs: determine-actions
if: ${{ needs.determine-actions.outputs.build_strategy == '5' }}
uses: ./.github/workflows/contributor.yml
with:
is_pr: ${{ needs.determine-actions.outputs.pr }}