Test against Pyodide / Emscripten in CI #3546
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Hypothesis CI | |
env: | |
# Tell pytest and other tools to produce coloured terminal output. | |
# Make sure this is also in the "passenv" section of the tox config. | |
PY_COLORS: 1 | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
# Cancel in-progress PR builds if another commit is pushed. | |
# On non-PR builds, fall back to the globally-unique run_id and don't cancel. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
# Cribbing from https://github.com/numpy/numpy/blob/9a650391651c8486d8cb8b27b0e75aed5d36033e/.github/workflows/emscripten.yml | |
test-pyodide: | |
runs-on: ubuntu-22.04 | |
env: | |
PYODIDE_VERSION: 0.25.0 | |
# 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.11.7 | |
EMSCRIPTEN_VERSION: 3.1.53 | |
NODE_VERSION: 18 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: set up python | |
id: setup-python | |
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 | |
with: | |
version: ${{ env.EMSCRIPTEN_VERSION }} | |
actions-cache-folder: emsdk-cache | |
- name: Install pyodide-build | |
run: pip install "pydantic<2" pyodide-build==$PYODIDE_VERSION | |
- name: Build | |
run: | | |
cd hypothesis-python/ | |
CFLAGS=-g2 LDFLAGS=-g2 pyodide build | |
- name: set up node | |
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Set up Pyodide virtual environment and install dependencies | |
run: | | |
pip install --upgrade setuptools pip wheel | |
python hypothesis-python/setup.py bdist_wheel | |
pip download --dest=dist/ hypothesis-python/ pytest tzdata # fetch all the wheels | |
rm dist/packaging-*.whl # fails with `invalid metadata entry 'name'` | |
pyodide venv .venv-pyodide | |
source .venv-pyodide/bin/activate | |
python -c "import sys; print(sys.platform)" | |
pip install dist/*.whl | |
- name: Run tests | |
run: | | |
source .venv-pyodide/bin/activate | |
python -m pytest hypothesis-python/tests/cover | |
# run: python -m pytest --numprocesses auto hypothesis-python/tests/ --ignore=hypothesis-python/tests/quality/ --ignore=hypothesis-python/tests/ghostwriter/ --ignore=hypothesis-python/tests/patching/ |