name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- target: x86_64-apple-darwin
os: macos-13
- target: aarch64-apple-darwin
os: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Test
run: cargo test --target ${{ matrix.target }}
- name: Check binary size
shell: bash
run: |
SIZE=$(stat -c%s target/${{ matrix.target }}/release/beck 2>/dev/null || stat -f%z target/${{ matrix.target }}/release/beck)
SIZE_MB=$(echo "scale=1; $SIZE / 1048576" | bc)
echo "Binary size: ${SIZE_MB} MB"
if (( $(echo "$SIZE_MB > 6" | bc -l) )); then
echo "::warning::Binary size ${SIZE_MB}MB exceeds 6MB budget"
fi
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: lint-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Format check
run: cargo fmt --check
- name: Clippy
run: cargo clippy --release -- -D warnings
musl:
name: Musl build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust + musl target
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- name: Install musl-tools
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: musl-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Test
run: cargo test --target x86_64-unknown-linux-musl
aarch64:
name: aarch64 cross-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust + aarch64 target
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-unknown-linux-gnu
- name: Install cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: aarch64-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --release --target aarch64-unknown-linux-gnu