-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
70 lines (53 loc) · 2.47 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
## Setup all variables
RUSTUP = rustup
NIGHTLY_TOOLCHAIN = nightly
DOCKER = docker
CARGO = cargo
INSTALLED_TOOLCHAINS = $(shell $(RUSTUP) toolchain list)
INSTALLED_COMPONENTS = $(shell $(RUSTUP) component list --installed --toolchain $(NIGHTLY_TOOLCHAIN))
INSTALLED_NIGHTLY_COMPONENTS = $(shell $(RUSTUP) component list --installed --toolchain $(NIGHTLY_TOOLCHAIN))
## Dev environment
install_rust_nightly:
ifeq (,$(findstring $(NIGHTLY_TOOLCHAIN),$(INSTALLED_TOOLCHAINS)))
$(RUSTUP) install $(NIGHTLY_TOOLCHAIN)
endif
install_clippy: install_rust_nightly
ifeq (,$(findstring clippy,$(INSTALLED_COMPONENTS)))
$(RUSTUP) component add clippy --toolchain $(NIGHTLY_TOOLCHAIN)
endif
install_rustfmt: install_rust_nightly
ifeq (,$(findstring rustfmt,$(INSTALLED_NIGHTLY_COMPONENTS)))
$(RUSTUP) component add rustfmt --toolchain $(NIGHTLY_TOOLCHAIN)
endif
## Initial setup
setup: install_rust_nightly install_clippy install_rustfmt
## Development tasks
all: fmt build clippy test
build: install_rust_nightly
$(CARGO) build --workspace --all-targets $(BUILD_ARGS)
clippy: install_clippy
$(CARGO) clippy --all-targets -- -D warnings
test:
$(DOCKER) build --tag rpll_backend_test_db ./Database/
$(CARGO) test --workspace --all-targets --no-fail-fast
fmt: install_rustfmt
$(CARGO) fmt -- --files-with-diff
coverage_test: install_rust_nightly
$(DOCKER) build --tag rpll_backend_test_db ./Database/
RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests" \
CARGO_INCREMENTAL=0 \
RUSTDOCFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests" \
$(CARGO) test --workspace --all-targets --no-fail-fast $(ARGS)
coverage_build:
$(CARGO) install grcov || true
~/.cargo/bin/grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing --filter "covered" \
--ignore "/*" --ignore "*/tests/*" --ignore "*/dto/*" --ignore "*/domain_value/*" --ignore "*/main.rs" --ignore "*/benches/*" \
--excl-br-line "#\\[\\w+(\\([\\w\",/\\s=<>]+\\))?\\]|pub\\s\\w+:[\\w<,\\s>]+," \
--excl-line "#\\[\\w+(\\([\\w\",/\\s=<>]+\\))?\\]" -o lcov.info
coverage_genhtml:
genhtml -o ./target/debug/coverage/ --branch-coverage --show-details --highlight --ignore-errors source --legend ./lcov.info && rm ./lcov.info
coverage: coverage_test coverage_build coverage_genhtml
tarpaulin:
$(CARGO) install cargo-tarpaulin || true
$(DOCKER) build --tag rpll_backend_test_db ./Database/
cargo tarpaulin -v --timeout 600