-
Notifications
You must be signed in to change notification settings - Fork 38
227 lines (187 loc) · 7.05 KB
/
ci-cd.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
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
name: CI/CD
on:
push:
branches:
- main
pull_request:
# Cancel previous runs of the same PR but do not cancel previous runs on main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
TERM: linux
TERMINFO: /etc/terminfo
PYTHONIOENCODING: utf-8
jobs:
client-test:
name: Unit tests on ${{ matrix.python-version }} and ${{ matrix.os }} (protobuf=${{ matrix.proto-version }})
timeout-minutes: 20
strategy:
fail-fast: false # run all variants across python versions/os to completion
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-20.04"]
proto-version: ["latest"]
include:
- os: "macos-12" # x86-64
python-version: "3.10"
proto-version: "latest"
- os: "macos-14" # ARM64 (M1)
python-version: "3.10"
proto-version: "latest"
- os: "windows-latest"
python-version: "3.10"
proto-version: "latest"
- os: "ubuntu-20.04"
python-version: "3.8"
proto-version: "3.19"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-cached-python
with:
version: ${{ matrix.python-version }}
- if: matrix.proto-version != 'latest'
name: Install protobuf
run: pip install protobuf==${{ matrix.proto-version }}
- name: Build protobuf
run: inv protoc
- name: Build client package (installs all dependencies)
run: pip install -e .
- name: Run client tests
run: pytest -v
- name: Run docstring tests
if: github.event.pull_request.head.repo.fork != 'true'
env:
MODAL_ENVIRONMENT: client-doc-tests
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
run: pytest -v --markdown-docs -m markdown-docs modal
container-dependencies:
name: Check minimal container dependencies for ${{ matrix.python-version }} / ${{ matrix.image-builder-version }}
runs-on: ubuntu-20.04
timeout-minutes: 4
strategy:
matrix:
image-builder-version: ["2024.04", "2024.10"]
python-version: ["3.8", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
pip install -r modal/requirements/${{ matrix.image-builder-version }}.txt
pip install synchronicity
- name: Compile protos
run: |
python -m venv venv
source venv/bin/activate
pip install grpcio-tools==1.59.2 grpclib==0.4.7
python -m grpc_tools.protoc --python_out=. --grpclib_python_out=. --grpc_python_out=. -I . modal_proto/api.proto modal_proto/options.proto
python -m grpc_tools.protoc --plugin=protoc-gen-modal-grpclib-python=protoc_plugin/plugin.py --modal-grpclib-python_out=. -I . modal_proto/api.proto modal_proto/options.proto
deactivate
- name: Check entrypoint import
run: |
python -c 'import modal._container_entrypoint'
if [ "${{ matrix.image-builder-version }}" == "2024.04" ]; then python -c 'import fastapi'; fi
publish-base-images:
name: |
Publish base images for ${{ matrix.image-name }} ${{ matrix.image-builder-version }} on ${{ matrix.python-version }}
if: github.ref == 'refs/heads/main'
needs: [client-test]
runs-on: ubuntu-20.04
timeout-minutes: 5
env:
MODAL_LOGLEVEL: DEBUG
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
image-builder-version: ["2023.12", "2024.04"]
image-name: ["debian_slim", "micromamba"]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-cached-python
with:
version: ${{ matrix.python-version }}
- name: Build protobuf
run: inv protoc
- name: Build client package (installs all dependencies)
run: pip install -e .
- name: Set the Modal environment
run: modal config set-environment main
- name: Publish base images
env:
MODAL_IMAGE_BUILDER_VERSION: ${{ matrix.image-builder-version }}
MODAL_IMAGE_ALLOW_GLOBAL_DEPLOYMENT: "1"
run: |
python -m modal_global_objects.images.${{ matrix.image-name }} ${{ matrix.python-version }}
publish-client:
name: Publish client package
if: github.ref == 'refs/heads/main'
needs: [client-test]
runs-on: ubuntu-20.04
concurrency: publish-client
timeout-minutes: 5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Generate token for Github PR Bot
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.GH_PRBOT_APP_ID }}
private_key: ${{ secrets.GH_PRBOT_APP_PRIVATE_KEY }}
- uses: actions/checkout@v3
with:
token: ${{ steps.generate_token.outputs.token }}
ref: main
- uses: ./.github/actions/setup-cached-python
with:
version: "3.10"
- name: Bump the version number
run: inv update-build-number
- name: Update the changelog
run: inv update-changelog --sha=$GITHUB_SHA
- name: Get the current client version
id: version
run: echo "client_version=`python -m modal_version`" >> "$GITHUB_OUTPUT"
- uses: EndBug/add-and-commit@v9
with:
add: modal_version/_version_generated.py CHANGELOG.md
tag: v${{ steps.version.outputs.client_version }}
message: "[auto-commit] [skip ci] Bump the build number"
pull: "--rebase --autostash"
default_author: github_actions
- name: Build protobuf
run: inv protoc
- name: Install all dependencies
run: pip install -e .
- name: Build type stubs
run: inv type-stubs
- name: Build wheel
run: python setup.py bdist_wheel
- name: Create alias package
run: inv create-alias-package
- name: Build alias package
working-directory: alias-package
run: python setup.py bdist_wheel
- name: Set the Modal environment
run: modal config set-environment main
- name: Publish client mount
env:
MODAL_LOGLEVEL: DEBUG
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
run: python -m modal_global_objects.mounts.modal_client_package
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/* --non-interactive
- name: Upload alias package to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
working-directory: alias-package
run: twine upload dist/* --non-interactive