forked from sympy/sympy
-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (155 loc) · 6.49 KB
/
emscripten.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
# Adapted from NumPy https://github.com/numpy/numpy/pull/25894
# https://github.com/numpy/numpy/blob/d2d2c25fa81b47810f5cbd85ea6485eb3a3ffec3/.github/workflows/emscripten.yml
#
name: Pyodide
on: [push, pull_request]
env:
FORCE_COLOR: 3
DURATIONS_CACHE_NAME: sympy_pyodide_test_durations_gha_cache
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
pyodide-test:
name: Test group ${{ matrix.group }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
splits: [4] # keep in sync with number of groups below
group: [1, 2, 3, 4]
env:
PYODIDE_VERSION: 0.27.0a2
# PYTHON_VERSION and EMSCRIPTEN_VERSION are determined by PYODIDE_VERSION.
# The appropriate versions can be found in the Pyodide repodata.json
# "info" field, or in Makefile.envs:
# https://github.com/pyodide/pyodide/blob/main/Makefile.envs#L2
PYTHON_VERSION: 3.12.1
EMSCRIPTEN_VERSION: 3.1.58
NODE_VERSION: 20
steps:
- name: Checkout SymPy
uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up Emscripten toolchain
uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14
with:
version: ${{ env.EMSCRIPTEN_VERSION }}
actions-cache-folder: emsdk-cache
- name: Install pyodide-build
run: pip install pyodide-build
- name: Set up Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Retrieve previous test durations from GHA cache
id: restore-test-durations
uses: actions/cache/restore@v4
with:
path: test_durations_merged.json
key: ${{ env.DURATIONS_CACHE_NAME }}
- name: Rename test duration artifacts
if: steps.restore-test-durations.outputs.cache-hit == 'true'
run: mv test_durations_merged.json .test_durations
- name: Set up Pyodide virtual environment and test SymPy for Pyodide
run: |
# Set up Pyodide virtual environment
pyodide xbuildenv install ${{ env.PYODIDE_VERSION }}
pyodide venv .venv-pyodide
# Activate the virtual environment and install SymPy
source .venv-pyodide/bin/activate
pip install .
# Install dependencies and optional test dependencies
pip install pytest pytest-split hypothesis
pip install matplotlib numpy scipy
# Trigger test suite (slow and tooslow tests are skipped by default)
pytest -svra --pyargs sympy \
--durations 20 \
--splits ${{ matrix.splits }} --group ${{ matrix.group }} \
--store-durations
- name: Move and rename test duration artifacts
if: always()
run: mv .test_durations test_durations_group_${{ matrix.group }}.json
- name: Upload test duration artifacts
if: always()
uses: actions/upload-artifact@v4.4.3
with:
name: pytest_durations_${{ matrix.group }}
path: test_durations_group_${{ matrix.group }}.json
if-no-files-found: error
# dotfiles are hidden by default, so we rename them above
# post actions/upload-artifact@v4.4.0 to make them visible
# and to avoid needing the `include-hidden-files` option
# We delete the previous cache to avoid storing outdated test durations.
# This is currently not possible to do with the actions/cache action:
# https://github.com/actions/toolkit/issues/505
# https://github.com/actions/cache/issues/342
#
# so we use the gh cache CLI to get around this limitation and delete
# any previous test durations before saving new ones. This exists
# as a separate job in order to scope run permissions differently
# from other jobs for security reasons.
delete-test-durations-caches:
name: Delete previous test duration caches
runs-on: ubuntu-latest
needs: [pyodide-test]
permissions:
contents: read
actions: write # to allow deletion of caches
if: always() && github.event_name == 'pull_request'
steps:
# Don't fail if the cache doesn't exist or if there are
# insufficient permissions to delete it. This is a best-effort
# attempt to delete the cache.
#
# This will fail for PRs from forks opened by contributors
# who do not have write permissions to the repository, but PRs
# via branches from the main repository and PRs from users
# with write access to the repository will succeed.
- name: Delete previous cached test durations
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ env.DURATIONS_CACHE_NAME }} \
-R ${{ github.repository }} \
-B ${{ github.head_ref }} \
--confirm || true
env:
GH_TOKEN: ${{ github.token }}
# We will collect the test durations from all groups in this job
# and merge them into a single file. Once all groups have finished,
# we will save the merged file as a persistent cache that GHA will
# retrieve in the next run.
handle-test-durations-files:
name: Merge and cache new test durations
runs-on: ubuntu-22.04
needs: [delete-test-durations-caches]
if: always()
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4.1.8
with:
path: all_test_durations
merge-multiple: true
- name: Merge test duration artifacts
shell: bash
run: |
# Move all test duration files to the root directory
mv all_test_durations/*.json .
# All four files are JSON. We use JQ to merge them into one JSON file.
jq -s 'add' test_durations_group_*.json > test_durations_merged.json
- name: Save test durations as an artifact for debugging
uses: actions/upload-artifact@v4.4.3
with:
name: test_durations_merged
path: test_durations_merged.json
if-no-files-found: error
- name: Cache test durations file for subsequent runs
uses: actions/cache/save@v4
with:
path: test_durations_merged.json
key: ${{ env.DURATIONS_CACHE_NAME }}