Skip to content

Commit

Permalink
Add CI workflows (#1)
Browse files Browse the repository at this point in the history
* copy CI setup from Bempp-rs

* fix warnings

* clippy

* clippy

* no s

* clippy

* add example finder
  • Loading branch information
mscroggs authored Aug 28, 2024
1 parent bd39860 commit b71df80
Show file tree
Hide file tree
Showing 15 changed files with 397 additions and 78 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: 📖

on:
push:
pull_request:
branches:
- main
merge_group:

jobs:
build-docs:
name: Build docs
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "nightly"
- name: Set up MPI
uses: mpi4py/setup-mpi@v1
with:
mpi: "mpich"
- uses: actions/checkout@v3

- name: Build docs
run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo +nightly doc --no-deps -Zunstable-options -Zrustdoc-scrape-examples --features "strict"

build-and-deploy-docs:
name: Build and deploy docs
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: github.ref == 'refs/heads/main'
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
steps:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "nightly"
components: rustfmt
- name: Set up MPI
uses: mpi4py/setup-mpi@v1
with:
mpi: "mpich"
- uses: actions/checkout@v3

- name: Build docs
run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo +nightly doc --no-deps -Zunstable-options -Zrustdoc-scrape-examples

- name: Set file permissions
run: |
rm target/doc/.lock
chmod -c -R +rX target/doc
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact for docs
uses: actions/upload-pages-artifact@v1
with:
path: 'target/doc'
- name: Deploy docs to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
67 changes: 67 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 🧪

on:
push:
branches:
- "**"
pull_request:
branches:
- main
merge_group:

jobs:
run-tests-rust:
name: Run Rust tests
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: ["stable"]
mpi: ['mpich', 'openmpi']
feature-flags: ['--features "strict"']
steps:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
components: rustfmt
- name: Set up MPI
uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpi }}
- name: Install cargo-mpirun
run: cargo install cargo-mpirun
- uses: actions/checkout@v3
- name: Install LAPACK, OpenBLAS
run:
sudo apt-get install -y libopenblas-dev liblapack-dev

- name: Run unit tests
run: cargo test ${{ matrix.feature-flags }}
- name: Run unit tests in release mode
run: cargo test --release ${{ matrix.feature-flags }}
- name: Run tests
run: cargo test --examples --release ${{ matrix.feature-flags }}
- name: Run examples
run: |
python3 find_examples.py
chmod +x examples.sh
./examples.sh
check-dependencies:
name: Check dependencies
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: ["stable"]
steps:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
components: rustfmt
- name: Install cargo-upgrades
run: cargo install cargo-upgrades
- uses: actions/checkout@v3
- name: Check that dependencies are up to date
run:
cargo upgrades
50 changes: 50 additions & 0 deletions .github/workflows/run-weekly-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 🧪

on:
schedule:
- cron: "0 7 * * 1"

jobs:
run-tests-rust:
name: Run Rust tests
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: ["stable", "beta", "nightly"]
mpi: [ 'mpich', 'openmpi']
steps:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust-version }}
components: rustfmt
- name: Set up MPI
uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpi }}
- name: Install cargo-mpirun
run: cargo install cargo-mpirun
- uses: actions/checkout@v3
- name: Install LAPACK, OpenBLAS
run:
sudo apt-get install -y libopenblas-dev liblapack-dev

- name: Build rust library
run: cargo build --features "strict"
- name: Build rust library in release mode
run: cargo build --release --features "strict"

- name: Run unit tests
run: cargo test --features "strict"
- name: Run unit tests in release mode
run: cargo test --release --features "strict"
- name: Run tests
run: cargo test --examples --release --features "strict"
- name: Run examples
run: |
python3 find_examples.py
chmod +x examples.sh
./examples.sh
- name: Build docs
run: cargo doc --features "strict" --no-deps
39 changes: 39 additions & 0 deletions .github/workflows/style-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name:

on:
push:
branches:
- "**"
pull_request:
branches:
- main
merge_group:

jobs:
style-checks:
name: Rust style checks
runs-on: ubuntu-latest
strategy:
matrix:
feature-flags: ['--features "strict"', '']
steps:
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rustfmt,clippy
- name: Set up MPI
uses: mpi4py/setup-mpi@v1
with:
mpi: mpich
- uses: actions/checkout@v3
- name: Install LAPACK, OpenBLAS
run:
sudo apt-get install -y libopenblas-dev liblapack-dev

- name: Style checks
run: |
cargo fmt -- --check
cargo clippy ${{ matrix.feature-flags }} -- -D warnings
cargo clippy --tests ${{ matrix.feature-flags }} -- -D warnings
cargo clippy --examples ${{ matrix.feature-flags }} -- -D warnings
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ fftw-src/fftw-*
kifmm/python/kifmm_py/_kifmm_rs/**/*.py



# Editor
.vim/*

# CPP
*.o
**/build/*
*.clang-format
*.clang-format

# Test and example output
_test_*.vtk
_example_*.vtk

13 changes: 4 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[features]
# Treat warnings as a build error.
strict = []
battleship = []

[package]
name = "bempp-octree"
Expand All @@ -21,26 +22,20 @@ crate-type = ["cdylib", "lib"]

[dependencies]
itertools = "0.13.*"
num = "0.4"
approx = "0.5"
rayon = "1.9"
rand = "0.8.5"
rand_distr = "0.4.3"
bitflags = "2.6.0"
bytemuck = "1.*"
coe-rs = "0.1.2"
vtkio = "0.6.*"
mpi = {version = "0.8.*", features = ["derive", "user-operations"] }
superslice = "1.0.*"

[profile.release]
debug = 1

[dev-dependencies]
criterion = { version = "0.5.*", features = ["html_reports"]}
rand_distr = "0.4.3"
#criterion = { version = "0.5.*", features = ["html_reports"]}

[build-dependencies]
cbindgen = "0.26.0"
cbindgen = "0.27.0"

[lints.clippy]
wildcard_imports = "forbid"
9 changes: 8 additions & 1 deletion examples/battleship.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
//! Compute an Octree for a medieval battleship
#[cfg(feature = "battleship")]
use std::time::Instant;

#[cfg(feature = "battleship")]
use bempp_octree::octree::Octree;
#[cfg(feature = "battleship")]
use vtkio::model::*;

#[cfg(feature = "battleship")]
pub fn main() {
let data: &[u8] = include_bytes!("battleship.vtk"); // Or just include_bytes!

Expand All @@ -29,6 +33,9 @@ pub fn main() {
);
println!("Maximum level: {}", octree.maximum_leaf_level());

octree.export_to_vtk("octree.vtk");
octree.export_to_vtk("_example_octree.vtk");
}
}

#[cfg(not(feature = "battleship"))]
pub fn main() {}
1 change: 0 additions & 1 deletion examples/parsort.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Testing the hyksort component.
use bempp_octree::parsort::{array_to_root, parsort};
use itertools::Itertools;
use mpi;
use mpi::traits::Communicator;
use rand::prelude::*;

Expand Down
Loading

0 comments on commit b71df80

Please sign in to comment.