Skip to content

Commit

Permalink
Add a makefile and simplify BUILD.md
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Oct 6, 2024
1 parent 71bfd38 commit 7c5c399
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Add a `makefile` and simplify `BUILD.md`

### Changed
- Bump `unsafe_cell_slice` to 0.2.0
- **Breaking**: Change `output` parameter of `decode_into` codec trait methods to `&UnsafeCellSlice<u8>`
Expand Down
40 changes: 15 additions & 25 deletions doc/BUILD.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
## Building
```bash
cargo build --release
```

## Testing
```bash
# Must have no warnings/errors to pass CI
cargo +nightly build --all-features && \
cargo +nightly test --all-features && \
RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo +nightly doc --all-features && \
cargo +nightly fmt --all -- --check && \
cargo +nightly clippy --all-features -- -D warnings && \
cargo +nightly check && \
cargo +nightly check --no-default-features
make check
```
Runs:
- build (default features, all features, no default features)
- test
- clippy
- doc
- fmt (check)

Extra checks with `clippy::nursery` (can have false positives):
```bash
# Additional checks
cargo +nightly clippy --all-features -- -D warnings -W clippy::nursery -A clippy::significant_drop_tightening -A clippy::significant_drop_in_scrutinee
# cargo clippy --all-features -- -D warnings -W clippy::unwrap_used -W clippy::expect_used
make check_extra
```

## Docs with Examples
```bash
cargo +nightly doc -Z unstable-options -Z rustdoc-scrape-examples --all-features
make doc
```

## Performance
Expand All @@ -34,28 +27,25 @@ cargo bench -- --save-baseline baseline
cargo bench -- --baseline baseline
```

## Coverage report (using [cargo-llvm-cov](https://crates.io/crates/cargo-llvm-cov))

## Coverage (using [cargo-llvm-cov](https://crates.io/crates/cargo-llvm-cov))
Install `cargo-llvm-cov`
```bash
cargo +nightly install cargo-llvm-cov --locked
make coverage_install
```

Generate a HTML report
```bash
cargo +nightly llvm-cov --all-features --doctests --html
open target/llvm-cov/html/index.html
make coverage_report
```

Generate a coverage file for [Coverage Gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) in VSCode
```bash
cargo +nightly llvm-cov --all-features --doctests --lcov --output-path lcov.info
make coverage_file
```

## [Miri](https://github.com/rust-lang/miri)
Tests that call foreign functions or access the filesystem are disabled.
The [inventory](https://crates.io/crates/inventory) crate does not work in miri, so there are workarounds in place for codecs, chunk key encodings, and chunk grids.
```bash
# `-Zmiri-ignore-leaks` is needed for multi-threaded programs... https://github.com/rust-lang/miri/issues/1371
MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-ignore-leaks -Zmiri-tree-borrows" cargo +nightly miri test -p zarrs --all-features
make miri
```
46 changes: 46 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
TOOLCHAIN ?= nightly

all: build

build:
cargo +$(TOOLCHAIN) build --all-features

test:
cargo +$(TOOLCHAIN) test --all-features

doc: RUSTDOCFLAGS="-D warnings --cfg docsrs"
doc:
cargo +$(TOOLCHAIN) doc -Z unstable-options -Z rustdoc-scrape-examples --all-features

clippy:
cargo +$(TOOLCHAIN) clippy --all-features -- -D warnings

check: build test clippy doc
cargo +$(TOOLCHAIN) fmt --all -- --check
cargo +$(TOOLCHAIN) check
cargo +$(TOOLCHAIN) check --no-default-features

check_extra:
cargo +$(TOOLCHAIN) clippy --all-features -- -D warnings -W clippy::nursery -A clippy::significant_drop_tightening -A clippy::significant_drop_in_scrutinee

# `-Zmiri-ignore-leaks` is needed for multi-threaded programs... https://github.com/rust-lang/miri/issues/1371
miri: MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-ignore-leaks -Zmiri-tree-borrows"
miri:
cargo +$(TOOLCHAIN) miri test -p zarrs --all-features

coverage_install:
cargo install cargo-llvm-cov --locked

coverage_report:
cargo +$(TOOLCHAIN) llvm-cov --all-features --doctests --html

coverage_file:
cargo +$(TOOLCHAIN) llvm-cov --all-features --doctests --lcov --output-path lcov.info

fmt:
cargo +$(TOOLCHAIN) fmt

clean:
cargo clean

.PHONY: all build test doc clippy check fmt clean

0 comments on commit 7c5c399

Please sign in to comment.