|
| 1 | +name: Run Pyodide CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +env: |
| 8 | + FORCE_COLOR: 3 |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 12 | + # cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + env: |
| 18 | + PYODIDE_VERSION: "https://github.com/pyodide/pyodide-build-environment-nightly/releases/download/20250523-emscripten_4.0.9/xbuildenv.tar.bz2" |
| 19 | + PYTHON_VERSION: 3.13 # any 3.13.x version works |
| 20 | + EMSCRIPTEN_VERSION: 4.0.9 |
| 21 | + NODE_VERSION: 22 |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 24 | + |
| 25 | + - name: Set up Python ${{ env.PYTHON_VERSION }} |
| 26 | + uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 |
| 27 | + with: |
| 28 | + python-version: ${{ env.PYTHON_VERSION }} |
| 29 | + |
| 30 | + - name: Set up Emscripten toolchain |
| 31 | + uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 |
| 32 | + with: |
| 33 | + version: ${{ env.EMSCRIPTEN_VERSION }} |
| 34 | + actions-cache-folder: emsdk-cache |
| 35 | + |
| 36 | + - name: Set up Node.js |
| 37 | + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 |
| 38 | + with: |
| 39 | + node-version: ${{ env.NODE_VERSION }} |
| 40 | + |
| 41 | + - name: Install pyodide-build |
| 42 | + run: | |
| 43 | + pip install pyodide-build |
| 44 | + pyodide xbuildenv install --url ${{ env.PYODIDE_VERSION }} |
| 45 | +
|
| 46 | + - name: Restore WASM library directory from cache |
| 47 | + id: cache-wasm-library-dir |
| 48 | + uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 |
| 49 | + with: |
| 50 | + path: ${{ github.workspace }}/wasm-library-dir |
| 51 | + key: wasm-library-dir-${{ hashFiles('bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 |
| 52 | + |
| 53 | + - name: Build GMP, MPFR and FLINT |
| 54 | + if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true' |
| 55 | + env: |
| 56 | + CFLAGS: "-fPIC" |
| 57 | + run: bin/pyodide_build_dependencies.sh --wasm-library-dir ${{ github.workspace }}/wasm-library-dir |
| 58 | + |
| 59 | + - name: Persist WASM library directory to cache |
| 60 | + uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 |
| 61 | + with: |
| 62 | + path: ${{ github.workspace }}/wasm-library-dir |
| 63 | + key: wasm-library-dir-${{ hashFiles('bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 |
| 64 | + |
| 65 | + - name: Restore python-flint build directory from cache |
| 66 | + uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 |
| 67 | + with: |
| 68 | + path: ${{ github.workspace }}/flint_wasm_build |
| 69 | + key: flint-wasm-build-${{ hashFiles('**/meson.build', '**/pyproject.toml', '**/setup.py') }} |
| 70 | + |
| 71 | + - name: Build python-flint |
| 72 | + env: |
| 73 | + WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir |
| 74 | + run: | |
| 75 | + export PKG_CONFIG_PATH="${{ env.WASM_LIBRARY_DIR }}/lib/pkgconfig:${PKG_CONFIG_PATH}" |
| 76 | + export CFLAGS="-I${{ env.WASM_LIBRARY_DIR }}/include ${CFLAGS:-}" |
| 77 | + export LDFLAGS="-L${{ env.WASM_LIBRARY_DIR }}/lib -lflint -lmpfr -lgmp ${LDFLAGS:-}" |
| 78 | +
|
| 79 | + echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" |
| 80 | + echo "CFLAGS=${CFLAGS}" |
| 81 | + echo "LDFLAGS=${LDFLAGS}" |
| 82 | +
|
| 83 | + pkg-config --modversion python3 |
| 84 | + pkg-config --modversion mpfr |
| 85 | + pkg-config --modversion flint |
| 86 | +
|
| 87 | + pyodide build -Cbuild-dir=flint_wasm_build -Csetup-args="-Dflint_version_check=false" |
| 88 | +
|
| 89 | + - name: Persist python-flint build directory to cache |
| 90 | + uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 |
| 91 | + with: |
| 92 | + path: ${{ github.workspace }}/flint_wasm_build |
| 93 | + key: flint-wasm-build-${{ hashFiles('**/meson.build', '**/pyproject.toml', '**/setup.py') }} |
| 94 | + |
| 95 | + - name: Set up Pyodide virtual environment and test python-flint |
| 96 | + run: | |
| 97 | + pyodide venv .venv-pyodide |
| 98 | +
|
| 99 | + source .venv-pyodide/bin/activate |
| 100 | + pip install dist/*.whl |
| 101 | +
|
| 102 | + cd doc |
| 103 | +
|
| 104 | + pip install pytest hypothesis |
| 105 | + # Don't use the cache provider plugin, as it doesn't work with Pyodide |
| 106 | + # right now: https://github.com/pypa/cibuildwheel/issues/1966 |
| 107 | + pytest -svra -p no:cacheprovider --pyargs flint |
0 commit comments