From d8b9073f47588b66cbe508ad24b7f9743a3306f8 Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Wed, 7 Aug 2024 17:58:50 -0400 Subject: [PATCH] Faster graalpy build (#85) * Revert "Revert "parallelize build on linux"" This reverts commit 0cebe7b43f7c037acdec68733df56bba2898c160. * Revert "Revert "set parallel shell"" This reverts commit 4faaa1b459b5599b8d151cada2903485dc91c609. * Revert "Revert "Revert "set parallel shell""" This reverts commit 659345b53fe94c1f88eebbc2d3efb7d2b8483cc7. * Revert "Revert "Revert "parallelize build on linux""" This reverts commit e51c7648935e27d53df9c46191a682c898039339. * split linux into different jobs * tweak * fix syntax --- .github/workflows/repackage_graalpy.yml | 230 ++++++++++++------------ scripts/repackage_graalpy.sh | 16 +- 2 files changed, 128 insertions(+), 118 deletions(-) diff --git a/.github/workflows/repackage_graalpy.yml b/.github/workflows/repackage_graalpy.yml index d3efe4aa..3167d0c5 100644 --- a/.github/workflows/repackage_graalpy.yml +++ b/.github/workflows/repackage_graalpy.yml @@ -1,115 +1,117 @@ -name: Repackage GraalPy - -on: - workflow_dispatch: - inputs: - graalpy_version: - required: true - type: string - platforms: - required: true - type: string - default: "linux-x86_64,linux-aarch64,macos,windows" - workflow_call: - inputs: - graalpy_version: - required: true - type: string - platforms: - required: true - type: string - -env: - image_map: '{"x86_64": "amd64/ubuntu:20.04", "aarch64": "arm64v8/ubuntu:20.04"}' - -jobs: - build_linux: - name: Linux ${{ inputs.graalpy_version }} ${{ matrix.arch }} - if: ${{ contains(inputs.platforms, 'linux') }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - arch: [x86_64, aarch64] - exclude: - - arch: ${{ !contains(inputs.platforms, 'linux-x86_64') && 'x86_64' || '' }} - - arch: ${{ !contains(inputs.platforms, 'linux-aarch64') && 'aarch64' || '' }} - - steps: - - name: Parse image - id: parse_image - run: | - IMAGE=$(echo ${{ toJSON(env.image_map) }} | jq -r '.["${{ matrix.arch }}"]') - echo "image=$IMAGE" >> "$GITHUB_OUTPUT" - - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Repackage - run: | - export DOCKER_IMAGE="${{ steps.parse_image.outputs.image }}" - ./scripts/repackage_graalpy.sh ${{ matrix.arch }} ${{ inputs.graalpy_version }} linux - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: graalpy-linux-${{ matrix.arch }}-${{ inputs.graalpy_version }} - path: ./graalpy*.zip - - build_windows: - name: Windows ${{ inputs.graalpy_version }} x86_64 - if: ${{ contains(inputs.platforms, 'windows') }} - runs-on: windows-latest - - steps: - - name: Set git to use LF - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - - name: Checkout - uses: actions/checkout@v4 - - - name: Repackage - shell: bash - run: | - set -ex - ./scripts/repackage_graalpy.sh x86_64 ${{ inputs.graalpy_version }} windows - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: graalpy-windows-x86_64-${{ inputs.graalpy_version }} - path: ./graalpy*.zip - - build_macos: - name: MacOS ${{ inputs.graalpy_version }} ${{ matrix.arch }} - if: ${{ contains(inputs.platforms, 'macos') }} - runs-on: ${{ matrix.runner }} - strategy: - fail-fast: false - matrix: - arch: [x86_64, aarch64] - include: - - arch: x86_64 - runner: macos-12 - - arch: aarch64 - runner: macos-14 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Repackage - run: | - set -ex - ./scripts/repackage_graalpy.sh ${{ matrix.arch }} ${{ inputs.graalpy_version }} darwin - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: graalpy-darwin-${{ matrix.arch }}-${{ inputs.graalpy_version }} +name: Repackage GraalPy + +on: + workflow_dispatch: + inputs: + graalpy_version: + required: true + type: string + platforms: + required: true + type: string + default: "linux-x86_64,linux-aarch64,macos,windows" + workflow_call: + inputs: + graalpy_version: + required: true + type: string + platforms: + required: true + type: string + +env: + image_map: '{"x86_64": "amd64/ubuntu:20.04", "aarch64": "arm64v8/ubuntu:20.04"}' + +jobs: + build_linux: + name: Linux ${{ inputs.graalpy_version }} ${{ matrix.distribution }} ${{ matrix.arch }} + if: ${{ contains(inputs.platforms, 'linux') }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + arch: [x86_64, aarch64] + distribution: [standard, jvm, community, community-jvm] + exclude: + - arch: ${{ !contains(inputs.platforms, 'linux-x86_64') && 'x86_64' || '' }} + - arch: ${{ !contains(inputs.platforms, 'linux-aarch64') && 'aarch64' || '' }} + + steps: + - name: Parse image + id: parse_image + run: | + IMAGE=$(echo ${{ toJSON(env.image_map) }} | jq -r '.["${{ matrix.arch }}"]') + echo "image=$IMAGE" >> "$GITHUB_OUTPUT" + + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Repackage + run: | + export DOCKER_IMAGE="${{ steps.parse_image.outputs.image }}" + export MATRIX_DISTRIBUTION="${{ matrix.distribution }}" + ./scripts/repackage_graalpy.sh ${{ matrix.arch }} ${{ inputs.graalpy_version }} linux + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: graalpy-linux-${{ matrix.distribution }}-${{ matrix.arch }}-${{ inputs.graalpy_version }} + path: ./graalpy*.zip + + build_windows: + name: Windows ${{ inputs.graalpy_version }} x86_64 + if: ${{ contains(inputs.platforms, 'windows') }} + runs-on: windows-latest + + steps: + - name: Set git to use LF + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - name: Checkout + uses: actions/checkout@v4 + + - name: Repackage + shell: bash + run: | + set -ex + ./scripts/repackage_graalpy.sh x86_64 ${{ inputs.graalpy_version }} windows + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: graalpy-windows-x86_64-${{ inputs.graalpy_version }} + path: ./graalpy*.zip + + build_macos: + name: MacOS ${{ inputs.graalpy_version }} ${{ matrix.arch }} + if: ${{ contains(inputs.platforms, 'macos') }} + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + arch: [x86_64, aarch64] + include: + - arch: x86_64 + runner: macos-12 + - arch: aarch64 + runner: macos-14 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Repackage + run: | + set -ex + ./scripts/repackage_graalpy.sh ${{ matrix.arch }} ${{ inputs.graalpy_version }} darwin + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: graalpy-darwin-${{ matrix.arch }}-${{ inputs.graalpy_version }} path: ./graalpy*.zip \ No newline at end of file diff --git a/scripts/repackage_graalpy.sh b/scripts/repackage_graalpy.sh index afba169e..21817846 100755 --- a/scripts/repackage_graalpy.sh +++ b/scripts/repackage_graalpy.sh @@ -93,7 +93,15 @@ function repackage_graal () { echo "::endgroup::" } -repackage_graal -repackage_graal jvm -repackage_graal community -repackage_graal community-jvm \ No newline at end of file +if [[ "${PLATFORM}" == "linux" ]]; then + if [[ "${MATRIX_DISTRIBUTION}" == "standard" ]]; then + repackage_graal + else + repackage_graal "${MATRIX_DISTRIBUTION}" + fi +else + repackage_graal + repackage_graal jvm + repackage_graal community + repackage_graal community-jvm +fi \ No newline at end of file