name: CI
on:
pull_request:
push: branches:
- master
jobs:
commit-authors:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Ban AI-authored commits
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
git fetch --no-tags --no-recurse-submodules origin "$BASE_SHA"
failed=0
offenders=$(git log --no-merges --pretty=format:'%H %an <%ae> committed by %cn <%ce>' "$BASE_SHA".."$HEAD_SHA" \
| grep -iE '(claude|codex)' || true)
if [ -n "$offenders" ]; then
echo "Commits authored or committed by Claude or Codex are not allowed:"
echo "$offenders"
failed=1
fi
for sha in $(git log --format=%H "$BASE_SHA".."$HEAD_SHA"); do
coauthors=$(git log -1 --format=%B "$sha" \
| grep -iE '^[[:space:]]*co[- ]?authored[- ]?by:.*(claude|codex)' || true)
if [ -n "$coauthors" ]; then
echo "Commit $sha has a co-author trailer referencing Claude or Codex:"
echo "$coauthors"
failed=1
fi
done
exit "$failed"
ci:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest", "ubuntu-24.04-arm"]
runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: --deny warnings
steps:
- uses: actions/checkout@v6
- name: Cache
id: rust-cache
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/cargo-deny
~/.cargo/bin/cargo-deny.exe
~/.cargo/bin/cargo-fuzz
~/.cargo/bin/cargo-fuzz.exe
~/.cargo/bin/just
~/.cargo/bin/just.exe
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/.rustc_info.json
target/debug/.fingerprint/
target/debug/build/
target/debug/deps/
fuzz/target/
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/Cargo.toml', '.github/workflows/*.yml', 'rust-toolchain') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-
- name: Non ASCII characters
if: startsWith(matrix.os, 'ubuntu')
run: |
if grep -P -n "[^\x00-\x7F]" -r --include="*.rs" --include="*.toml" .; then
echo "Non-ASCII characters detected"
exit 1
fi
- name: Install Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install Rust
run: |
rustup component add rustfmt
rustup component add clippy
- name: OSX x86 rust
if: startsWith(matrix.os, 'macos')
run: |
# For some reason this is required to run the fuzzer on OSX
rustup target add x86_64-apple-darwin
- name: Setup wasmtime
uses: bytecodealliance/actions/wasmtime/setup@v1
with:
version: "24.0.0"
- name: Install cargo-deny
if: steps.rust-cache.outputs.cache-hit != 'true'
run: cargo install --force --version 0.20.2 cargo-deny --locked
- name: Install cargo-fuzz
if: steps.rust-cache.outputs.cache-hit != 'true'
run: cargo install --force --version 0.12.0 cargo-fuzz --locked
- name: Install just
if: steps.rust-cache.outputs.cache-hit != 'true'
run: cargo install --force --version 1.36.0 just --locked
- name: Format
run: cargo fmt --all -- --check
- name: Compile (`wasm32-unknown-unknown`)
if: matrix.os == 'ubuntu-latest'
run: |
# Needed for 'cargo pkgid' to run
cargo generate-lockfile
rustup target add wasm32-unknown-unknown
# Not possible to set default members for specific a target:
# https://github.com/rust-lang/cargo/issues/6179
command="cargo check -p $(cargo pkgid) -p redb-derive --target wasm32-unknown-unknown"
$command
$command --all-features
$command --no-default-features
rustup target remove wasm32-unknown-unknown
- name: Compile (`no_std`, `thumbv7em-none-eabihf`)
if: matrix.os == 'ubuntu-latest'
run: |
rustup target add thumbv7em-none-eabihf
# Uses cargo pkgid because "redb" is ambiguous with the test dependency on an old version of redb
cargo check -p $(cargo pkgid) --target thumbv7em-none-eabihf --no-default-features --features experimental-api-5
# The features that are supported alongside no_std. cache_metrics needs 64-bit atomics,
# and chrono_v0_4/uuid need std, so all three are refused at compile time instead.
cargo check -p $(cargo pkgid) --target thumbv7em-none-eabihf --no-default-features --features experimental-api-5,logging,experimental_cursor
rustup target remove thumbv7em-none-eabihf
- name: Clippy (default features)
run: cargo clippy --all --all-targets -- -Dwarnings
- name: Fuzzer
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
run: just fuzz_ci
- name: Run tests
run: just test_all_no_sandbox
- name: Run CPython wrapper tests
if: runner.os != 'Windows'
run: |
python3 -m venv venv
source venv/bin/activate
pip3 install --upgrade pip
pip3 install maturin
just test_py
- name: Run CPython wrapper tests
if: runner.os == 'Windows'
run: |
python3 -m venv venv
venv\Scripts\activate
pip3 install --upgrade pip
pip3 install maturin
just test_py
- name: Run WASI tests
if: runner.os != 'Windows'
run: |
RUSTFLAGS="" just test_wasi
coverage:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Install cargo-llvm-cov
run: |
rustup component add llvm-tools-preview
cargo install --force --version 0.8.5 cargo-llvm-cov --locked
- name: Generate coverage report
run: cargo llvm-cov --all-features --lcov --output-path lcov.info
- name: Upload to Codecov
uses: codecov/codecov-action@v5
with:
files: lcov.info
use_oidc: true