name: CI
on:
pull_request:
branches:
- main
- "codex/**"
push:
branches:
- main
- "codex/**"
permissions:
contents: read
env:
MACOSX_DEPLOYMENT_TARGET: "13.3"
CARGO_HTTP_MULTIPLEXING: "false"
CARGO_NET_RETRY: "10"
jobs:
fmt:
name: cargo fmt
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with:
fetch-depth: 0
- name: Check formatting
run: cargo fmt --check
test:
name: cargo test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
rustflags: ""
prebuilt_lbug: false
lbug_archive: ""
test_args: ""
- os: macos-latest
rustflags: ""
prebuilt_lbug: true
lbug_archive: liblbug-static-osx-arm64.tar.gz
test_args: ""
- os: windows-2022
rustflags: ""
prebuilt_lbug: false
lbug_archive: ""
test_args: "--release"
steps:
- name: Check out repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with:
fetch-depth: 0
- name: Prepare prebuilt liblbug
if: ${{ matrix.prebuilt_lbug }}
shell: bash
run: |
set -eu
lib_dir="$PWD/.cache/lbug-prebuilt"
archive="${{ matrix.lbug_archive }}"
lbug_version="$(awk '/^name = "lbug"/ { found=1 } found && /^version = / { gsub(/"/, "", $3); print $3; exit }' Cargo.lock)"
mkdir -p "$lib_dir"
curl --retry 5 --retry-all-errors --connect-timeout 20 -fSL \
"https://github.com/LadybugDB/ladybug/releases/download/v${lbug_version}/${archive}" \
-o "$RUNNER_TEMP/$archive"
tar xzf "$RUNNER_TEMP/$archive" -C "$lib_dir"
test -f "$lib_dir/liblbug.a"
test -f "$lib_dir/lbug.h"
{
echo "LBUG_LIBRARY_DIR=$lib_dir"
echo "LBUG_INCLUDE_DIR=$lib_dir"
} >> "$GITHUB_ENV"
- name: Run tests
env:
RUSTFLAGS: ${{ matrix.rustflags }}
run: cargo test --workspace --locked ${{ matrix.test_args }}
clippy:
name: cargo clippy
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with:
fetch-depth: 0
- name: Run clippy
run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
supply-chain:
name: cargo audit
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with:
fetch-depth: 0
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Run Rust advisory scan
run: cargo audit
publish-dry-run:
name: cargo publish dry-run
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with:
fetch-depth: 0
- name: Verify crates.io package
run: cargo publish --dry-run --locked
package:
name: native package (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
binary: codebase-graph
archive: codebase-graph-linux-x86_64.tar.gz
prebuilt_lbug: false
lbug_archive: ""
rustflags: ""
- os: macos-latest
binary: codebase-graph
archive: codebase-graph-macos-arm64.tar.gz
prebuilt_lbug: true
lbug_archive: liblbug-static-osx-arm64.tar.gz
rustflags: ""
- os: macos-15-intel
binary: codebase-graph
archive: codebase-graph-macos-x86_64.tar.gz
prebuilt_lbug: true
lbug_archive: liblbug-static-osx-x86_64.tar.gz
rustflags: ""
- os: windows-2022
binary: codebase-graph.exe
archive: codebase-graph-windows-x86_64.tar.gz
prebuilt_lbug: false
lbug_archive: ""
rustflags: ""
steps:
- name: Check out repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 with:
fetch-depth: 0
- name: Prepare prebuilt liblbug
if: ${{ matrix.prebuilt_lbug }}
shell: bash
run: |
set -eu
lib_dir="$PWD/.cache/lbug-prebuilt"
archive="${{ matrix.lbug_archive }}"
lbug_version="$(awk '/^name = "lbug"/ { found=1 } found && /^version = / { gsub(/"/, "", $3); print $3; exit }' Cargo.lock)"
mkdir -p "$lib_dir"
curl --retry 5 --retry-all-errors --connect-timeout 20 -fSL \
"https://github.com/LadybugDB/ladybug/releases/download/v${lbug_version}/${archive}" \
-o "$RUNNER_TEMP/$archive"
tar xzf "$RUNNER_TEMP/$archive" -C "$lib_dir"
test -f "$lib_dir/liblbug.a"
test -f "$lib_dir/lbug.h"
{
echo "LBUG_LIBRARY_DIR=$lib_dir"
echo "LBUG_INCLUDE_DIR=$lib_dir"
} >> "$GITHUB_ENV"
- name: Build Rust production binary
env:
RUSTFLAGS: ${{ matrix.rustflags }}
shell: bash
run: |
mkdir -p dist/smoke
cargo build --locked --release --bin codebase-graph
cp "target/release/${{ matrix.binary }}" "dist/smoke/${{ matrix.binary }}"
chmod +x "dist/smoke/${{ matrix.binary }}"
tar -C dist/smoke -czf "dist/${{ matrix.archive }}" "${{ matrix.binary }}"
- name: Smoke-test Rust production binary
shell: bash
run: cargo run -p xtask -- smoke-artifact "./dist/smoke/${{ matrix.binary }}"