From 8fdb1791e8fdfa9f47b36a42d4adb109daf1bf17 Mon Sep 17 00:00:00 2001 From: Zsolt Dollenstein Date: Sat, 3 Feb 2024 10:11:39 +0000 Subject: [PATCH] ci: build linux-arm64 wheels using emulation Stop using self-hosted runner --- .github/workflows/build.yml | 33 +++++++++++-------------------- .github/workflows/pypi_upload.yml | 4 ++-- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 38e95c36..393ef407 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,29 +4,13 @@ on: jobs: # Build python wheels - build_matrix: - name: Prepare job matrix for build job - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} - steps: - - uses: actions/checkout@v4 - - id: set-matrix - # match github.ref to the on_ref_regex field in the json - # to skip running linux/aarch64 builds on PRs - run: | - matrix=$(jq --arg ref "${{ github.ref }}" \ - 'map(select(.on_ref_regex as $pat | $pat == null or ($ref | test($pat))) | del(.on_ref_regex))' \ - .github/build-matrix.json) - echo matrix={\"include\":$(echo $matrix)}\" >> $GITHUB_OUTPUT - build: - name: Build wheels on ${{ join(matrix.os, '/') }}/${{ matrix.vers }} - needs: build_matrix + name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false - matrix: ${{fromJson(needs.build_matrix.outputs.matrix)}} + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] env: SCCACHE_VERSION: 0.2.13 CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | env -u CARGO_HOME sh -s -- --default-toolchain stable --profile minimal -y" @@ -36,22 +20,27 @@ jobs: CIBW_BEFORE_ALL_WINDOWS: "rustup target add x86_64-pc-windows-msvc i686-pc-windows-msvc" CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin" LIBCST_NO_LOCAL_SCHEME=$LIBCST_NO_LOCAL_SCHEME' CIBW_SKIP: "cp27-* cp34-* cp35-* pp* *-win32 *-win_arm64 *-musllinux_*" - CIBW_ARCHS: ${{ matrix.vers }} + CIBW_ARCHS_LINUX: auto aarch64 + CIBW_ARCHS_MACOS: x86_64 arm64 CIBW_BUILD_VERBOSITY: 1 steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-python@v5 - if: ${{ !contains(matrix.os, 'self-hosted') }} with: cache: pip cache-dependency-path: "pyproject.toml" - python-version: "3.10" + python-version: "3.12" - name: Disable scmtools local scheme if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} run: >- echo LIBCST_NO_LOCAL_SCHEME=1 >> $GITHUB_ENV + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-quemu-action@v3 + with: + platforms: all - name: Build wheels uses: pypa/cibuildwheel@v2.16.5 - uses: actions/upload-artifact@v4 diff --git a/.github/workflows/pypi_upload.yml b/.github/workflows/pypi_upload.yml index c4ed262e..1bff6cef 100644 --- a/.github/workflows/pypi_upload.yml +++ b/.github/workflows/pypi_upload.yml @@ -4,14 +4,14 @@ on: release: types: [published] push: - branches: [main] + branches: [main, pr1102] permissions: contents: read jobs: build: - uses: Instagram/LibCST/.github/workflows/build.yml@main + uses: Instagram/LibCST/.github/workflows/build.yml@pr1102 upload_release: name: Upload wheels to pypi runs-on: ubuntu-latest