diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 93458a4e..2d11100f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -35,13 +35,13 @@ jobs: - name: Clippy run: make clippy - name: Run tests - run: make test_nightly + run: make test env: RUST_BACKTRACE: 1 EXTRA_CARGO_ARGS: '--verbose' - name: Run asan tests if: ${{ matrix.os == 'ubuntu-latest' }} - run: make test_nightly + run: make test env: RUST_BACKTRACE: 1 RUSTFLAGS: '-Zsanitizer=address' @@ -68,11 +68,14 @@ jobs: sharedKey: ${{ matrix.os }}-stable - name: Clippy run: make clippy + env: + WITH_STABLE_TOOLCHAIN: 'true' - name: Run tests run: make test env: RUST_BACKTRACE: 1 EXTRA_CARGO_ARGS: '--verbose' + WITH_STABLE_TOOLCHAIN: 'true' coverage: runs-on: ubuntu-latest needs: nightly @@ -95,7 +98,7 @@ jobs: - name: Run tests run: | make test - make test_nightly + env WITH_STABLE_TOOLCHAIN=true make test env: RUSTFLAGS: '-Zinstrument-coverage' LLVM_PROFILE_FILE: '%p-%m.profraw' diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..aaeddcf0 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +# Makefile + +## Additionaly arguments passed to cargo. +EXTRA_CARGO_ARGS ?= +## Whether to disable nightly-only feature. [true/false] +WITH_STABLE_TOOLCHAIN ?= + +.PHONY: format clippy test + +all: format clippy test + +## Format code in-place using rustfmt. +format: + cargo fmt --all + +## Run clippy. +ifeq ($(WITH_STABLE_TOOLCHAIN), true) +clippy: + cargo clippy --all --features all_stable --all-targets -- -D clippy::all +else +clippy: + cargo clippy --all --all-features --all-targets -- -D clippy::all +endif + +## Run tests. +ifeq ($(WITH_STABLE_TOOLCHAIN), true) +test: + cargo test --all --features all_stable_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture + cargo test --test failpoints --features all_stable ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture +else +test: + cargo test --all --features all_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture + cargo test --test failpoints --all-features ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture +endif diff --git a/README.md b/README.md index 999aec8a..33c1e8ac 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,10 @@ Contributions are always welcome! Here are a few tips for making a PR: ``` # rustup default nightly make +# rustup default stable +env WITH_STABLE_TOOLCHAIN=true make # filter a specific test case -env EXTRA_CARGO_ARGS= make test_nightly +env EXTRA_CARGO_ARGS= make test ``` - For changes that might induce performance effects, please quote the targeted benchmark results in the PR description. In addition to micro-benchmarks, there is a standalone [stress test tool](https://github.com/tikv/raft-engine/tree/master/stress) which you can use to demonstrate the system performance.