name: CI
on:
push:
branches: [main]
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
name: fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 - name: Install Rust toolchain
run: rustup show && rustup component add rustfmt
- run: cargo fmt --all --check
clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 - name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Install Rust toolchain
run: rustup show && rustup component add clippy
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 - name: Clippy
run: cargo clippy --locked --all-targets --all-features -- -D warnings
build-test-matrix:
name: build & test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 - name: Install protoc
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust toolchain
run: rustup show
- name: Expose Xcode compiler runtime
if: runner.os == 'macOS'
run: |
set -euo pipefail
clang_bin="$(xcrun --toolchain XcodeDefault --find clang)"
clang_usr="$(dirname "$(dirname "$clang_bin")")"
runtime_dir="$(find "$clang_usr/lib/clang" -type d -path '*/lib/darwin' | sort | tail -n 1)"
if [ -z "$runtime_dir" ]; then
echo "::error::could not find Xcode compiler runtime under $clang_usr/lib/clang"
exit 1
fi
echo "LIBRARY_PATH=$runtime_dir${LIBRARY_PATH:+:$LIBRARY_PATH}" >> "$GITHUB_ENV"
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 - name: Cache Hugging Face tokenizer downloads
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 with:
path: ~/.cache/huggingface
key: hf-hub-${{ runner.os }}-arctic-embed-s
- name: Build
run: cargo build --locked --all-targets
- name: Warm tokenizer cache
run: |
set -euo pipefail
printf '[embeddings]\nenabled = false\n' > "${RUNNER_TEMP}/hf-warm.toml"
for attempt in 1 2 3 4 5; do
if cargo run --locked --quiet -- config download --config "${RUNNER_TEMP}/hf-warm.toml"; then
exit 0
fi
echo "tokenizer warm attempt ${attempt} failed; retrying after backoff"
sleep $(( attempt * 20 ))
done
echo "::error::could not warm the tokenizer cache after 5 attempts"
exit 1
- name: Test
env:
HF_HUB_OFFLINE: "1"
run: cargo test --locked
build-test:
name: build & test
needs: build-test-matrix
if: always()
runs-on: ubuntu-latest
steps:
- name: Require all matrix legs to pass
if: needs.build-test-matrix.result != 'success'
run: exit 1