Reverse target architecture mapping logic #14
This file contains 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: ci-verify-binary-architecture | |
on: | |
workflow_dispatch: | |
push: | |
env: | |
CARGO_TERM_COLOR: always | |
RUSTFLAGS: "-D warnings" | |
CARGO_INCREMENTAL: 0 | |
CARGO_PROFILE_DEV_DEBUG: 0 | |
CARGO_PROFILE_TEST_DEBUG: 0 | |
CROSS_CONTAINER_UID: 0 | |
permissions: | |
contents: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: test | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: false | |
matrix: | |
toolchain: [stable] | |
target: | |
- x86_64-unknown-linux-gnu | |
- x86_64-unknown-linux-musl | |
- aarch64-unknown-linux-gnu | |
- aarch64-unknown-linux-musl | |
- x86_64-apple-darwin | |
- x86_64-pc-windows-msvc | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
use-cross: false | |
run-integration-tests: true | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
use-cross: true | |
run-integration-tests: true | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
use-cross: true | |
run-integration-tests: false # Cannot run aarch64 binaries on x86_64 | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
use-cross: true | |
run-integration-tests: false # Cannot run aarch64 binaries on x86_64 | |
# macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64 | |
- os: macos-13 # intel | |
target: x86_64-apple-darwin | |
use-cross: false | |
run-integration-tests: true | |
- os: macos-latest # aarch64 | |
toolchain: stable | |
target: aarch64-apple-darwin | |
use-cross: false | |
run-integration-tests: true | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
use-cross: false | |
run-integration-tests: true | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install musl-tools incl. musl-gcc | |
uses: awalsh128/cache-apt-pkgs-action@v1 | |
with: | |
# musl-tools provide `musl-gcc` which is required for `ring` which is required for `rustls` et al. | |
packages: musl-tools | |
version: 1.1 | |
if: ${{ matrix.target == 'x86_64-unknown-linux-musl'}} | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
target: ${{ matrix.target }} | |
- name: Install Erlang (non-macos) | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: "26.1" | |
elixir-version: "1.16.1" | |
rebar3-version: "3" | |
if: ${{ runner.os != 'macOS' }} # setup-beam does not support macOS | |
- name: Install Erlang (macos) | |
run: | | |
brew install erlang rebar3 elixir | |
mix local.hex --force | |
if: ${{ runner.os == 'macOS' }} # setup-beam does not support macOS | |
- name: Handle Rust dependencies caching | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: v1-${{ matrix.target }} | |
- name: Install Gleam | |
uses: clechasseur/rs-cargo@v2 | |
with: | |
command: install | |
args: "--path compiler-cli --target ${{ matrix.target }} --debug --locked" | |
use-cross: ${{ matrix.use-cross }} | |
if: ${{ matrix.run-integration-tests }} | |
- name: Verify binary architecture | |
shell: bash | |
run: | | |
set -xeuo pipefail | |
BINARY_PATH="${CARGO_HOME}/bin/gleam" | |
if [[ "${{ matrix.target }}" == *"windows"* ]]; then | |
BINARY_PATH="${BINARY_PATH}.exe" | |
fi | |
./bin/verify-binary-architecture.sh "${{ matrix.target }}" "$BINARY_PATH" | |
if: ${{ matrix.run-integration-tests }} |