name: CI
"on":
push:
branches: ["main"]
tags-ignore: ["v*"]
paths-ignore:
- "README.md"
pull_request:
branches: ["main"]
paths-ignore:
- "README.md"
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint & fmt
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: lint-cargo-${{ hashFiles('Cargo.lock') }}
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
needs: lint
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
cross: false
- os: ubuntu-24.04
target: x86_64-unknown-linux-musl
cross: true
- os: ubuntu-24.04
target: aarch64-unknown-linux-musl
cross: true
- os: ubuntu-24.04
target: aarch64-unknown-linux-gnu
cross: true
- os: ubuntu-24.04
target: armv7-unknown-linux-musleabihf
cross: true
- os: macos-14
target: x86_64-apple-darwin
cross: false
- os: macos-14
target: aarch64-apple-darwin
cross: false
- os: windows-2022
target: x86_64-pc-windows-msvc
cross: false
- os: windows-2022
target: x86_64-pc-windows-gnu
cross: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install NASM (Windows MSVC)
if: matrix.target == 'x86_64-pc-windows-msvc'
uses: ilammy/setup-nasm@v1
- name: Install cross (for cross-compilation)
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install musl tools (Linux musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
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: ${{ matrix.target }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Build (native)
if: ${{ !matrix.cross }}
run: cargo build --release --target ${{ matrix.target }}
- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}
- name: Run unit tests (native)
if: ${{ !matrix.cross }}
run: cargo test --release --lib
- name: Run integration tests (Linux)
if: ${{ !matrix.cross && matrix.os == 'ubuntu-24.04' }}
run: |
./tests/fixtures.sh
cargo test --test integration --release
docker:
name: Docker Image
runs-on: ubuntu-24.04
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to ghcr.io
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: ghcr.io/${{ github.repository }}:main
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build dockerfile (without push)
run: |
chmod +x ./buildx.sh
./buildx.sh --push false --repo ${{ secrets.DOCKER_USERNAME }} --tag main
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build dockerfile (with push)
run: |
chmod +x ./buildx.sh
./buildx.sh --push true --repo ${{ secrets.DOCKER_USERNAME }} --tag main