name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clean cargo cache
run: cargo clean
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
test:
name: Test (${{ matrix.name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: "Default Features"
os: ubuntu-latest
features: ""
test_cmd: "cargo nextest run --profile ci"
- name: "Python Backend"
os: ubuntu-latest
features: "python"
test_cmd: "cargo nextest run --profile ci --features python"
- name: "macOS Default"
os: macos-latest
features: ""
test_cmd: "cargo nextest run --profile ci"
- name: "Windows Default"
os: windows-latest
features: ""
test_cmd: "cargo nextest run --profile ci"
steps:
- name: Free disk space (Linux)
if: runner.os == 'Linux'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-nextest
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-nextest
locked: true
- name: Clean cargo cache
run: cargo clean
- name: Run tests
run: ${{ matrix.test_cmd }}
coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Free disk space
run: cargo clean
- name: Generate coverage
run: cargo llvm-cov --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: false
license:
name: License Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check License Headers
run: |
# Check that all .rs files have the Apache license header
missing_license=""
for file in $(find . -name "*.rs" -not -path "./target/*" -not -path "./.git/*"); do
if ! grep -q "Copyright.* Contributors" "$file"; then
missing_license="$missing_license\n$file"
fi
done
if [ ! -z "$missing_license" ]; then
echo "Files missing license header:$missing_license"
exit 1
fi
build-artifacts:
name: Build Release Artifacts
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: oxibase
asset_name: oxibase-linux-amd64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: oxibase
asset_name: oxibase-linux-arm64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: oxibase
asset_name: oxibase-darwin-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: oxibase.exe
asset_name: oxibase-windows-amd64.exe
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Rename artifact
shell: bash
run: |
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}