name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Run cargo check
run: cargo check --all-targets
- name: Run cargo fmt
run: cargo fmt -- --check
- name: Run cargo clippy
run: cargo clippy --all-targets -- -D warnings
- name: Run cargo test
run: cargo test --verbose
build:
name: Build
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
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: macos-latest
target: x86_64-apple-darwin
use_native: true
- os: macos-latest
target: aarch64-apple-darwin
use_cross: true
- os: windows-latest
target: x86_64-pc-windows-msvc
use_cross: false
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
targets: ${{ matrix.use_cross == true && matrix.target || '' }}
- name: Install cross
if: matrix.use_cross == true
uses: taiki-e/install-action@v2
with:
tool: cross
- uses: Swatinem/rust-cache@v2
- name: Build release binary
run: |
if [ "${{ matrix.use_native }}" = "true" ]; then
cargo build --release
elif [ "${{ matrix.use_cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
shell: bash
- name: Upload artifacts (Unix)
if: "!contains(runner.os, 'Windows')"
run: |
mkdir -p artifacts
if [ "${{ matrix.use_native }}" = "true" ]; then
cp target/release/ccs artifacts/ccs-${{ matrix.target }}
else
cp target/${{ matrix.target }}/release/ccs artifacts/ccs-${{ matrix.target }}
fi
- name: Upload artifacts (Windows)
if: contains(runner.os, 'Windows')
run: |
mkdir artifacts
copy target\${{ matrix.target }}\release\ccs.exe artifacts\ccs-${{ matrix.target }}.exe
- uses: actions/upload-artifact@v4
with:
name: ccs-${{ matrix.target }}
path: artifacts/*