From b35ed862747311d929063e25479b0b02ae44f688 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 17 Jan 2025 16:03:37 +0100 Subject: [PATCH] Drop usage of the ARM64 runners This was a "fun" experiment, but we're not going to use these runners any time soon for the following reasons: 1. Alpine on ARM64 doesn't support Javascript actions, which is pretty much all of them. This was first reported back in 2020 (https://github.com/actions/runner/issues/801), and knowing how these things go it's unlikely to be resolved any time soon. 2. The lack of Alpine support on ARM64 means we have to resort to a somewhat hacky cross-compilation approach to run tests for musl. 3. The runners are flaky and will randomly fail with Docker related errors, and produce a ton of permission errors (https://github.com/orgs/community/discussions/148648#discussioncomment-11858098). 4. Building multi-arch Docker containers is messy and requires a bunch of cargo-cult copy-pasting to get things to work. I don't want to repeat that for the nightly and stable containers _just_ so _some_ people can use those in CI jobs. 5. We already run tests on an ARM64 macOS host, so any ARM related errors are bound to pop up there, making all this effort rather redundant. We'll reconsider using the ARM64 runners at some point in the future when these issues are addressed and building multi-arch containers is made easier. --- .github/workflows/container.yml | 52 +--------------------- .github/workflows/containers.yml | 14 +++++- .github/workflows/push.yml | 12 +---- .github/workflows/release.yml | 12 +---- .github/workflows/runtimes.yml | 74 +++++++++++++++++++------------ .github/workflows/tests.yml | 42 +++++++----------- ci/docker/alpine/Dockerfile | 15 +++++++ ci/docker/debian-amd64/Dockerfile | 25 +++++++++++ ci/docker/debian-arm64/Dockerfile | 27 +++++++++++ ci/docker/fedora/Dockerfile | 12 ++--- ci/linux.sh | 32 ------------- 11 files changed, 150 insertions(+), 167 deletions(-) create mode 100644 ci/docker/alpine/Dockerfile create mode 100644 ci/docker/debian-amd64/Dockerfile create mode 100644 ci/docker/debian-arm64/Dockerfile delete mode 100755 ci/linux.sh diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 60d4c332e..657dd790d 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -14,15 +14,7 @@ env: jobs: build: - name: ${{ inputs.name }}-${{ matrix.target.arch }} build - strategy: - matrix: - target: - - arch: amd64 - runner: ubuntu-24.04 - - arch: arm64 - runner: ubuntu-24.04-arm - runs-on: ${{ matrix.target.runner }} + runs-on: ubuntu-24.04 permissions: contents: read packages: write @@ -33,48 +25,8 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build image - id: build - uses: docker/build-push-action@v5 + - uses: docker/build-push-action@v5 with: context: ci/docker/${{ inputs.name }} - platforms: linux/${{ matrix.target.arch }} push: true tags: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}:${{ inputs.name }} - outputs: type=image,name=${{ env.REGISTRY }}/${{ env.NAMESPACE }},name-canonical=true,push=true - - name: Export digest - run: | - mkdir -p ${{ runner.temp }}/digests - digest="${{ steps.build.outputs.digest }}" - touch "${{ runner.temp }}/digests/${digest#sha256:}" - - name: Upload digest - uses: actions/upload-artifact@v4 - with: - name: digests-${{ inputs.name }}-${{ matrix.target.arch }} - path: ${{ runner.temp }}/digests/* - if-no-files-found: error - retention-days: 1 - - merge: - runs-on: ubuntu-24.04 - needs: - - build - steps: - - name: Download digests - uses: actions/download-artifact@v4 - with: - path: ${{ runner.temp }}/digests - pattern: digests-${{ inputs.name }}-* - merge-multiple: true - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/setup-buildx-action@v3 - - name: Create and push manifest - working-directory: ${{ runner.temp }}/digests - run: | - docker buildx imagetools create \ - -t "${{ env.REGISTRY }}/${{ env.NAMESPACE }}:${{ inputs.name }}" \ - $(printf '${{ env.REGISTRY }}/${{ env.NAMESPACE }}@sha256:%s ' *) diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 63cd47769..35cb8f6b5 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -21,4 +21,16 @@ jobs: fedora: uses: ./.github/workflows/container.yml with: - name: fedora + name: 'fedora' + alpine: + uses: ./.github/workflows/container.yml + with: + name: 'alpine' + debian-amd64: + uses: ./.github/workflows/container.yml + with: + name: 'debian-amd64' + debian-arm64: + uses: ./.github/workflows/container.yml + with: + name: 'debian-arm64' diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 89a678b15..26688b8d1 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -25,15 +25,8 @@ jobs: uses: ./.github/workflows/tests.yml nightly-container: - strategy: - matrix: - target: - - name: linux/amd64 - runner: ubuntu-24.04 - - name: linux/arm64 - runner: ubuntu-24.04-arm - name: ${{ matrix.target.name }} container - runs-on: ${{ matrix.target.runner }} + name: Nightly container + runs-on: ubuntu-24.04 permissions: contents: read packages: write @@ -54,7 +47,6 @@ jobs: - uses: docker/build-push-action@v5 with: context: . - platforms: ${{ matrix.target.name }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfecaac50..ecbe839cb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -104,15 +104,8 @@ jobs: fi container: - strategy: - matrix: - target: - - name: linux/amd64 - runner: ubuntu-24.04 - - name: linux/arm64 - runner: ubuntu-24.04-arm - name: ${{ matrix.target.name }} container - runs-on: ${{ matrix.target.runner }} + name: Container + runs-on: ubuntu-24.04 needs: - docs - runtimes @@ -139,7 +132,6 @@ jobs: - uses: docker/build-push-action@v5 with: context: . - platforms: ${{ matrix.target.name }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/runtimes.yml b/.github/workflows/runtimes.yml index f8dfbb599..ae63385b9 100644 --- a/.github/workflows/runtimes.yml +++ b/.github/workflows/runtimes.yml @@ -9,51 +9,65 @@ env: RUSTUP_TOOLCHAIN: '1.78' jobs: - linux: - strategy: - matrix: - target: - - image: ci:fedora - arch: amd64 - runner: ubuntu-24.04 - - image: ci:fedora - arch: arm64 - runner: ubuntu-24.04-arm - name: ${{ matrix.target.arch }}-linux - runs-on: ${{ matrix.target.runner }} + amd64-linux: + runs-on: ubuntu-24.04 + container: + image: ghcr.io/inko-lang/ci:debian-amd64 + steps: + - uses: actions/checkout@v4 + - name: Build runtimes + run: bash ci/runtimes.sh amd64-linux + - uses: actions/upload-artifact@v4 + with: + name: amd64-linux + path: tmp/runtimes/*.tar.gz + overwrite: true + retention-days: 2 + compression-level: 0 + + arm64-linux: + runs-on: ubuntu-24.04 container: - image: ghcr.io/inko-lang/${{ matrix.target.image }} + image: ghcr.io/inko-lang/ci:debian-arm64 steps: - uses: actions/checkout@v4 - name: Build runtimes - run: bash ci/runtimes.sh ${{ matrix.target.arch }}-linux + run: bash ci/runtimes.sh arm64-linux + - uses: actions/upload-artifact@v4 + with: + name: arm64-linux + path: tmp/runtimes/*.tar.gz + overwrite: true + retention-days: 2 + compression-level: 0 + + amd64-mac: + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: ./ci/mac.sh + - name: Build runtimes + run: bash ci/runtimes.sh amd64-mac - uses: actions/upload-artifact@v4 with: - name: ${{ matrix.target.arch }}-linux + name: amd64-mac path: tmp/runtimes/*.tar.gz overwrite: true retention-days: 2 compression-level: 0 - mac: - strategy: - matrix: - target: - - name: amd64-mac - runner: macos-13 - - name: arm64-mac - runner: macos-14 - name: ${{ matrix.target.name }} - runs-on: ${{ matrix.target.runner }} + arm64-mac: + runs-on: macos-14 steps: - uses: actions/checkout@v4 - name: Install dependencies run: ./ci/mac.sh - name: Build runtimes - run: bash ci/runtimes.sh ${{ matrix.target.name }} + run: bash ci/runtimes.sh arm64-mac - uses: actions/upload-artifact@v4 with: - name: ${{ matrix.target.name }} + name: arm64-mac path: tmp/runtimes/*.tar.gz overwrite: true retention-days: 2 @@ -90,8 +104,10 @@ jobs: RCLONE_S3_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_SECRET_ACCESS_KEY }} RCLONE_S3_ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com needs: - - linux - - mac + - amd64-linux + - arm64-linux + - amd64-mac + - arm64-mac - amd64-freebsd steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7e57af325..91249c5b1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -67,15 +67,15 @@ jobs: strategy: matrix: target: - - name: amd64-linux-gnu - runner: ubuntu-24.04 - - name: arm64-linux-gnu - runner: ubuntu-24.04-arm + - image: 'ci:fedora' + name: amd64-linux-gnu + - image: 'ci:alpine' + name: amd64-linux-musl name: ${{ matrix.target.name }} compiler timeout-minutes: 15 - runs-on: ${{ matrix.target.runner }} + runs-on: ubuntu-24.04 container: - image: ghcr.io/inko-lang/ci:fedora + image: ghcr.io/inko-lang/${{ matrix.target.image }} steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 @@ -91,38 +91,25 @@ jobs: level: - none - balanced + - aggressive target: - - name: amd64-linux-gnu - runner: ubuntu-24.04 - triple: x86_64-unknown-linux-gnu - - name: amd64-linux-musl - runner: ubuntu-24.04 - triple: x86_64-unknown-linux-musl - - name: arm64-linux-gnu - runner: ubuntu-24.04-arm - triple: aarch64-unknown-linux-gnu - - name: arm64-linux-musl - runner: ubuntu-24.04-arm - triple: aarch64-unknown-linux-musl + - image: 'ci:fedora' + name: amd64-linux-gnu + - image: 'ci:alpine' + name: amd64-linux-musl name: ${{ matrix.target.name }} std --opt=${{ matrix.level }} timeout-minutes: 15 - runs-on: ${{ matrix.target.runner }} + runs-on: ubuntu-24.04 container: - image: ghcr.io/inko-lang/ci:fedora - env: - # This is needed because when setting an explicit target, "ring" looks for - # `aarch64-linux-musl-gcc` instead of using `musl-gcc`. - CC_aarch64_unknown_linux_musl: musl-gcc + image: ghcr.io/inko-lang/${{ matrix.target.image }} steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: path: '${{ env.CARGO_HOME }}' key: ${{ matrix.target.name }}-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }} - - name: Build the runtime and compiler - run: ./ci/linux.sh ${{ matrix.target.name }} ${{ matrix.target.triple }} - name: Run tests - run: 'cd std && ../target/debug/inko test --opt=${{ matrix.level }} --target=${{ matrix.target.name }}' + run: 'cd std && cargo run -- test --opt=${{ matrix.level }}' compiler-mac: strategy: @@ -156,6 +143,7 @@ jobs: level: - none - balanced + - aggressive target: - runner: macos-13 name: amd64-mac-native diff --git a/ci/docker/alpine/Dockerfile b/ci/docker/alpine/Dockerfile new file mode 100644 index 000000000..9827fd7cc --- /dev/null +++ b/ci/docker/alpine/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:3 + +ENV LLVM_VERSION 17 +ENV RUST_VERSION 1.78 + +ENV PATH /opt/cargo/bin:$PATH +ENV RUSTUP_HOME /opt/rustup +ENV CARGO_HOME /opt/cargo + +RUN apk add --update build-base tar git rustup \ + llvm$LLVM_VERSION llvm$LLVM_VERSION-dev llvm$LLVM_VERSION-static \ + libstdc++-dev zlib-static zstd-static libxml2-static + +RUN rustup-init --quiet -y --no-modify-path --profile minimal \ + --component clippy,rustfmt --default-toolchain $RUST_VERSION diff --git a/ci/docker/debian-amd64/Dockerfile b/ci/docker/debian-amd64/Dockerfile new file mode 100644 index 000000000..55c6a61a5 --- /dev/null +++ b/ci/docker/debian-amd64/Dockerfile @@ -0,0 +1,25 @@ +FROM debian:12 + +ENV LLVM_VERSION 17 +ENV RUST_VERSION 1.78 + +ENV PATH /opt/cargo/bin:$PATH +ENV CARGO_HOME /opt/cargo +ENV RUSTUP_HOME /opt/rustup + +RUN apt update --quiet && apt install --quiet --yes curl build-essential tar git +RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc +RUN /usr/bin/echo -e "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-$LLVM_VERSION main" \ + > /etc/apt/sources.list.d/llvm$LLVM_VERSION.list + +RUN apt update --quiet && apt install --quiet --yes \ + llvm-$LLVM_VERSION llvm-$LLVM_VERSION-dev \ + libstdc++-11-dev libclang-common-$LLVM_VERSION-dev zlib1g-dev \ + libpolly-$LLVM_VERSION-dev libzstd-dev + +RUN curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location \ + --silent --show-error --fail "https://sh.rustup.rs" | \ + sh -s -- --quiet -y --no-modify-path --profile minimal \ + --component clippy,rustfmt --default-toolchain $RUST_VERSION + +RUN apt install --quiet --yes musl-tools diff --git a/ci/docker/debian-arm64/Dockerfile b/ci/docker/debian-arm64/Dockerfile new file mode 100644 index 000000000..1539bbd51 --- /dev/null +++ b/ci/docker/debian-arm64/Dockerfile @@ -0,0 +1,27 @@ +FROM debian:12 + +ENV LLVM_VERSION 17 +ENV RUST_VERSION 1.78 + +ENV PATH /opt/cargo/bin:$PATH +ENV CARGO_HOME /opt/cargo +ENV RUSTUP_HOME /opt/rustup + +RUN apt update --quiet && apt install --quiet --yes curl build-essential tar git +RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc +RUN /usr/bin/echo -e "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-$LLVM_VERSION main" \ + > /etc/apt/sources.list.d/llvm$LLVM_VERSION.list + +RUN apt update --quiet && apt install --quiet --yes \ + llvm-$LLVM_VERSION llvm-$LLVM_VERSION-dev \ + libstdc++-11-dev libclang-common-$LLVM_VERSION-dev zlib1g-dev \ + libpolly-$LLVM_VERSION-dev libzstd-dev + +RUN curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location \ + --silent --show-error --fail "https://sh.rustup.rs" | \ + sh -s -- --quiet -y --no-modify-path --profile minimal \ + --component clippy,rustfmt --default-toolchain $RUST_VERSION + +RUN dpkg --add-architecture arm64 \ + && apt update --quiet \ + && apt install --quiet --yes gcc-aarch64-linux-gnu musl-tools:arm64 diff --git a/ci/docker/fedora/Dockerfile b/ci/docker/fedora/Dockerfile index 5e8cd2c70..9dd58331b 100644 --- a/ci/docker/fedora/Dockerfile +++ b/ci/docker/fedora/Dockerfile @@ -7,18 +7,14 @@ ENV PATH /opt/cargo/bin:$PATH ENV RUSTUP_HOME /opt/rustup ENV CARGO_HOME /opt/cargo -RUN dnf install --assumeyes --quiet gcc make tar git rustup rclone \ - llvm$LLVM_VERSION llvm$LLVM_VERSION-devel llvm$LLVM_VERSION-static \ - libstdc++-devel libstdc++-static libffi-devel \ - zlib-devel musl-gcc +RUN sudo dnf install --assumeyes --quiet gcc make tar git rustup rclone \ + llvm$LLVM_VERSION llvm$LLVM_VERSION-devel \ + llvm$LLVM_VERSION-static libstdc++-devel libstdc++-static \ + libffi-devel zlib-devel RUN rustup-init --quiet -y --no-modify-path --profile minimal \ --component clippy,rustfmt --default-toolchain $RUST_VERSION -# Add the musl target for the current architecture. -RUN rustup target add \ - $(rustc --print cfg | grep target_arch | cut -d '"' -f 2)-unknown-linux-musl - # idoc targets the latest stable release of Inko, but our tests run against a # newer version. This allows us to use an existing idoc executable without # having to compile it ourselves. diff --git a/ci/linux.sh b/ci/linux.sh deleted file mode 100755 index ed861319f..000000000 --- a/ci/linux.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -set -e - -INKO_VERSION="$(cargo pkgid -p inko | cut -d\# -f2 | cut -d: -f2)" -INKO_TRIPLE="${1}" -RUST_TRIPLE="${2}" -INKO_RUNTIMES="${HOME}/.local/share/inko/runtimes/${INKO_VERSION}/${INKO_TRIPLE}" - -function rustup_lib { - local home - local toolchain - home="$(rustup show home)" - toolchain="$(rustup show active-toolchain | awk '{print $1}')" - - echo "${home}/toolchains/${toolchain}/lib/rustlib/${1}/lib/" -} - -# As the host is a GNU host, a bit of extra work is needed to get -# cross-compilation to musl to work. -if [[ "${INKO_TRIPLE}" == *-musl ]] -then - cargo build -p rt --target="${RUST_TRIPLE}" - mkdir -p "${INKO_RUNTIMES}" - cp "./target/${RUST_TRIPLE}/debug/libinko.a" "${INKO_RUNTIMES}/libinko.a" - cp "$(rustup_lib "${RUST_TRIPLE}")/self-contained/libunwind.a" \ - "${INKO_RUNTIMES}/libunwind.a" - - INKO_RT="${PWD}/target/${RUST_TRIPLE}/debug" cargo build -p inko -else - cargo build -fi