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
- run: python3 scripts/check-versions.py
- name: The tag names the version
if: github.ref_type == 'tag'
run: python3 scripts/check-versions.py --tag "$GITHUB_REF_NAME"
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with:
python-version: "3.12"
- name: Site
run: |
mkdir -p docs/assets && cp -a assets/branding docs/assets/branding
python -m pip install "mkdocs==1.6.1" "mkdocs-material==9.5.49"
mkdocs build --site-dir _site
- name: Rust API reference
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --no-deps --locked --lib
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 vesin minimage
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
clang-libomp:
runs-on: ubuntu-latest
env:
CC: clang-21
CXX: clang++-21
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c with:
components: clippy
- name: Install Clang 21 and libomp
run: |
. /etc/os-release
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \
| sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null
echo "deb http://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-21 main" \
| sudo tee /etc/apt/sources.list.d/llvm-21.list
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang-21 libomp-21-dev
clang-21 --version
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-clang-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-clang-cargo-
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with:
python-version: '3.12'
- run: pip install meson ninja
- name: Runtime check
run: |
cat > "$RUNNER_TEMP/only-libomp.sh" <<'EOF'
#!/usr/bin/env bash
# Fail unless every argument needs libomp and no other OpenMP runtime.
set -euo pipefail
for lib in "$@"; do
needed=$(readelf -d "$lib" | sed -n 's/.*(NEEDED).*\[\(.*\)\]/\1/p')
printf '%s needs:\n%s\n' "$lib" "$needed"
grep -q '^libomp\.so' <<<"$needed" || { echo "::error::$lib does not need libomp"; exit 1; }
if grep -E 'gomp|iomp' <<<"$needed"; then
echo "::error::$lib needs another OpenMP runtime"
exit 1
fi
loaded=$(ldd "$lib")
echo "$loaded"
if grep -E 'libgomp|libiomp' <<<"$loaded"; then
echo "::error::$lib loads another OpenMP runtime"
exit 1
fi
done
EOF
chmod +x "$RUNNER_TEMP/only-libomp.sh"
- run: cargo build --locked
- name: liblinkcell.so needs libomp alone
run: '"$RUNNER_TEMP/only-libomp.sh" target/debug/liblinkcell.so'
- run: cargo test --locked
- run: cargo clippy --locked --all-targets -- -D warnings
- run: meson setup build --prefix "$PWD/prefix" --libdir lib
- run: meson compile -C build
env:
CC: gcc
- run: meson test -C build --print-errorlogs
- run: meson install -C build
- name: Installed library and pkg-config
run: |
"$RUNNER_TEMP/only-libomp.sh" prefix/lib/liblinkcell.so
export PKG_CONFIG_PATH="$PWD/prefix/lib/pkgconfig"
libs=$(pkg-config --static --libs linkcell)
echo "$libs"
grep -qw -- -lomp <<<"$libs"
if grep -w -- -lgomp <<<"$libs"; then exit 1; fi
clang-library-path:
runs-on: ubuntu-latest
env:
CC: clang
CXX: clang++
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with:
python-version: '3.12'
- run: pip install meson ninja
- name: Unpack libomp 21 into a private prefix
run: |
. /etc/os-release
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \
| sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null
echo "deb http://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-21 main" \
| sudo tee /etc/apt/sources.list.d/llvm-21.list
sudo apt-get update
cd "$RUNNER_TEMP"
apt-get download libomp-21-dev libomp5
for deb in libomp*.deb; do dpkg -x "$deb" omp; done
lib="$RUNNER_TEMP/omp/usr/lib/x86_64-linux-gnu"
inc="$RUNNER_TEMP/omp/usr/lib/llvm-21/lib/clang/21/include"
test -f "$lib/libomp.so" && test -f "$inc/omp.h"
if [ -f "$(clang -print-file-name=libomp.so)" ]; then
echo "::error::clang finds a libomp of its own; LIBRARY_PATH would not be exercised"
exit 1
fi
{
echo "LIBRARY_PATH=$lib"
echo "CPATH=$inc"
echo "LD_LIBRARY_PATH=$lib"
echo "LINKCELL_OMP_LIB=$lib"
} >> "$GITHUB_ENV"
- name: Runtime check
run: |
cat > "$RUNNER_TEMP/private-libomp.sh" <<'EOF'
#!/usr/bin/env bash
# Fail unless every argument loads the private libomp and no other runtime.
set -euo pipefail
for lib in "$@"; do
needed=$(readelf -d "$lib" | sed -n 's/.*(NEEDED).*\[\(.*\)\]/\1/p')
printf '%s needs:\n%s\n' "$lib" "$needed"
grep -q '^libomp\.so' <<<"$needed" || { echo "::error::$lib does not need libomp"; exit 1; }
if grep -E 'gomp|iomp' <<<"$needed"; then
echo "::error::$lib needs another OpenMP runtime"
exit 1
fi
loaded=$(ldd "$lib")
echo "$loaded"
grep -q "libomp\.so.* => $LINKCELL_OMP_LIB/" <<<"$loaded" \
|| { echo "::error::$lib does not load libomp from $LINKCELL_OMP_LIB"; exit 1; }
if grep -E 'libgomp|libiomp' <<<"$loaded"; then
echo "::error::$lib loads another OpenMP runtime"
exit 1
fi
done
EOF
chmod +x "$RUNNER_TEMP/private-libomp.sh"
- run: cargo build --locked
- name: liblinkcell.so needs the private libomp alone
run: '"$RUNNER_TEMP/private-libomp.sh" target/debug/liblinkcell.so'
- run: cargo test --locked
- run: meson setup build
- run: meson compile -C build
- run: meson test -C build --print-errorlogs
- name: Meson's liblinkcell.so needs the private libomp alone
run: '"$RUNNER_TEMP/private-libomp.sh" build/liblinkcell.so'
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
read -ra gpu_flags <<<"$(pkg-config --cflags --libs linkcell-gpu)"
c++ -std=c++17 tests/cmake-consumer/gpu.cpp \
"${gpu_flags[@]}" \
-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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a 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