Repository navigation
Add Pyodide WebAssembly wheel support #1450
Workflow file for this run
This file contains hidden or 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: Build | |
| on: [push, pull_request] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | |
| with: | |
| python-version: '3.12' | |
| - run: | | |
| python -m pip install setuptools pylint | |
| python -m pip install -e . | |
| - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 | |
| with: | |
| extra_args: pylint --all-files | |
| build_sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Build sdist | |
| run: | | |
| python -m pip install --user build | |
| python -m build --sdist | |
| - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: source | |
| path: dist/*.tar.gz | |
| build_wheels: | |
| needs: build_sdist | |
| name: Build wheel ${{ matrix.py }}-${{ matrix.platform.wheel_tag }} on ${{ matrix.platform.os }} | |
| runs-on: ${{ matrix.platform.os }} | |
| strategy: | |
| matrix: | |
| py: [cp312, cp313, cp314] | |
| platform: | |
| - { arch: x86_64, os: windows-latest, wheel_tag: win_amd64 } | |
| - { arch: x86_64, os: macos-15-intel, wheel_tag: macosx_x86_64 } | |
| - { arch: arm64, os: macos-latest, wheel_tag: macosx_arm64 } | |
| - { arch: x86_64, os: ubuntu-latest, wheel_tag: manylinux_x86_64 } | |
| - { arch: aarch64, os: ubuntu-24.04-arm, wheel_tag: manylinux_aarch64 } | |
| steps: | |
| - name: Download source distribution | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: source | |
| - name: Unpack source distribution | |
| shell: bash | |
| run: tar --strip-components 1 -xvf *.tar.gz | |
| - name: Build wheel | |
| uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0 | |
| with: | |
| output-dir: wheelhouse | |
| env: | |
| CIBW_ARCHS_MACOS: ${{ matrix.platform.arch }} | |
| CIBW_BUILD: ${{ matrix.py }}-${{ matrix.platform.wheel_tag }} | |
| CIBW_TEST_COMMAND: python -m unittest discover -v -s {package}/tests | |
| CIBW_BUILD_VERBOSITY: 1 | |
| MACOSX_DEPLOYMENT_TARGET: ${{ matrix.platform.arch == 'arm64' && '11' || '10.14' }} | |
| - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: ${{ matrix.py }}-${{ matrix.platform.wheel_tag }} | |
| path: ./wheelhouse/*.whl | |
| build_pyodide: | |
| name: Build Pyodide wheel | |
| needs: build_sdist | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download source distribution | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: source | |
| - name: Unpack source distribution | |
| run: tar --strip-components 1 -xvf *.tar.gz | |
| - name: Build and test wheel | |
| uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0 | |
| env: | |
| CIBW_PLATFORM: pyodide | |
| CIBW_BUILD: cp314-pyodide_wasm32 | |
| CIBW_TEST_COMMAND: >- | |
| python -c "import pypcode; assert pypcode.Context('x86:LE:64:default').translate(b'\xc3').ops" | |
| - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: cp314-pyodide_wasm32 | |
| path: ./wheelhouse/*.whl | |
| build_docs: | |
| name: Build docs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | |
| with: | |
| python-version: '3.12' | |
| - run: | | |
| pip install -e .[docs] | |
| cd docs && make html coverage | |
| test_coverage: | |
| name: Test with coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | |
| with: | |
| python-version: '3.13' | |
| - name: Run tests | |
| run: | | |
| pip install setuptools nanobind cmake | |
| COVERAGE=1 pip install --no-build-isolation -e .[testing] | |
| pytest -vv \ | |
| --junitxml=junit.xml -o junit_family=legacy \ | |
| --cov-report=xml \ | |
| || [[ $? -lt 2 ]] # Accept success and test failures, fail on infrastructure problems (exit codes >1) | |
| gcovr -r . \ | |
| --print-summary \ | |
| --xml-pretty \ | |
| -o coverage-native.xml \ | |
| --gcov-filter 'pypcode_native.cpp' | |
| [[ -e ./junit.xml && -e coverage.xml && -e ./coverage-native.xml ]] | |
| - name: Upload test results | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: results | |
| include-hidden-files: true | |
| if-no-files-found: error | |
| path: | | |
| ./junit.xml | |
| ./coverage.xml | |
| ./coverage-native.xml | |
| upload_coverage: | |
| name: Upload test results to Codecov | |
| needs: [test_coverage] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: results | |
| - name: Upload test coverage to Codecov | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| use_oidc: true | |
| fail_ci_if_error: true | |
| verbose: true | |
| files: ./coverage.xml ./coverage-native.xml | |
| - name: Upload test results to Codecov | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| use_oidc: true | |
| fail_ci_if_error: true | |
| verbose: true | |
| files: ./junit.xml | |
| report_type: test_results | |
| upload_pypi: | |
| name: Upload wheels to PyPI | |
| needs: [lint, build_docs, build_sdist, build_wheels, build_pyodide, upload_coverage] | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/pypcode | |
| permissions: | |
| id-token: write | |
| runs-on: ubuntu-latest | |
| # Upload to PyPI on every tag starting with 'v' | |
| if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| path: artifacts | |
| - run: | | |
| mkdir dist | |
| find artifacts -type f \( -name '*.whl' -o -name '*.tar.gz' \) -exec mv {} dist \; | |
| - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |