Fix memory leak and bump V8 version #393
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: pypi-build | |
| on: | |
| # For PRs: | |
| pull_request: {} | |
| # For releases: | |
| push: | |
| branches: | |
| - 'release/*' | |
| concurrency: | |
| group: build-${{ github.head_ref }} | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| sdist: | |
| name: Build sdist | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: astral-sh/setup-uv@v7 | |
| - uses: actions/checkout@v3 | |
| with: | |
| # Fetch all tags | |
| fetch-depth: 0 | |
| - name: Build | |
| run: uv build --sdist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist/* | |
| if-no-files-found: error | |
| build-dll: | |
| name: Build dll for ${{ matrix.config.name }} | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - name: win-x64_64 | |
| os: windows-2022 | |
| target_cpu: x64 | |
| - name: win-aarch64 | |
| os: windows-2022 | |
| target_cpu: arm64 | |
| - name: linux-x64_64 | |
| os: ubuntu-24.04 | |
| target_cpu: x64 | |
| - name: linux-aarch64 | |
| os: ubuntu-24.04 | |
| target_cpu: arm64 | |
| - name: macos-x64_64 | |
| os: macos-15-intel | |
| target_cpu: x64 | |
| - name: macos-aarch64 | |
| os: macos-15 | |
| target_cpu: arm64 | |
| - name: linux-aarch64-musl-compat | |
| os: ubuntu-24.04 | |
| target_cpu: arm64 | |
| steps: | |
| - uses: extractions/setup-just@v3 | |
| - uses: astral-sh/setup-uv@v7 | |
| - uses: actions/checkout@v3 | |
| with: | |
| # Fetch all tags | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| # the v8 build still doesn't work with a system Python > 3.11: | |
| python-version: '3.11' | |
| - run: just git-config-global | |
| - uses: maxim-lobanov/setup-xcode@v1 | |
| if: contains(matrix.config.os, 'macos') | |
| with: | |
| xcode-version: latest-stable | |
| - name: Build dll with v8 | |
| run: just build-dll "--out-path=_dll" "--target-cpu=${{ matrix.config.target_cpu }}" | |
| if: matrix.config.name != 'linux-aarch64-musl-compat' | |
| - name: Build dll with v8 | |
| run: just build-dll "--out-path=_dll" "--target-cpu=${{ matrix.config.target_cpu }}" --aarch64-musl-compat | |
| if: matrix.config.name == 'linux-aarch64-musl-compat' | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dll-${{ matrix.config.name }} | |
| path: _dll | |
| if-no-files-found: error | |
| build-wheel: | |
| name: Build and test wheel for ${{ matrix.config.name }} | |
| needs: build-dll | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - name: win-x64_64 | |
| os: windows-2022 | |
| - name: win-aarch64 | |
| os: windows-11-arm | |
| - name: linux-x64_64 | |
| os: ubuntu-24.04 | |
| - name: linux-aarch64 | |
| os: ubuntu-24.04-arm | |
| - name: macos-x64_64 | |
| os: macos-15-intel | |
| - name: macos-aarch64 | |
| os: macos-15 | |
| steps: | |
| - uses: extractions/setup-just@v3 | |
| if: matrix.config.os != 'windows-11-arm' | |
| - run: choco install just # no Github cargo action for windows-11-arm yet; use choco: | |
| if: matrix.config.os == 'windows-11-arm' | |
| - uses: astral-sh/setup-uv@v7 | |
| - uses: actions/checkout@v3 | |
| with: | |
| # Fetch all tags | |
| fetch-depth: 0 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dll-${{ matrix.config.name }} | |
| path: src/py_mini_racer | |
| - run: just build-wheel | |
| if: matrix.config.os != 'windows-11-arm' | |
| # By default, uv still uses the x86_64 python in emulation on Windows. | |
| # https://github.com/astral-sh/uv/issues/12906 | |
| # Override this behavior to build an actual aarch64 wheel: | |
| - run: UV_PYTHON=arm64 just build-wheel | |
| if: matrix.config.os == 'windows-11-arm' | |
| - name: Test wheel | |
| if: matrix.config.os != 'windows-11-arm' | |
| run: just test-matrix | |
| # As above; uv on Windows aarch64 likes to do emulation by default | |
| # (and uv has no 3.10 Python build): | |
| - name: Test wheel | |
| if: matrix.config.os == 'windows-11-arm' | |
| run: | | |
| uv run --python cpython-3.11-windows-aarch64-none pytest tests | |
| uv run --python cpython-3.12-windows-aarch64-none pytest tests | |
| uv run --python cpython-3.13-windows-aarch64-none pytest tests | |
| uv run --python cpython-3.14-windows-aarch64-none pytest tests | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.config.name }} | |
| path: dist/* | |
| if-no-files-found: error | |
| build-alpine-wheel: | |
| name: Build wheel for ${{ matrix.config.name }} | |
| needs: build-dll | |
| runs-on: ${{ matrix.config.image }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - name: alpine-x64_64 | |
| image: ubuntu-22.04 | |
| dll: linux-x64_64 | |
| - name: alpine-aarch64 | |
| image: ubuntu-22.04-arm | |
| dll: linux-aarch64-musl-compat | |
| container: | |
| image: alpine | |
| options: --user root | |
| # From https://github.com/actions/runner/issues/801?timeline_page=1 | |
| volumes: | |
| - /opt:/opt:rw,rshared | |
| - /opt:/__e/node20:ro,rshared | |
| steps: | |
| # From https://github.com/actions/runner/issues/801?timeline_page=1 | |
| - name: Allow Linux musl containers on ARM64 runners | |
| shell: /bin/sh {0} | |
| if: contains(matrix.config.image, 'arm') | |
| run: | | |
| sed -i "/^ID=/s/alpine/NotpineForGHA/" /etc/os-release | |
| apk add nodejs --update-cache | |
| mkdir /opt/bin | |
| ln -s /usr/bin/node /opt/bin/node | |
| - name: Install deps | |
| shell: /bin/sh {0} | |
| run: | | |
| apk update | |
| apk add bash curl gcompat libgcc uv just | |
| - uses: actions/checkout@v3 | |
| with: | |
| # Fetch all tags | |
| fetch-depth: 0 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dll-${{ matrix.config.dll }} | |
| path: src/py_mini_racer | |
| - run: just build-wheel | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.config.name }} | |
| path: dist/* | |
| if-no-files-found: error | |
| - name: Test wheel | |
| run: | | |
| # We have to use this twisted formulation of sync and then run, splitting | |
| # up what uv normally does for us, because the LD_PRELOAD accidentally | |
| # confuses uv into thinking we're on a glibc Linux and thus it rejects our | |
| # musl wheel. | |
| uv sync --python 3.10 | |
| uv sync --python 3.11 | |
| uv sync --python 3.12 | |
| uv sync --python 3.13 | |
| uv sync --python 3.14 | |
| LD_PRELOAD="/lib/libgcompat.so.0" just test-matrix --frozen | |
| release: | |
| name: Create GitHub release | |
| if: startsWith(github.ref, 'refs/heads/release') | |
| needs: | |
| - build-wheel | |
| - build-alpine-wheel | |
| - sdist | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| - name: Compute release version | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#release/} | |
| echo Version: $VERSION | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Make release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: "wheels/*,sdist/*" | |
| commit: ${{ github.ref }} | |
| tag: ${{ env.VERSION }} | |
| publish: | |
| name: Upload release to PyPI | |
| if: startsWith(github.ref, 'refs/heads/release') | |
| needs: | |
| - release | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/mini-racer | |
| permissions: | |
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
| steps: | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| path: artifacts | |
| - name: List artifacts | |
| run: find artifacts/ | |
| - name: Make dist directory | |
| run: mkdir dist && cp artifacts/wheels-*/*.whl artifacts/sdist/* dist/ | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |