Skip to content
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

Better support for Webassembly and no_std #9

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,42 @@ jobs:
command: clippy
args: --all-targets --all-features

- name: Test in development mode
- name: Test in development mode with default features
uses: actions-rs/cargo@v1.0.1
env:
RUSTFLAGS: "-D warnings"
with:
command: test
toolchain: stable

- name: Test in release mode
- name: Test in development mode with --no-default-features
uses: actions-rs/cargo@v1.0.1
env:
RUSTFLAGS: "-D warnings"
with:
command: test
toolchain: stable
args: --no-default-features

- name: Test in development mode with only "std" feature
uses: actions-rs/cargo@v1.0.1
env:
RUSTFLAGS: "-D warnings"
with:
command: test
toolchain: stable
args: --no-default-features --features=std

- name: Test in development mode with only "system_math" feature
uses: actions-rs/cargo@v1.0.1
env:
RUSTFLAGS: "-D warnings"
with:
command: test
toolchain: stable
args: --no-default-features --features=system_math

- name: Test in release mode with default features
uses: actions-rs/cargo@v1.0.1
env:
RUSTFLAGS: "-D warnings"
Expand All @@ -63,10 +90,27 @@ jobs:
toolchain: stable
args: --release

- name: Test in development mode (without default features)
uses: actions-rs/cargo@v1.0.1
env:
RUSTFLAGS: "-D warnings"
with:
command: test
toolchain: stable
args: --no-default-features

- name: Test in release mode (without default features)
uses: actions-rs/cargo@v1.0.1
env:
RUSTFLAGS: "-D warnings"
with:
command: test
toolchain: stable
args: --release --no-default-features

miri-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

Expand All @@ -92,7 +136,7 @@ jobs:
RUSTFLAGS: "-Zrandomize-layout"
MIRIFLAGS: "-Zmiri-symbolic-alignment-check -Zmiri-check-number-validity -Zmiri-tag-raw-pointers -Zmiri-disable-isolation"
run: |
cargo miri test --no-fail-fast --all-targets
cargo miri test --no-fail-fast --all-targets --no-default-features

python-test:
runs-on: ${{ matrix.os }}
Expand Down
55 changes: 15 additions & 40 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,48 +78,23 @@ jobs:
toolchain: stable
args: --release

miri-test:
runs-on: ${{ matrix.os }}
needs: rust-test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Get latest rust nightly version that has miri
id: versions
run: |
echo "::set-output name=rustc::nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)"

- name: Cache Rust dependencies
uses: actions/cache@v2
with:
path: |
target
.cargo_home
.cargo
key: ${{ runner.os }}-no_pybindings-miri-${{ steps.versions.outputs.rustc }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-no_pybindings-miri-${{ steps.versions.outputs.rustc }}-

- name: Install rust ${{ steps.versions.outputs.rustc }}
uses: actions-rs/toolchain@v1
- name: Test in development mode (without default features)
uses: actions-rs/cargo@v1.0.1
env:
RUSTFLAGS: "-D warnings"
with:
toolchain: ${{ steps.versions.outputs.rustc }}
profile: minimal
components: miri
override: true
command: test
toolchain: stable
args: --no-default-features

- name: Run tests in miri
- name: Test in release mode (without default features)
uses: actions-rs/cargo@v1.0.1
env:
RUSTFLAGS: "-Zrandomize-layout"
MIRIFLAGS: "-Zmiri-symbolic-alignment-check -Zmiri-check-number-validity -Zmiri-tag-raw-pointers -Zmiri-disable-isolation"
run: |
cargo miri test --no-fail-fast --all-targets
RUSTFLAGS: "-D warnings"
with:
command: test
toolchain: stable
args: --release --no-default-features

python-test:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -184,7 +159,7 @@ jobs:
testall:
runs-on: ubuntu-latest
name: Meta job for all tests
needs: [rust-test, miri-test, python-test]
needs: [rust-test, python-test]
steps:
- name: Done
run: echo "All tests successful."
70 changes: 33 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ crate-type = ["rlib", "cdylib"]
name = "constriction"

[features]
default = ["std"]
std = ["probability"]
default = ["std", "system_math"]

# Features "system_math" is active by default. Deactivate it if your compilation
# target has no system math C library (e.g., if you compile to WebAssembly).
system_math = ["probability/system_math", "special/system_math"]

# Feature "std" is active by default. Deactivate it if you want to compile
# to a `no_std` target (e.g., a microcontroller). You'll likely want to
# deactivate feature "system_math" as well in this case.
std = ["probability/std", "special/std"]

# Use feature `pybindings` to compile the python extension module that provides
# access to this library from python. This feature is turned off by default
Expand All @@ -33,7 +41,10 @@ hashbrown = "0.11"
num = "0.4"
smallvec = "1.6.1"

probability = {version = "0.17", optional = true}
# special = {path = "../special", default-features = false}# Only used if "std" is deactivated.
special = {git = "https://github.com/robamler/special.git", rev = "16708ea249ec56fbebfcc91b413142f01671ebd9", default-features = false}
# probability = {path = "../probability", default-features = false}
probability = {git = "https://github.com/robamler/probability.git", rev = "29c68c470990a9e5dbd13f8687f6bbe7edd61c00", default-features = false}

ndarray = {version = "0.15", optional = true}
numpy = {version = "0.15", optional = true}
Expand Down
3 changes: 0 additions & 3 deletions benches/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ criterion_group!(
round_trip_u16_u32_u16_12
);

#[cfg(not(miri))]
criterion::criterion_main!(benches);
#[cfg(miri)]
fn main() {} // All benchmarks currently use FFI and therefore can't be tested in miri.

fn round_trip_u32_u64_u16_12(c: &mut Criterion) {
round_trip::<u32, u64, u16, 12>(c);
Expand Down
Loading