-
Notifications
You must be signed in to change notification settings - Fork 7
Implement a C API for metatomic #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
36319a5
e45ed6b
477bf48
094a56c
fb69442
b020133
3394973
5614890
f7a8534
d28504e
37b3974
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| name: Python tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| # Check all PR | ||
|
|
||
| concurrency: | ||
| group: python-tests-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
|
||
| jobs: | ||
| python-tests: | ||
| runs-on: ${{ matrix.os }} | ||
| name: ${{ matrix.os }} / Python ${{ matrix.python-version }} / Torch ${{ matrix.torch-version }} | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-24.04 | ||
| python-version: "3.10" | ||
| torch-version: "2.3" | ||
| numpy-version-pin: "<2.0" | ||
| # Do not run docs-tests with python 3.10 since torch-sim-atomistic | ||
| # is not available for this version of python | ||
| tox-envs: lint,torch-tests | ||
| - os: ubuntu-24.04 | ||
| python-version: "3.10" | ||
| torch-version: "2.12" | ||
| # See above | ||
| tox-envs: lint,torch-tests | ||
| - os: ubuntu-24.04 | ||
| # TorchScript is no longer supported in Python 3.14 | ||
| # so we keep a test with 3.13 to make sure this doesn't break | ||
| python-version: "3.13" | ||
| torch-version: "2.12" | ||
| tox-envs: lint,torch-tests,docs-tests | ||
| - os: ubuntu-24.04 | ||
| python-version: "3.14" | ||
| torch-version: "2.12" | ||
| tox-envs: lint,torch-tests,docs-tests | ||
| - os: macos-15 | ||
| python-version: "3.14" | ||
| torch-version: "2.12" | ||
| tox-envs: lint,torch-tests,docs-tests | ||
| - os: windows-2022 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as macos =) |
||
| python-version: "3.14" | ||
| torch-version: "2.12" | ||
| tox-envs: lint,torch-tests,docs-tests | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: setup Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: setup rust | ||
| uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: stable | ||
|
|
||
| - name: Cache Rust dependencies | ||
| uses: Leafwing-Studios/cargo-cache@v2.6.1 | ||
| with: | ||
| sweep-cache: true | ||
|
|
||
| - name: Setup sccache | ||
| if: ${{ !env.ACT }} | ||
| uses: mozilla-actions/sccache-action@v0.0.10 | ||
| with: | ||
| version: "v0.10.0" | ||
|
Comment on lines
+73
to
+74
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, one is the version of the action, and one is the version of sccache itself |
||
|
|
||
| - name: setup MSVC command prompt | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
|
|
||
| - name: Setup sccache environnement variables | ||
| if: ${{ !env.ACT }} | ||
| 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: install tests dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install tox coverage | ||
|
|
||
| - name: run tests | ||
| run: tox -e ${{ matrix.tox-envs }} | ||
| env: | ||
| PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu | ||
| METATOMIC_TESTS_TORCH_VERSION: ${{ matrix.torch-version }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| 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: | ||
| 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: | ||
| - os: ubuntu-24.04 | ||
| rust-version: stable | ||
| rust-target: x86_64-unknown-linux-gnu | ||
| cxx: g++ | ||
| cc: gcc | ||
| cmake-generator: Unix Makefiles | ||
|
|
||
| # check the build on a stock Ubuntu 22.04, which uses cmake 3.22, and | ||
| # with our minimal supported rust version | ||
| - os: ubuntu-24.04 | ||
| rust-version: 1.74 | ||
| container: ubuntu:22.04 | ||
| rust-target: x86_64-unknown-linux-gnu | ||
| extra-name: ", cmake 3.22" | ||
| cxx: g++ | ||
| cc: gcc | ||
| cmake-generator: Unix Makefiles | ||
|
|
||
| - os: macos-15 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No |
||
| rust-version: stable | ||
| rust-target: aarch64-apple-darwin | ||
| extra-name: "" | ||
| cxx: clang++ | ||
| cc: clang | ||
| cmake-generator: Unix Makefiles | ||
|
|
||
| # - os: windows-2022 | ||
| # rust-version: stable | ||
| # rust-target: x86_64-pc-windows-msvc | ||
| # extra-name: " / MSVC" | ||
| # cxx: cl.exe | ||
| # cc: cl.exe | ||
| # cmake-generator: Visual Studio 17 2022 | ||
|
|
||
| # - os: windows-2022 | ||
| # rust-version: stable | ||
| # rust-target: x86_64-pc-windows-gnu | ||
| # extra-name: " / MinGW" | ||
| # cxx: g++.exe | ||
| # cc: gcc.exe | ||
| # cmake-generator: MinGW Makefiles | ||
| steps: | ||
| - name: install dependencies in container | ||
| if: matrix.container == 'ubuntu:22.04' | ||
| run: | | ||
| apt update | ||
| apt install -y software-properties-common | ||
| apt install -y cmake make gcc g++ git curl python3-venv | ||
|
|
||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Configure git safe directory | ||
| if: matrix.container == 'ubuntu:22.04' | ||
| run: git config --global --add safe.directory /__w/metatomic/metatomic | ||
|
|
||
| - name: setup rust | ||
| uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: ${{ matrix.rust-version }} | ||
| target: ${{ matrix.rust-target }} | ||
|
|
||
| - name: setup Python | ||
| uses: actions/setup-python@v6 | ||
| if: matrix.container == null | ||
| with: | ||
| # Python 3.14.5 fails with "No module named pip.__main__; 'pip' is a | ||
| # package and cannot be directly executed" when using a venv, so we | ||
| # use 3.14.4 for now | ||
| python-version: "3.14.4" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to be this specific? If yes, why? Elsewhere, only
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python 3.14.5 had a bug with EDIT: some failing logs: https://github.com/metatensor/metatomic/actions/runs/26566813574/job/78263488176 |
||
|
|
||
| - name: Cache Rust dependencies | ||
| uses: Leafwing-Studios/cargo-cache@v2.6.1 | ||
| with: | ||
| sweep-cache: true | ||
|
|
||
| - name: install valgrind | ||
| if: matrix.do-valgrind | ||
| run: | | ||
| sudo apt-get install -y valgrind | ||
|
|
||
| - name: Setup sccache | ||
| if: ${{ !env.ACT }} | ||
| uses: mozilla-actions/sccache-action@v0.0.10 | ||
| with: | ||
| version: "v0.15.0" | ||
|
|
||
| - name: Setup sccache environnement variables | ||
| if: ${{ !env.ACT }} | ||
| 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 metatomic-core --target ${{ matrix.rust-target }} | ||
| env: | ||
| RUST_BACKTRACE: full | ||
|
|
||
| - name: check that the header was already up to date | ||
| run: | | ||
| git diff --exit-code | ||
|
|
||
| # check that the C API declarations are correctly documented and used | ||
| prevent-bitrot: | ||
| runs-on: ubuntu-24.04 | ||
| name: check C API declarations | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: setup Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.14" | ||
|
|
||
| - name: install python dependencies | ||
| run: | | ||
| pip install pycparser | ||
|
|
||
| - 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-24.04 | ||
| name: check leftover debug print | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - 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 "\!metatomic-core/tests/cpp/external/catch/catch.hpp" --quiet | ||
|
|
||
| - name: check for leftover std::cout | ||
| run: | | ||
| ! rg "cout" --iglob "\!metatomic-core/tests/cpp/external/catch/catch.hpp" --quiet | ||
|
|
||
| - name: check for leftover std::cerr | ||
| run: | | ||
| ! rg "cerr" --iglob "\!metatomic-core/tests/cpp/external/catch/catch.hpp" --quiet | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No
macos-26?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to test on the oldest "supported" platform to make sure everything works there instead of testing on the latest and greatest