-
Notifications
You must be signed in to change notification settings - Fork 52
242 lines (205 loc) · 7.62 KB
/
CI.yaml
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: CI
on:
push:
branches:
- main
paths-ignore: ["docs/**", "scripts/**", "**.md", "*"]
pull_request:
branches:
- main
types: [opened, synchronize, labeled, reopened, ready_for_review]
paths-ignore: ["docs/**", "scripts/**", "**.md", "*"]
workflow_dispatch:
inputs:
debug_enabled:
description: "Run with tmate.io debugging enabled"
required: true
type: boolean
default: false
run_build_images:
description: "Run build-images job"
required: false
type: boolean
default: false
run_execute_workflow:
description: "Run execute-workflow job"
required: false
type: boolean
default: false
workflow_execution_mode:
description: "Workflow execution mode"
required: false
type: string
default: "prod"
defaults:
run:
shell: bash
permissions:
actions: write
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
set-variables:
name: Set Variables
runs-on: ubuntu-latest
outputs:
debug: ${{ steps.set-variables.outputs.debug }}
skip_ci: ${{ steps.set-variables.outputs.skip_ci }}
skip_tests: ${{ steps.set-variables.outputs.skip_tests }}
mode: ${{ steps.set-variables.outputs.mode }}
steps:
- name: Set action variables
id: set-variables
run: |
DEBUG="false"
MODE="prod"
SKIP_CI="false"
SKIP_TESTS="false"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
DEBUG="${{ github.event.inputs.debug_enabled }}"
MODE="${{ github.event.inputs.workflow_execution_mode }}"
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if ${{ contains(github.event.pull_request.labels.*.name, 'skip-ci') }}; then
SKIP_CI="true"
fi
if ${{ contains(github.event.pull_request.labels.*.name, 'skip-tests') }}; then
SKIP_TESTS="true"
fi
if ${{ contains(github.event.pull_request.labels.*.name, 'actions-debug') }}; then
DEBUG="true"
fi
if ${{ contains(github.event.pull_request.labels.*.name, 'workflow-mode-dev') }}; then
MODE="dev"
fi
fi
echo "DEBUG=$DEBUG"
echo "MODE=$MODE"
echo "SKIP_CI=$SKIP_CI"
echo "SKIP_TESTS=$SKIP_TESTS"
echo "DEBUG=$DEBUG" >> $GITHUB_OUTPUT
echo "MODE=$MODE" >> $GITHUB_OUTPUT
echo "SKIP_CI=$SKIP_CI" >> $GITHUB_OUTPUT
echo "SKIP_TESTS=$SKIP_TESTS" >> $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
needs: [set-variables]
if: ${{ needs.set-variables.outputs.skip_ci != 'true' && needs.set-variables.outputs.skip_tests != 'true' }}
strategy:
matrix:
python_version: ['3.10']
steps:
- name: Check Variables
run: |
echo "SKIP_CI=${{ needs.set-variables.outputs.skip_ci }}"
echo "SKIP_TESTS=${{ needs.set-variables.outputs.skip_tests }}"
echo "DEBUG=${{ needs.set-variables.outputs.debug }}"
echo "MODE=${{ needs.set-variables.outputs.mode }}"
- name: Checkout code
uses: actions/checkout@v4
- name: Setup environment
uses: ./.github/actions/setup_environment
with:
python_version: ${{ matrix.python_version }}
debug_enabled: ${{ needs.set-variables.outputs.debug }}
- name: "Setup tmate debug session"
uses: mxschmitt/action-tmate@v3
if: ${{ inputs.debug_enabled }}
- name: Lint and typecheck
run: |
make lint-check
- name: Run tests
run: |
make test-cov-xml
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
build-images:
needs: [test, set-variables]
if: ${{ needs.set-variables.outputs.skip_ci != 'true' && (contains(github.event.pull_request.labels.*.name, 'build-images') || contains(github.event.pull_request.labels.*.name, 'execute-workflow') || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_build_images)) }}
uses: ./.github/workflows/build-images.yaml
secrets:
GCP_ARTIFACT_REGISTRY_PATH: ${{ secrets.GCP_ARTIFACT_REGISTRY_PATH }}
with:
debug_enabled: ${{ needs.set-variables.outputs.debug }}
mode: ${{ needs.set-variables.outputs.mode }}
config-workflows:
needs: [test, set-variables]
if: ${{ needs.set-variables.outputs.skip_ci != 'true' && (contains(github.event.pull_request.labels.*.name, 'execute-workflow') || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_execute_workflow)) }}
runs-on: ubuntu-latest
outputs:
config-path: ${{ steps.config-output.outputs.path }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Flyte config from YAML template
id: yq-process
uses: mikefarah/yq@master
with:
cmd: "yq e \
'.admin.endpoint = strenv(FLYTE_CLUSTER_ENDPOINT) | \
.storage.stow.config.project_id = strenv(GCP_PROJECT_ID) | \
.storage.stow.config.scopes = strenv(GCP_STORAGE_SCOPES) | \
.storage.container = strenv(GCP_STORAGE_CONTAINER)' \
.flyte/config-template.yaml > .flyte/config.yaml"
env:
FLYTE_CLUSTER_ENDPOINT: ${{ secrets.FLYTE_CLUSTER_ENDPOINT }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_STORAGE_SCOPES: ${{ secrets.GCP_STORAGE_SCOPES }}
GCP_STORAGE_CONTAINER: ${{ secrets.GCP_STORAGE_CONTAINER }}
- name: Upload Flyte config as an artifact
id: config-output
uses: actions/upload-artifact@v3
with:
name: flyte-config
path: ${{ secrets.FLYTECTL_CONFIG }}
execute-workflow:
needs: [config-workflows, build-images, set-variables]
if: ${{ needs.set-variables.outputs.skip_ci != 'true' && (contains(github.event.pull_request.labels.*.name, 'execute-workflow') || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_execute_workflow)) }}
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ['3.10']
env:
FLYTECTL_CONFIG: ${{ secrets.FLYTECTL_CONFIG }}
FLYTE_OAUTH_CLIENT_SECRET: ${{ secrets.FLYTE_OAUTH_CLIENT_SECRET }}
WORKFLOW_IMAGE: ${{ vars.WORKFLOW_IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Setup environment
uses: ./.github/actions/setup_environment
with:
python_version: ${{ matrix.python_version }}
debug_enabled: ${{ needs.set-variables.outputs.debug }}
- name: Download Flyte config
uses: actions/download-artifact@v3
with:
name: flyte-config
path: .flyte/
- name: Setup tmate debug session
if: ${{ github.event.inputs.debug_enabled == 'true' }}
uses: mxschmitt/action-tmate@v3
- name: Execute workflow
id: execute
run: |
make run_${{ needs.set-variables.outputs.mode }}
- name: Create config tarball
id: save-hydra-outputs
run: |
TAR_FILENAME="hydra_outputs_${GITHUB_SHA_SHORT}.tar.gz"
tar -czf $TAR_FILENAME ./outputs/
tar -tzf $TAR_FILENAME
echo "HYDRA_OUTPUTS_TAR=$TAR_FILENAME" >> $GITHUB_ENV
- name: Upload config artifact
uses: actions/upload-artifact@v3
with:
name: hydra-outputs
path: ${{ env.HYDRA_OUTPUTS_TAR }}