Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify on CI that gleam binary architectures match target architectures #3897

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/workflows/ci-verify-binary-architecture.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
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 }}
10 changes: 10 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ jobs:
use-cross: ${{ matrix.use-cross }}
if: ${{ matrix.run-integration-tests }}

- name: Verify binary architecture
shell: bash
run: |
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 }}

- name: Run tests
uses: clechasseur/rs-cargo@v2
with:
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/release-nightly-verify-binary-architecture.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: release-nightly-verify-binary-architecture

on:
workflow_dispatch:
# push:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"

jobs:
nightly-last-run:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
# if: ${{ github.repository_owner == 'gleam-lang' }}
steps:
- uses: actions/checkout@v4
- name: print latest_commit
run: echo ${{ github.sha }}

- id: should_run
continue-on-error: true
name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should_run=false" >> $GITHUB_OUTPUT

build-nightly-clean:
runs-on: ubuntu-latest
needs: [ nightly-last-run ]
# if: ${{ github.repository_owner == 'gleam-lang' && needs.nightly-last-run.outputs.should_run != 'false' }}
steps:
- name: Delete old release assets
uses: mknejp/delete-release-assets@v1
with:
token: ${{ github.token }}
tag: nightly
fail-if-no-assets: false
fail-if-no-release: false
assets: |
*.zip
*.tar.gz
*.sha256
*.sha512

build-nightly:
name: build-release
runs-on: ${{ matrix.os }}
needs: [ build-nightly-clean ]
# if: ${{ github.repository_owner == 'gleam-lang' }}
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc
toolchain: [stable]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
use-cross: false
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
use-cross: true
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
use-cross: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
use-cross: true
# macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64
- os: macos-13
target: x86_64-apple-darwin
use-cross: false
- os: macos-latest
target: aarch64-apple-darwin
use-cross: false
- os: windows-latest
target: x86_64-pc-windows-msvc
use-cross: false
- os: windows-latest
target: aarch64-pc-windows-msvc
use-cross: false
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Update versions
shell: bash
run: |
./bin/add-nightly-suffix-to-versions.sh

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}

- name: Handle Rust dependencies caching
uses: Swatinem/rust-cache@v2
with:
key: v1-${{ matrix.target }}

- name: Build release binary
uses: clechasseur/rs-cargo@v2
with:
command: build
args: --release --target ${{ matrix.target }}
use-cross: ${{ matrix.use-cross }}

- name: Verify binary architecture
shell: bash
run: |
set -xeuo pipefail

BINARY_PATH="target/${{ matrix.target }}/release/gleam"
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
BINARY_PATH="${BINARY_PATH}.exe"
fi

./bin/verify-binary-architecture.sh "${{ matrix.target }}" "$BINARY_PATH"
9 changes: 9 additions & 0 deletions .github/workflows/release-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ jobs:
args: --release --target ${{ matrix.target }}
use-cross: ${{ matrix.use-cross }}

- name: Verify binary architecture
shell: bash
run: |
BINARY_PATH="target/${{ matrix.target }}/release/gleam"
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
BINARY_PATH="${BINARY_PATH}.exe"
fi
./bin/verify-binary-architecture.sh "${{ matrix.target }}" "$BINARY_PATH"

- name: Build archive
shell: bash
run: |
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/release-verify-binary-architecture.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: release-verify-binary-architecture

on:
workflow_dispatch:
# push:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"

jobs:
build-release:
name: build-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc
toolchain: [stable]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
use-cross: false
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
use-cross: true
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
use-cross: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
use-cross: true
# macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64
- os: macos-13
target: x86_64-apple-darwin
use-cross: false
- os: macos-latest
target: aarch64-apple-darwin
use-cross: false
- os: windows-latest
target: x86_64-pc-windows-msvc
use-cross: false
- os: windows-latest
target: aarch64-pc-windows-msvc
use-cross: false
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}

- name: Handle Rust dependencies caching
uses: Swatinem/rust-cache@v2
with:
key: v1-${{ matrix.target }}

- name: Build release binary
uses: clechasseur/rs-cargo@v2
with:
command: build
args: --release --target ${{ matrix.target }}
use-cross: ${{ matrix.use-cross }}

- name: Verify binary architecture
shell: bash
run: |
set -xeuo pipefail

BINARY_PATH="target/${{ matrix.target }}/release/gleam"
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
BINARY_PATH="${BINARY_PATH}.exe"
fi

./bin/verify-binary-architecture.sh "${{ matrix.target }}" "$BINARY_PATH"
9 changes: 9 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ jobs:
args: --release --target ${{ matrix.target }}
use-cross: ${{ matrix.use-cross }}

- name: Verify binary architecture
shell: bash
run: |
BINARY_PATH="target/${{ matrix.target }}/release/gleam"
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
BINARY_PATH="${BINARY_PATH}.exe"
fi
./bin/verify-binary-architecture.sh "${{ matrix.target }}" "$BINARY_PATH"

- name: Build archive
shell: bash
run: |
Expand Down
Loading