Put the engine logo in the backlink from outputs #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust tests | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
# Check all PR | |
concurrency: | |
group: rust-tests-${{ github.ref }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} | |
jobs: | |
rust-tests: | |
name: ${{ matrix.os }} / Rust ${{ matrix.rust-version }}${{ matrix.extra-name }} | |
runs-on: ${{ matrix.os }} | |
container: ${{ matrix.container }} | |
defaults: | |
run: | |
shell: "bash" | |
env: | |
CMAKE_CXX_COMPILER: ${{ matrix.cxx }} | |
CMAKE_C_COMPILER: ${{ matrix.cc }} | |
CMAKE_GENERATOR: ${{ matrix.cmake-generator }} | |
strategy: | |
matrix: | |
include: | |
# test without any feature (i.e shared build) | |
- os: ubuntu-20.04 | |
rust-version: stable | |
rust-target: x86_64-unknown-linux-gnu | |
extra-name: ", no features" | |
cxx: g++ | |
cc: gcc | |
cmake-generator: Unix Makefiles | |
# test with all features (i.e static build + ndarray) | |
- os: ubuntu-20.04 | |
rust-version: stable | |
rust-target: x86_64-unknown-linux-gnu | |
cargo-test-flags: --release --all-features | |
do-valgrind: true | |
extra-name: ", all features, release" | |
cxx: g++ | |
cc: gcc | |
cmake-generator: Unix Makefiles | |
# check the build on a stock Ubuntu 20.04, which uses cmake 3.16, and | |
# with our minimal supported rust version | |
- os: ubuntu-20.04 | |
rust-version: 1.65 | |
container: ubuntu:20.04 | |
rust-target: x86_64-unknown-linux-gnu | |
cargo-build-flags: --features=rayon | |
extra-name: ", cmake 3.16" | |
cxx: g++ | |
cc: gcc | |
cmake-generator: Unix Makefiles | |
- os: macos-14 | |
rust-version: stable | |
rust-target: aarch64-apple-darwin | |
cargo-test-flags: --features=rayon | |
extra-name: "" | |
cxx: clang++ | |
cc: clang | |
cmake-generator: Unix Makefiles | |
- os: windows-2019 | |
rust-version: stable | |
rust-target: x86_64-pc-windows-msvc | |
cargo-build-flags: --features=rayon | |
extra-name: " / MSVC" | |
cxx: cl.exe | |
cc: cl.exe | |
cmake-generator: Visual Studio 16 2019 | |
- os: windows-2019 | |
rust-version: stable | |
rust-target: x86_64-pc-windows-gnu | |
cargo-build-flags: --features=rayon | |
extra-name: " / MinGW" | |
cxx: g++.exe | |
cc: gcc.exe | |
cmake-generator: MinGW Makefiles | |
steps: | |
- name: install dependencies in container | |
if: matrix.container == 'ubuntu:20.04' | |
run: | | |
apt update | |
apt install -y software-properties-common | |
apt install -y cmake make gcc g++ git curl | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure git safe directory | |
if: matrix.container == 'ubuntu:20.04' | |
run: git config --global --add safe.directory /__w/metatensor/metatensor | |
- name: setup rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust-version }} | |
target: ${{ matrix.rust-target }} | |
- name: install valgrind | |
if: matrix.do-valgrind | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y valgrind | |
- name: Setup sccache | |
uses: mozilla-actions/[email protected] | |
with: | |
version: "v0.8.1" | |
- name: Setup sccache environnement variables | |
run: | | |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV | |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV | |
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV | |
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV | |
- name: run tests | |
run: | | |
cargo test --package metatensor --package metatensor-core --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }} | |
- name: check the code can be compiled as a standalone crate | |
if: matrix.os != 'windows-2019' | |
run: | | |
./scripts/package-core.sh rust/metatensor-sys/ | |
cd rust/metatensor-sys | |
cargo package --allow-dirty | |
# check that the C API declarations are correctly used by Rust and Python | |
prevent-bitrot: | |
runs-on: ubuntu-20.04 | |
name: check C API declarations | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: setup rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
target: x86_64-unknown-linux-gnu | |
- name: install python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install pycparser | |
- name: install bindgen | |
run: | | |
cargo install bindgen-cli --version ^0.69 | |
- name: check that Rust/Python/Julia C API declarations are up to date | |
run: | | |
./scripts/update-declarations.sh | |
git diff --exit-code | |
- name: check that C API functions are all documented | |
run: | | |
python scripts/check-c-api-docs.py | |
# make sure no debug print stays in the code | |
check-debug-prints: | |
runs-on: ubuntu-20.04 | |
name: check leftover debug print | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install ripgrep | |
run: | | |
wget https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz | |
tar xf ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz | |
echo "$(pwd)/ripgrep-13.0.0-x86_64-unknown-linux-musl" >> $GITHUB_PATH | |
- name: check for leftover dbg! | |
run: | | |
# use ripgrep (rg) to check for instances of `dbg!` in rust files. | |
# rg will return 1 if it fails to find a match, so we invert it again | |
# with the `!` builtin to get the error/success in CI | |
! rg "dbg!" --type=rust --quiet | |
- name: check for leftover \#include <iostream> | |
run: | | |
! rg "<iostream>" --iglob "\!metatensor-core/tests/cpp/external/catch/catch.hpp" --quiet | |
- name: check for leftover std::cout | |
run: | | |
! rg "cout" --iglob "\!metatensor-core/tests/cpp/external/catch/catch.hpp" --quiet | |
- name: check for leftover std::cerr | |
run: | | |
! rg "cerr" --iglob "\!metatensor-core/tests/cpp/external/catch/catch.hpp" --quiet |