Skip to content

test(meson): require named gpu dependency #53

test(meson): require named gpu dependency

test(meson): require named gpu dependency #53

Workflow file for this run

name: ci
on:
push:
branches: [main]
tags: ['v*']
pull_request:
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --check
header-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
# Pin matches the version comment cbindgen writes into include/linkcell.h.
- run: cargo install cbindgen --version 0.29.4
- run: scripts/regen-capi-headers.sh --check
python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/cache@v4
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, 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:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: actions/cache@v4
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 }}
- 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@v4
- uses: dtolnay/rust-toolchain@stable
- uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- uses: actions/setup-python@v5
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@v4
- uses: dtolnay/rust-toolchain@stable
- uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- uses: actions/cache@v4
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