name: ci
on:
push:
branches:
- main
- "perf/**"
- "fix/**"
- "feat/**"
- "ci/**"
- "release/**"
tags: ['v*']
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c with:
components: rustfmt
- run: cargo fmt --check
- run: python3 scripts/check-llms-txt.py
header-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c - run: cargo install cbindgen --version 0.29.4
- run: scripts/regen-capi-headers.sh --check
python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with:
python-version: '3.12'
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-py-${{ hashFiles('Cargo.lock', 'python/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-py-
- name: Install Python test deps
run: |
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
pip install maturin pytest numpy
pip install torch --index-url https://download.pytorch.org/whl/cpu
- name: maturin develop
run: |
. .venv/bin/activate
maturin develop
- name: pytest
run: |
. .venv/bin/activate
pytest tests/python -q
cargo:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
crate:
- name: default
flags: ""
- name: serial
flags: --no-default-features --features capi
name: cargo (${{ matrix.os }}, ${{ matrix.crate.name }})
runs-on: ${{ matrix.os }}
steps:
- name: CPU flags
shell: bash
run: |
echo "arch=$(uname -m)"
grep -m1 'model name' /proc/cpuinfo || true
grep -m1 flags /proc/cpuinfo || true
sysctl -n machdep.cpu.brand_string 2>/dev/null || true
lscpu || true
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c with:
components: clippy
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- run: cargo test --locked ${{ matrix.crate.flags }}
- name: SIMD paths exercised
shell: bash
run: cargo test --locked ${{ matrix.crate.flags }} --lib simd_paths_exercised -- --nocapture
- run: cargo clippy --locked --all-targets ${{ matrix.crate.flags }} -- -D warnings
meson:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
name: meson (${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c - name: Configure MSVC
if: runner.os == 'Windows'
shell: pwsh
run: .github/scripts/setup-msvc.ps1
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with:
python-version: '3.12'
- run: pip install meson ninja
- name: Meson setup
if: runner.os != 'Windows'
run: meson setup build --prefix "$PWD/prefix" --libdir lib
shell: bash
- name: Meson setup
if: runner.os == 'Windows'
run: meson setup build --prefix "$env:GITHUB_WORKSPACE/prefix" --libdir lib
shell: pwsh
- run: meson compile -C build
- run: meson test -C build --print-errorlogs
- run: meson install -C build
- name: Installed headers and libraries
shell: bash
run: |
prefix="$PWD/prefix"
test -f "$prefix/include/linkcell.h"
test -f "$prefix/include/linkcell.hpp"
test -f "$prefix/include/linkcell_gpu.h"
test -f "$prefix/include/linkcell_gpu.hpp"
case "$RUNNER_OS" in
Windows)
test -f "$prefix/bin/linkcell.dll"
test -f "$prefix/lib/linkcell.dll.lib"
test -f "$prefix/lib/linkcell.lib"
test -f "$prefix/lib/linkcell_gpu.lib"
;;
macOS)
test -f "$prefix/lib/liblinkcell.dylib"
test -f "$prefix/lib/liblinkcell.a"
test -f "$prefix/lib/liblinkcell_gpu.a"
;;
Linux)
test -f "$prefix/lib/liblinkcell.so"
test -f "$prefix/lib/liblinkcell.a"
test -f "$prefix/lib/liblinkcell_gpu.a"
;;
esac
- name: pkg-config after meson install
if: runner.os != 'Windows'
run: |
prefix="$PWD/prefix"
export PKG_CONFIG_PATH="$prefix/lib/pkgconfig"
pkg-config --exists --print-errors linkcell
pkg-config --modversion linkcell
pkg-config --cflags --libs linkcell
pkg-config --exists --print-errors linkcell-gpu
pkg-config --modversion linkcell-gpu
c++ -std=c++17 tests/cmake-consumer/gpu.cpp \
$(pkg-config --cflags --libs linkcell-gpu) \
-o build/installed-gpu-consumer
cmake:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
name: cmake (${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c - name: Configure MSVC
if: runner.os == 'Windows'
shell: pwsh
run: .github/scripts/setup-msvc.ps1
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- run: cmake -S . -B build -DCMAKE_INSTALL_PREFIX="$PWD/prefix"
shell: bash
- run: cmake --build build --config Release
- run: ctest --test-dir build -C Release --output-on-failure
- run: cmake --install build --config Release
- name: find_package after cmake install
shell: bash
run: |
test -f prefix/include/linkcell.h
test -f prefix/lib/cmake/linkcell/linkcellConfig.cmake
if [[ "$RUNNER_OS" == "Windows" ]]; then
test -f prefix/bin/linkcell.dll
test -f prefix/lib/linkcell.dll.lib
test -f prefix/lib/linkcell.lib
test -f prefix/lib/linkcell_gpu.lib
elif [[ "$RUNNER_OS" == "macOS" ]]; then
test -f prefix/lib/liblinkcell.dylib
test -f prefix/lib/liblinkcell.a
test -f prefix/lib/liblinkcell_gpu.a
else
test -f prefix/lib/liblinkcell.so
test -f prefix/lib/liblinkcell.a
test -f prefix/lib/liblinkcell_gpu.a
fi
cmake -S tests/cmake-consumer -B find-build \
-DCMAKE_PREFIX_PATH="$PWD/prefix" \
-DLINKCELL_C_EXAMPLE="$PWD/examples/two_points.c" \
-DLINKCELL_CPP_EXAMPLE="$PWD/examples/two_points.cpp"
cmake --build find-build --config Release
if [[ "$RUNNER_OS" == "Windows" ]]; then
export PATH="$PWD/prefix/bin:$PATH"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
export DYLD_LIBRARY_PATH="$PWD/prefix/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
else
export LD_LIBRARY_PATH="$PWD/prefix/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fi
ctest --test-dir find-build -C Release --output-on-failure
- name: pkg-config after cmake install
if: runner.os != 'Windows'
run: |
test -f prefix/lib/pkgconfig/linkcell.pc
export PKG_CONFIG_PATH="$PWD/prefix/lib/pkgconfig"
pkg-config --exists --print-errors linkcell
pkg-config --modversion linkcell
static-minimage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
repository: lode-org/minimage
ref: v0.2.0
path: build/minimage-source
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c - run: cmake -S tests/static-minimage -B build/static-minimage -DMINIMAGE_SOURCE="$PWD/build/minimage-source"
- run: cmake --build build/static-minimage --target static_minimage --parallel 2
- run: ctest --test-dir build/static-minimage --output-on-failure
isa-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c - name: CPU flags
run: |
echo "arch=$(uname -m)"
grep -m1 'model name' /proc/cpuinfo || true
grep -m1 flags /proc/cpuinfo || true
- name: Unstripped library
run: |
cargo build --release --lib --locked
mkdir -p isa-audit-input
cp -a target/release/liblinkcell.so isa-audit-input/liblinkcell-x86_64.so
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with:
name: unstripped-libs
path: isa-audit-input
isa-audit:
needs: isa-build
permissions:
contents: read
uses: OmniPotentRPC/rgpot/.github/workflows/isa-audit.yml@000887fc75392c024eee070f23655f74a0865a15
with:
artifact-name: unstripped-libs
allow-file: isa-allow.toml
baseline: x86-64