name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '0 9 * * 1'
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-
- name: Build
run: cargo build --release --verbose
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: bin
path: target/release/apt-swarm
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-
- name: Build
run: cargo build --release --verbose
repro-env:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
target:
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v4
- name: Set up cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: repro-env-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: repro-env-${{ matrix.target }}-
- name: Install dependencies (apt)
run: sudo apt-get install repro-env
- name: Build
run: make ${{ matrix.target }}
- name: Print sha256 of binary
run: sha256sum target/${{ matrix.target }}/release/apt-swarm
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: bin-${{ matrix.target }}
path: target/${{ matrix.target }}/release/apt-swarm
unit-test:
runs-on: ${{ matrix.os.target }}
strategy:
fail-fast: false
matrix:
os:
- target: ubuntu-24.04
flags: --examples
- target: macos-latest
flags: --examples
- target: windows-latest
features:
- name: default
- name: none
flags: --no-default-features
- name: irc
flags: --no-default-features -F irc
steps:
- uses: actions/checkout@v4
- name: Set up cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-debug-
- name: Run clippy
run: cargo clippy --lib --bins --tests ${{ matrix.os.flags }} ${{ matrix.features.flags }} -- -D warnings
- name: Run tests
run: cargo test --verbose --lib --bins --tests ${{ matrix.features.flags }}
deny:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Run cargo deny
run: |
docker run --rm -v "$PWD:/src" -w /src alpine:edge sh -c '
set -e
apk add cargo cargo-deny
exec cargo deny check
'
fmt:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Run cargo fmt
run: cargo fmt --all -- --check