feat(ci): update test matrix to match Essex project #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
RUSTFLAGS: "-D warnings" | |
jobs: | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Linux (GNU) | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
name: Linux GNU x86_64 | |
- target: i686-unknown-linux-gnu | |
os: ubuntu-latest | |
name: Linux GNU i686 | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-latest | |
name: Linux GNU aarch64 | |
- target: armv7-unknown-linux-gnueabihf | |
os: ubuntu-latest | |
name: Linux GNU armv7 | |
- target: arm-unknown-linux-gnueabi | |
os: ubuntu-latest | |
name: Linux GNU arm | |
# Linux (MUSL) | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
name: Linux MUSL x86_64 | |
- target: i686-unknown-linux-musl | |
os: ubuntu-latest | |
name: Linux MUSL i686 | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
name: Linux MUSL aarch64 | |
# macOS | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
name: macOS x86_64 | |
- target: aarch64-apple-darwin | |
os: macos-14 | |
name: macOS aarch64 | |
name: Test ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: clippy, rustfmt | |
targets: ${{ matrix.target }} | |
- name: Install Linux dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y qemu-user musl-tools pkg-config libssl-dev | |
- name: Install macOS dependencies | |
if: runner.os == 'macOS' | |
run: | | |
brew install openssl@3 | |
- name: Setup musl build environment | |
if: contains(matrix.target, 'musl') | |
run: | | |
# Install musl-gcc | |
sudo apt-get install -y musl-tools | |
# Install musl OpenSSL | |
wget https://www.openssl.org/source/openssl-3.1.4.tar.gz | |
tar xzf openssl-3.1.4.tar.gz | |
cd openssl-3.1.4 | |
# Configure and build OpenSSL for musl | |
CC="musl-gcc -fPIC" ./Configure no-shared no-async --prefix=/usr/local/musl --openssldir=/usr/local/musl linux-x86_64 | |
make -j$(nproc) | |
sudo make install | |
cd .. | |
# Set environment variables for OpenSSL | |
echo "OPENSSL_DIR=/usr/local/musl" >> $GITHUB_ENV | |
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV | |
- name: Setup cross-compilation for ARM | |
if: contains(matrix.target, 'arm') | |
run: | | |
sudo apt-get install -y gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu | |
cargo install cross | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check formatting | |
run: cargo fmt --check | |
- name: Run clippy | |
run: | | |
if [ -n "${{ matrix.target }}" ] && [ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]; then | |
cross clippy --target ${{ matrix.target }} --all-targets --all-features -- -D warnings | |
else | |
cargo clippy --all-targets --all-features -- -D warnings | |
fi | |
- name: Build | |
run: | | |
if [ -n "${{ matrix.target }}" ] && [ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]; then | |
cross build --target ${{ matrix.target }} --all-features --release | |
else | |
cargo build --all-features --release | |
fi | |
- name: Check binary size | |
if: matrix.target != '' | |
run: | | |
ls -lh target/${{ matrix.target }}/release/strainer || ls -lh target/release/strainer | |
- name: Run tests | |
run: | | |
if [ -n "${{ matrix.target }}" ] && [ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]; then | |
cross test --target ${{ matrix.target }} --features testing | |
else | |
cargo test --features testing | |
fi | |
- name: Run security audit | |
uses: actions-rs/audit-check@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
coverage: | |
name: Code Coverage | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Install cargo-tarpaulin | |
run: cargo install cargo-tarpaulin | |
- name: Generate coverage report | |
run: | | |
cargo tarpaulin --features testing --out Xml --output-dir coverage --fail-under 90 | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
files: ./coverage/cobertura.xml | |
fail_ci_if_error: false | |
docs: | |
name: Documentation | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Build documentation | |
run: cargo doc --no-deps --all-features | |
env: | |
RUSTDOCFLAGS: -D warnings | |
- name: Deploy documentation | |
uses: peaceiris/actions-gh-pages@v3 | |
if: github.ref == 'refs/heads/main' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./target/doc |