Make sure to include the sdist in the releases #704
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: [main] | |
pull_request: | |
# Check all PR | |
concurrency: | |
group: rust-tests-${{ github.ref }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
jobs: | |
tests: | |
runs-on: ${{ matrix.os }} | |
name: ${{ matrix.os }} / rust ${{ matrix.rust-version }} ${{ matrix.extra-name }} | |
container: ${{ matrix.container }} | |
defaults: | |
run: | |
working-directory: ${{ matrix.working-directory }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-22.04 | |
rust-version: stable | |
rust-target: x86_64-unknown-linux-gnu | |
build-type: debug | |
test-static-lib: true | |
extra-name: / static C library | |
working-directory: /home/runner/work/featomic/featomic/ | |
- os: ubuntu-22.04 | |
rust-version: stable | |
rust-target: x86_64-unknown-linux-gnu | |
build-type: release | |
cargo-build-flags: --release | |
do-valgrind: true | |
extra-name: / release valgrind | |
working-directory: /home/runner/work/featomic/featomic/ | |
# check the build on a stock Ubuntu 20.04, including cmake 3.16 | |
- os: ubuntu-22.04 | |
rust-version: "1.74" | |
container: ubuntu:20.04 | |
rust-target: x86_64-unknown-linux-gnu | |
build-type: debug | |
extra-name: / cmake 3.16 | |
working-directory: /__w/featomic/featomic | |
- os: macos-14 | |
rust-version: stable | |
rust-target: aarch64-apple-darwin | |
build-type: debug | |
working-directory: /Users/runner/work/featomic/featomic/ | |
- os: windows-2019 | |
rust-version: stable | |
rust-target: x86_64-pc-windows-msvc | |
build-type: debug | |
working-directory: C:\\featomic | |
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 python3-pip python3-venv | |
ln -s /usr/bin/python3 /usr/bin/python | |
working-directory: / | |
- name: free disk space | |
if: matrix.os == 'ubuntu-22.04' | |
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android || true | |
- 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/featomic/featomic | |
- name: "copy the code to C: drive" | |
if: matrix.os == 'windows-2019' | |
run: cp -r ${{ github.workspace }} ${{ matrix.working-directory }} | |
working-directory: / | |
- name: setup Python | |
uses: actions/setup-python@v5 | |
if: "!matrix.container" | |
with: | |
python-version: "3.12" | |
- 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.5.4" | |
- 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: unit tests | |
run: cargo test --lib --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }} | |
- name: documentation tests | |
# we need rustc 1.78 to load libmetatensor.so in doctests | |
if: matrix.rust-version == 'stable' | |
run: cargo test --doc --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }} | |
- name: integration tests | |
env: | |
FEATOMIC_TEST_WITH_STATIC_LIB: ${{ matrix.test-static-lib || 0 }} | |
run: | | |
cargo test --test "*" --package featomic --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }} | |
# second set of jobs checking that (non-test) code still compiles/run as expected | |
prevent-bitrot: | |
runs-on: ubuntu-22.04 | |
name: check examples / benchmarks | |
steps: | |
- uses: actions/checkout@v4 | |
- name: setup rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Setup sccache | |
uses: mozilla-actions/[email protected] | |
with: | |
version: "v0.8.2" | |
- 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: check that examples compile & run | |
run: | | |
cargo run --release --features chemfiles --example compute-soap -- featomic/examples/data/water.xyz | |
cargo run --release --features chemfiles --example profiling -- featomic/examples/data/water.xyz | |
- name: check that benchmarks compile and run once | |
run: cargo bench -- --test | |
# third set of jobs checking containing basic rust linting | |
lint-rust: | |
runs-on: ubuntu-22.04 | |
name: Lint Rust code | |
strategy: | |
matrix: | |
include: | |
- rust-version: stable | |
rust-target: x86_64-unknown-linux-gnu | |
steps: | |
- uses: actions/checkout@v4 | |
- name: setup rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust-version }} | |
target: ${{ matrix.rust-target }} | |
- name: install dependencies | |
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 |