-
Notifications
You must be signed in to change notification settings - Fork 8
238 lines (202 loc) · 7.67 KB
/
build.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
name: Build Recipes
on:
push:
branches: [ main ]
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: write
env:
# Increase this value to reset cache if environment.yml has not changed
CONDA_CACHE_NUMBER: 0
# Increase this value to reset cache if emscripten_version has not changed
EMSDK_CACHE_FOLDER: 'emsdk-cache'
EMSDK_CACHE_NUMBER: 0
CCACHE_DIR: /tmp/.ccache
CCACHE_CACHE_NUMBER: 0
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Emscripten ccache
shell: bash -l {0}
run: |
# FIXME: Installing ccache using `emsdk install ccache-git-emscripten-64bit` doesn't work well in conda env:
# https://stackoverflow.com/questions/71340058/conda-does-not-look-for-libpthread-and-libpthread-nonshared-at-the-right-place-w
git clone https://github.com/juj/ccache -b emscripten --depth 1
cd ccache
cmake .
make ccache
export PATH=$(pwd):$PATH
cd ..
which ccache
- name: Cache conda
uses: actions/cache@v2
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CONDA_CACHE_NUMBER }}-${{
hashFiles('environment.yml') }}
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: pyodide-env
use-mamba: true
- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache Conda env
id: conda-cache
uses: actions/cache@v2
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}-${{ steps.get-date.outputs.today }}-${{ hashFiles('environment.yml') }}-${{ env.CONDA_CACHE_NUMBER }}
- name: Update environment if cache miss
run:
mamba env update -n pyodide-env -f environment.yml
if: steps.conda-cache.outputs.cache-hit != 'true'
- name: Install latest pyodide-build and build dependencies
shell: bash -l {0}
run : |
which python
python -m pip install git+https://github.com/pyodide/pyodide.git@main#subdirectory=pyodide-build
pyodide xbuildenv install --download --url http://pyodide-cache.s3-website-us-east-1.amazonaws.com/xbuildenv/dev/xbuildenv.tar.bz2
- name: Check emscripten version
shell: bash -l {0}
run: |
echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV
- name: Cache emsdk
uses: actions/cache@v2
with:
path: ${{env.EMSDK_CACHE_FOLDER}}
key: ${{env.EMSDK_CACHE_NUMBER}}-${{env.EMSCRIPTEN_VERSION}}-${{ runner.os }}
- uses: mymindstorm/setup-emsdk@v11
with:
version: ${{ env.EMSCRIPTEN_VERSION }}
actions-cache-folder: ${{env.EMSDK_CACHE_FOLDER}}
- name: Set ccache suffix
shell: bash -l {0}
run: |
# This step makes the cache key in the main branch and PRs different.
# main branch run a full build, while PRs run a partial build
# so we keep the ccache cache separate
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo CCACHE_SUFFIX="-pr" >> $GITHUB_ENV
fi
- name: Cache ccache
uses: actions/cache@v2
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ env.CCACHE_DIR }}-${{ env.CCACHE_CACHE_NUMBER }}-${{ env.EMSCRIPTEN_VERSION }}-${{ runner.os }}${{ env.CCACHE_SUFFIX }}
restore-keys: |
${{ env.CCACHE_DIR }}-${{ env.CCACHE_CACHE_NUMBER }}-${{ env.EMSCRIPTEN_VERSION }}-${{ runner.os }}
- name: Calculate recipes to build (pull_request)
if: github.event_name == 'pull_request'
id: calculate_recipes_pr
shell: bash -l {0}
run: |
export CHANGED_RECIPES=$(python ./tools/calc_diff.py \
--base origin/${{ github.event.pull_request.base.ref }} \
--target ${{ github.sha }})
echo "Changed recipes: $CHANGED_RECIPES"
# If there are no changed recipes, we build only core packages sets
if [ -z "$CHANGED_RECIPES" ]; then
echo "recipes=tag:core" >> "$GITHUB_OUTPUT"
else
echo "recipes=$CHANGED_RECIPES,tag:core" >> "$GITHUB_OUTPUT"
fi
- name: Build recipes (full)
shell: bash -l {0}
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[full build]') }}
run: |
ccache -z
export _EMCC_CACHE=1
export PIP_CONSTRAINT=$(pwd)/tools/constraints.txt
pyodide build-recipes "*" --install --install-dir=./repodata
ccache -s
- name: Build recipes (changed only)
shell: bash -l {0}
if: github.event_name == 'pull_request' && !contains(github.event.head_commit.message, '[full build]')
run: |
ccache -z
export _EMCC_CACHE=1
export PIP_CONSTRAINT=$(pwd)/tools/constraints.txt
pyodide build-recipes ${{ steps.calculate_recipes_pr.outputs.recipes }} --install --install-dir=./repodata
ccache -s
- name: Store artifacts build
uses: actions/upload-artifact@v2
with:
name: repodata
path: ./repodata/
retention-days: 15
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
./repodata/*.whl
test:
runs-on: ubuntu-latest
needs: [build]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
test-config: [
{runner: selenium, runtime: chrome, runtime-version: latest },
]
steps:
- uses: actions/checkout@v3
- name: Cache conda
uses: actions/cache@v2
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CONDA_CACHE_NUMBER }}-${{
hashFiles('environment.yml') }}
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: pyodide-env
environment-file: environment.yml
channels: conda-forge
use-only-tar-bz2: true
- name: Download latest Pyodide
shell: bash -l {0}
run: |
wget http://pyodide-cache.s3-website-us-east-1.amazonaws.com/xbuildenv/dev/pyodide-core.tar.bz2
tar -xvf pyodide-core.tar.bz2
mv pyodide dist
- uses: pyodide/pyodide-actions/install-browser@v1
with:
runner: ${{ matrix.test-config.runner }}
browser: ${{ matrix.test-config.runtime }}
browser-version: ${{ matrix.test-config.runtime-version }}
- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: repodata
path: ./repodata/
- name: Copy repodata
run: |
cp ./repodata/* ./dist/
- name: Run tests
shell: bash -l {0}
run: |
# FIXME: don't skip webworker tests
# FIXKE: don't skip cpp_exception tests
pytest -v \
--dist-dir=./dist/ \
--runner=${{ matrix.test-config.runner }} \
--rt ${{ matrix.test-config.runtime }} \
-k "not webworker and not cpp_exception and not triangulation and not cartopy" \
packages