summaryrefslogtreecommitdiff
path: root/.github/workflows/emscripten.yml
blob: 5f01e72b2e444126c993df4b0064ef88fc634798 (plain)
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
# To enable this workflow on a fork, comment out:
#
# if: github.repository == 'numpy/numpy'
name: Test Emscripten/Pyodide build

on:
  pull_request:
    branches:
      - main
      - maintenance/**

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

permissions:
  contents: read # to fetch code (actions/checkout)

jobs:
  build-wasm-emscripten:
    runs-on: ubuntu-22.04
    if: "github.repository == 'numpy/numpy'"
    env:
      PYODIDE_VERSION: 0.23.1
      # 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.2
      EMSCRIPTEN_VERSION: 3.1.32
      NODE_VERSION: 18
    steps:
      - name: Checkout numpy
        uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
        with:
          submodules: true
          # versioneer.py requires the latest tag to be reachable. Here we
          # fetch the complete history to get access to the tags.
          # A shallow clone can work when the following issue is resolved:
          # https://github.com/actions/checkout/issues/338
          fetch-depth: 0

      - name: set up python
        id: setup-python
        uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}

      - uses: mymindstorm/setup-emsdk@ab889da2abbcbb280f91ec4c215d3bb4f3a8f775 # v12
        with:
          version: ${{ env.EMSCRIPTEN_VERSION }}
          actions-cache-folder: emsdk-cache

      - name: Install pyodide-build
        run: pip install pyodide-build==$PYODIDE_VERSION

      - name: Build
        run: CFLAGS=-g2 LDFLAGS=-g2 pyodide build

      - name: set up node
        uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
        with:
          node-version: ${{ env.NODE_VERSION }}

      - name: Set up Pyodide virtual environment
        run: |
          pyodide venv .venv-pyodide
          source .venv-pyodide/bin/activate
          pip install dist/*.whl
          pip install -r test_requirements.txt
      - name: Test
        run: |
          source .venv-pyodide/bin/activate
          cd ..
          python numpy/runtests.py -n -vv