Skip to content
Open
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
85 changes: 82 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
toolchain: ${{ matrix.rust-toolchain }}
components: rustfmt, clippy
cache-key: ${{ matrix.os }}-${{ matrix.rust-toolchain }}
cache-key: ${{ matrix.os }}-${{ matrix.rust-toolchain }}-v2
- name: Check
run: cargo check --all-features
- name: Architecture check
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
with:
toolchain: ${{ matrix.rust-toolchain }}
components: rustfmt, clippy
cache-key: ${{ matrix.os }}-${{ matrix.rust-toolchain }}
cache-key: ${{ matrix.os }}-${{ matrix.rust-toolchain }}-v2
- name: Check
run: cargo check --all-features
- name: Architecture check
Expand Down Expand Up @@ -146,4 +146,83 @@ jobs:
run: cargo miri nextest run --all-features -j${{ steps.cores.outputs.count }}
- name: Run Miri tests (serial)
if: steps.cores.outputs.use_nextest == 'false'
run: cargo miri test --all-features
run: cargo miri test --all-features

test-no-std:
name: Test no_std
runs-on: ubuntu-latest
strategy:
matrix:
target:
- thumbv7em-none-eabihf # ARM Cortex-M4F/M7F
- thumbv8m.main-none-eabihf # ARM Cortex-M33/M35P
- riscv32imac-unknown-none-elf # RISC-V 32-bit
rust-toolchain:
- "1.81" # minimum for this crate
- "stable"
- "nightly"
steps:
- uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust
- uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
with:
toolchain: ${{ matrix.rust-toolchain }}
target: ${{ matrix.target }}
components: rustfmt, clippy
cache-key: ${{ matrix.target }}-${{ matrix.rust-toolchain }}-v2
- name: Check no_std (no features)
run: cargo check --target ${{ matrix.target }} --no-default-features --features panic-handler --lib
- name: Check no_std with alloc
run: cargo check --target ${{ matrix.target }} --no-default-features --features alloc,panic-handler --lib
- name: Check no_std with cache
run: cargo check --target ${{ matrix.target }} --no-default-features --features cache,panic-handler --lib
- name: Run no_std tests (on host with std test harness)
run: cargo test --test no_std_tests

test-wasm:
name: Test WASM
runs-on: ubuntu-latest
strategy:
matrix:
include:
# WASM 1.0/2.0 (32-bit) - all toolchains
- target: wasm32-unknown-unknown
rust-toolchain: "1.81"
- target: wasm32-unknown-unknown
rust-toolchain: "stable"
- target: wasm32-unknown-unknown
rust-toolchain: "nightly"
# WASI preview 1 (32-bit) - all toolchains
- target: wasm32-wasip1
rust-toolchain: "1.81"
- target: wasm32-wasip1
rust-toolchain: "stable"
- target: wasm32-wasip1
rust-toolchain: "nightly"
# WASI preview 2 (32-bit) - nightly only (experimental)
- target: wasm32-wasip2
rust-toolchain: "nightly"
# Note: wasm64-unknown-unknown removed - not consistently available in nightly
steps:
- uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust
- uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
with:
toolchain: ${{ matrix.rust-toolchain }}
target: ${{ matrix.target }}
components: rustfmt, clippy
cache-key: ${{ matrix.target }}-${{ matrix.rust-toolchain }}-v2
- name: Check WASM (no features)
run: cargo check --target ${{ matrix.target }} --no-default-features --features panic-handler --lib
- name: Check WASM with alloc
run: cargo check --target ${{ matrix.target }} --no-default-features --features alloc,panic-handler --lib
- name: Check WASM with cache
run: cargo check --target ${{ matrix.target }} --no-default-features --features cache,panic-handler --lib
- name: Build WASM release
run: cargo build --target ${{ matrix.target }} --no-default-features --features alloc,panic-handler --lib --release
- name: Run WASM tests (on host with std test harness)
run: cargo test --test wasm_tests
- if: ${{ matrix.target == 'wasm32-unknown-unknown' && matrix.rust-toolchain == 'stable' }}
name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- if: ${{ matrix.target == 'wasm32-unknown-unknown' && matrix.rust-toolchain == 'stable' }}
name: Build WASM package with wasm-pack
run: wasm-pack build --target web --no-default-features --features alloc,panic-handler
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
.idea
.DS_Store
.git
.vscode
.vscode
105 changes: 95 additions & 10 deletions Cargo.lock

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

21 changes: 16 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@ bench = true

[dependencies]
crc = "3"
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When default-features = false is specified, the 'alloc' feature may not be available. Consider removing the features array or documenting why this specific combination is needed, as it could cause build failures if the digest crate's alloc feature depends on its default features.

Suggested change
crc = "3"
crc = "3"
# We use digest with default-features = false and features = ["alloc"] to enable heap allocation support in no_std environments.
# This configuration is safe because the alloc feature in digest does not depend on its default features as of digest v0.10.

Copilot uses AI. Check for mistakes.
digest = { version = "0.10", features = ["alloc"] }
digest = { version = "0.10", optional = true, default-features = false, features = ["alloc"] }

# will be removed once Rust 1.89 is the minimum supported version
rustversion = "1.0"

# constrain indexmap (transitive) to a version compatible with Rust 1.81.0
indexmap = { version = ">=2.11.0, <2.12.0", optional = true }

# no_std support
# spin is always required for no_std builds (feature detection synchronization)
spin = { version = "0.10.0", default-features = false, features = ["once", "rwlock", "mutex", "spin_mutex"] }
# hashbrown is only needed when caching is enabled in no_std
hashbrown = { version = "0.16.0", optional = true }

[dev-dependencies]
criterion = "0.7"
cbindgen = "0.29"
rand = "0.9"
regex = "1.12"
wasm-bindgen-test = "0.3"

# lto=true has a big improvement in performance
[profile.release]
Expand All @@ -62,12 +69,16 @@ required-features = ["cli"]
[[bench]]
name = "benchmark"
harness = false
required-features = ["std"]

[features]
default = ["std"]
std = []
default = ["std", "panic-handler"]
std = ["alloc"] # std implies alloc is available
cli = ["std"]
alloc = []
alloc = ["digest"] # marker feature for heap allocation support
cache = ["alloc", "hashbrown"] # caching requires alloc + hashbrown HashMap
ffi = ["std"]
panic-handler = [] # Provides panic handler for no_std library checks (disable in binaries)

# the features below are deprecated, aren't in use, and will be removed in the next MAJOR version (v2)
vpclmulqdq = [] # deprecated, VPCLMULQDQ stabilized in Rust 1.89.0
Expand All @@ -87,4 +98,4 @@ rustdoc-args = ["--cfg", "docsrs"]
[[test]]
name = "checksum_integration_tests"
path = "tests/checksum_integration_tests.rs"
required-features = ["cli"]
required-features = ["cli"]
Loading
Loading