-
Notifications
You must be signed in to change notification settings - Fork 238
348 lines (311 loc) · 11.3 KB
/
Copy pathcicd.yaml
File metadata and controls
348 lines (311 loc) · 11.3 KB
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
name: CI jobs
on:
# run on pushes to the default branch
push:
branches: [main]
# run on pull requests originated from forks based on the `main` branch.
# note that if you're trying to edit the CI in a pull request,
# your changes won't run here. you need to temporarily add your branch to
# the `branches` list above.
pull_request:
branches: [main]
# run on releases
release:
types: ["published"]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
Authorize:
environment: ${{ github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository &&
'external' || 'internal' }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- run: true
Static-Check:
needs: Authorize
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
version: "0.7.12"
- uses: actions/setup-python@v6
with:
python-version: "3.12"
architecture: "x64"
- run: uv pip install --system "hatch>=1.14.2"
- run: hatch run tests.py3.12-2.10:static-check
Run-Unit-Tests:
needs: Authorize
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
airflow-version:
["2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "3.0"]
exclude:
- python-version: "3.11"
airflow-version: "2.4"
- python-version: "3.11"
airflow-version: "2.5"
- python-version: "3.11"
airflow-version: "2.6"
# Apache Airflow versions prior to 2.9.0 have not been tested with Python 3.12.
# Official support for Python 3.12 and the corresponding constraints.txt are available only for Apache Airflow >= 2.9.0.
# See: https://github.com/apache/airflow/tree/2.9.0?tab=readme-ov-file#requirements
# See: https://github.com/apache/airflow/tree/2.8.4?tab=readme-ov-file#requirements
- python-version: "3.12"
airflow-version: "2.4"
- python-version: "3.12"
airflow-version: "2.5"
- python-version: "3.12"
airflow-version: "2.6"
- python-version: "3.12"
airflow-version: "2.7"
- python-version: "3.12"
airflow-version: "2.8"
steps:
- uses: actions/checkout@v6.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
persist-credentials: false
- uses: actions/cache@v5
with:
path: |
~/.cache/uv
~/.cache/pip
.local/share/hatch/
key: unit-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.airflow-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('dagfactory/__init__.py') }}
- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
version: "0.7.12"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install packages and dependencies
run: |
uv pip install --system "hatch>=1.14.2"
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze
- name: Test DAG Factory against Airflow ${{ matrix.airflow-version }} and Python ${{ matrix.python-version }}
run: |
hatch run tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }}:test-cov
- name: Upload coverage to Github
uses: actions/upload-artifact@v5
with:
name: coverage-unit-test-${{ matrix.python-version }}-${{ matrix.airflow-version }}
path: .coverage
include-hidden-files: true
Run-Integration-Tests:
needs: Authorize
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
airflow-version:
["2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "3.0"]
exclude:
- python-version: "3.11"
airflow-version: "2.4"
- python-version: "3.11"
airflow-version: "2.5"
- python-version: "3.11"
airflow-version: "2.6"
# Apache Airflow versions prior to 2.9.0 have not been tested with Python 3.12.
# Official support for Python 3.12 and the corresponding constraints.txt are available only for Apache Airflow >= 2.9.0.
# See: https://github.com/apache/airflow/tree/2.9.0?tab=readme-ov-file#requirements
# See: https://github.com/apache/airflow/tree/2.8.4?tab=readme-ov-file#requirements
- python-version: "3.12"
airflow-version: "2.4"
- python-version: "3.12"
airflow-version: "2.5"
- python-version: "3.12"
airflow-version: "2.6"
- python-version: "3.12"
airflow-version: "2.7"
- python-version: "3.12"
airflow-version: "2.8"
steps:
- uses: actions/checkout@v6.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
persist-credentials: false
- uses: actions/cache@v5
with:
path: |
~/.cache/uv
~/.cache/pip
.local/share/hatch/
key: integration-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.airflow-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('dagfactory/__init__.py') }}
- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
version: "0.7.12"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install packages and dependencies
run: |
uv pip install --system "hatch>=1.14.2"
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze
- name: Test DAG Factory against Airflow ${{ matrix.airflow-version }} and Python ${{ matrix.python-version }}
run: |
hatch run tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }}:test-integration-setup
hatch run tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }}:test-integration
env:
AIRFLOW__CORE__DAGBAG_IMPORT_TIMEOUT: 90.0
AIRFLOW_HOME: ${{ github.workspace }}
CONFIG_ROOT_DIR: ${{ github.workspace }}/dags
PYTHONPATH: ${{ github.workspace }}:${{ github.workspace }}/dev/dags:$PYTHONPATH
- name: Upload coverage to Github
uses: actions/upload-artifact@v5
with:
name: coverage-integration-test-${{ matrix.python-version }}-${{ matrix.airflow-version }}
path: .coverage
include-hidden-files: true
Code-Coverage:
if: github.event.action != 'labeled'
needs:
- Run-Unit-Tests
- Run-Integration-Tests
- Build-Mkdocs
- Authorize
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
version: "0.7.12"
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install coverage
run: |
uv tool install coverage
- name: Download all coverage artifacts
uses: actions/download-artifact@v7
with:
path: ./coverage
- name: Combine coverage
run: |
coverage combine ./coverage/coverage*/.coverage
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Build-Mkdocs:
name: Build MkDocs
runs-on: ubuntu-latest
permissions:
contents: read
needs:
- Authorize
steps:
- uses: actions/checkout@v6.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
persist-credentials: true
- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install hatch via uv
run: uv pip install --system "hatch>=1.14.2"
- name: Build docs (MkDocs)
run: hatch run docs:build
Deploy-Pages:
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release'
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- Authorize
steps:
- uses: actions/checkout@v6.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
persist-credentials: true
- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
version: "0.7.12"
- uses: actions/setup-python@v6
with:
python-version: "3.12"
architecture: "x64"
- name: Install packages and dependencies
run: uv pip install --system "hatch>=1.14.2"
- name: Deploy Docs
run: |
git config user.name "oss-integrations-bot"
git config user.email "oss-integrations-bot@astronomer.io"
git fetch origin gh-pages --depth=1
if [[ $GITHUB_EVENT_NAME == "release" ]]; then
hatch run docs:gh-release
else
hatch run docs:gh-deploy
fi
Publish-Package:
if: github.event_name == 'release'
name: Build and publish Python 🐍 distributions 📦 to PyPI
needs:
- Static-Check
- Run-Unit-Tests
- Run-Integration-Tests
- Deploy-Pages
- Code-Coverage
- Authorize
- Build-Mkdocs
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/dag-factory
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v6.0.1
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
version: "0.7.12"
- uses: actions/setup-python@v6
with:
python-version: "3.10"
architecture: "x64"
- name: Verify Git Tag and package version
run: python3 ./scripts/verify_tag_and_version.py
- run: uv build --wheel --sdist
- run: uv publish