-
Notifications
You must be signed in to change notification settings - Fork 0
319 lines (270 loc) · 9.33 KB
/
deploy.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
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
name: Build and Deploy
on:
push:
branches:
- main
release:
branch: main
types: [released]
jobs:
build-pyodide:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Check the Pyodide version
run: |
echo "PYODIDE_SHA_SHORT=$(git submodule status pyodide | cut -c 2-8)" >> $GITHUB_ENV
- name: Cache the Pyodide build
uses: actions/cache@v4
with:
path: ./pyodide
key: pyodide-${{ github.ref }}-${{ env.PYODIDE_SHA_SHORT }}
restore-keys: |
pyodide-${{ github.ref }}-${{ env.PYODIDE_SHA_SHORT }}
pyodide-${{ github.ref }}
pyodide-refs/heads/main
- name: Ensure that the Pyodide source files are fresh
run: |
cd pyodide
git status
git diff --name-only | xargs git checkout --
git clean -df
echo ======
git status
- name: Cache the Pyodide Docker image
uses: ScribeMD/docker-cache@0.5.0
with:
key: docker-pyodide-${{ hashFiles('pyodide/Dockerfile') }}
- name: Discover the cached Pyodide Docker image
run: echo "PYODIDE_DOCKER_IMAGE=$(docker images climet-eu/pyodide --format '{{.ID}}')" >> $GITHUB_ENV
- name: Build the Pyodide Docker image
if: ${{ env.PYODIDE_DOCKER_IMAGE == '' }}
run: |
cd pyodide
docker build -t climet-eu/pyodide .
echo "PYODIDE_DOCKER_IMAGE=$(docker build . -q)" >> $GITHUB_ENV
- name: Build Pyodide and all required packages
run: |
cd pyodide
./run_docker \
--non-interactive \
PYODIDE_PACKAGES="$(cat ../venv/packages.txt | paste -sd "," -)" \
make
- name: Clean up the Pyodide build
run: |
python tools/clean-dist.py pyodide/dist
cd pyodide
find . -name jupyter-lite.json -delete
find . -name jupyter_lite_config.json -delete
rm -f dist/tsconfig.tsbuildinfo
mkdir -p packages/numpy/build
touch packages/numpy/build/ls-success
ls -d packages/*/build/* | xargs rm -r
- name: Upload the pyodide-lock.json artifact
uses: actions/upload-artifact@v4
with:
name: pyodide-lock.json
path: pyodide/dist/pyodide-lock.json
retention-days: 1
- name: Upload the Pyodide distribution artifact
uses: actions/upload-artifact@v4
with:
name: pyodide
path: pyodide/dist
retention-days: 1
- name: Remove the uploaded Pyodide distribution
run: rm -rf pyodide/dist
build-pypa:
runs-on: ubuntu-latest
needs: build-pyodide
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Download the pyodide-lock.json artifact
uses: actions/download-artifact@v4
with:
name: pyodide-lock.json
path: pyodide/dist
- name: Extract the PyPa simple repository API
run: python tools/pypa-simple.py pypa/simple ../../../static/pyodide/
- name: Upload the PyPa repository artifact
uses: actions/upload-artifact@v4
with:
name: pypa
path: pypa
retention-days: 1
build-lock:
runs-on: ubuntu-latest
needs: [build-pyodide, build-pypa]
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache the Pyodide Docker image
uses: ScribeMD/docker-cache@0.5.0
with:
key: docker-pyodide-${{ hashFiles('pyodide/Dockerfile') }}
read-only: true
- name: Discover the cached Pyodide Docker image
run: echo "PYODIDE_DOCKER_IMAGE=$(docker images climet-eu/pyodide --format '{{.ID}}')" >> $GITHUB_ENV
- name: Download the Pyodide distribution artifact
uses: actions/download-artifact@v4
with:
name: pyodide
path: pyodide/static/pyodide
- name: Download the PyPa repository artifact
uses: actions/download-artifact@v4
with:
name: pypa
path: pyodide/pypa
- name: Extract the PyPi-enabled pyodide-lock.json
run: |
cp venv/requirements.txt pyodide/my-requirements.txt
cp tools/pypi-lock.mjs pyodide/static/pyodide/pypi-lock.mjs
cd pyodide
./run_docker --non-interactive python -m http.server "&" node static/pyodide/pypi-lock.mjs my-requirements.txt pyodide-lock.json
- name: Upload the PyPi pyodide-lock.json artifact
uses: actions/upload-artifact@v4
with:
name: pypi-pyodide-lock.json
path: pyodide/pyodide-lock.json
retention-days: 1
check-venv:
runs-on: ubuntu-latest
needs: build-lock
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12.7"
- name: Install PyYAML
run: pip install PyYAML
- name: Download the PyPi pyodide-lock.json artifact
uses: actions/download-artifact@v4
with:
name: pypi-pyodide-lock.json
path: pyodide/dist
- name: Extract the requirements from the Pyodide build
run: python tools/requirements.py
- name: Check that the venv requirements are up-to-date
run: git diff --exit-code ./venv/
- name: Check the requirements.txt file
continue-on-error: ${{ github.event_name != 'release' }}
run: |
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r venv/requirements.txt --dry-run --ignore-installed
deactivate
rm -rf .venv
- name: Check the validity of the constraints.txt and requirements.in files
continue-on-error: ${{ github.event_name != 'release' }}
run: |
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r venv/constraints.txt -r venv/requirements.in --dry-run --ignore-installed
deactivate
rm -rf .venv
build-jupyterlite:
runs-on: ubuntu-latest
needs: [build-pyodide, build-pypa, build-lock]
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12.7"
- name: Install the dependencies
run: |
pip install -r requirements.txt
- name: Prepare the JupyterLite input files
run: |
mkdir -p files
cp ./README.md files/
cp venv/constraints.txt venv/requirements.in venv/requirements.txt files/
mkdir -p static
- name: Download the Pyodide distribution artifact
uses: actions/download-artifact@v4
with:
name: pyodide
path: static/pyodide
- name: Download the PyPi pyodide-lock.json artifact
uses: actions/download-artifact@v4
with:
name: pypi-pyodide-lock.json
path: static/pyodide
- name: Build the JupyterLite site
run: |
jupyter lite build --output-dir staging
cp static/favicons/favicon.ico staging/
find staging/ -name favicon.ico | xargs -L1 cp -f static/favicons/favicon.ico
- name: Download the PyPa repository artifact
uses: actions/download-artifact@v4
with:
name: pypa
path: staging/pypa
- name: Upload the JupyterLite artifact
uses: actions/upload-artifact@v4
with:
name: jupyterlite
path: staging
retention-days: 1
deploy:
permissions:
contents: write
runs-on: ubuntu-latest
needs: [build-jupyterlite, check-venv]
steps:
- name: Get the current branch name
uses: tj-actions/branch-names@v8
id: branch
- name: Compute the current version name
run: echo "CLIMETLAB_VERSION=${{ steps.branch.outputs.current_branch || steps.branch.outputs.tag }}" >> $GITHUB_ENV
- name: Checkout the previous dist branch
uses: actions/checkout@v4
with:
ref: dist
path: dist
continue-on-error: ${{ github.event_name != 'release' }}
- name: Prepare merging the different dist versions
run: |
mkdir -p dist
rm -rf dist/${{ env.CLIMETLAB_VERSION }}
- name: Download the JupyterLite artifact into the dist
uses: actions/download-artifact@v4
with:
name: jupyterlite
path: dist/${{ env.CLIMETLAB_VERSION }}
- name: Deploy to dist branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: dist
publish_dir: ./dist
keep_files: false
force_orphan: true
cleanup:
runs-on: ubuntu-latest
needs: deploy
if: always()
steps:
- name: Delete the build artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: |
pyodide
pypa
jupyterlite
failOnError: false