-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
171 lines (139 loc) · 4.72 KB
/
Copy pathMakefile
File metadata and controls
171 lines (139 loc) · 4.72 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# -------------------------------------------------------------------
# Configuration
# -------------------------------------------------------------------
NIGHTLY ?= nightly
V ?=
LINT_CMDS := cargo cargo-machete
LINT_EXTRA_CMDS := typos taplo shellcheck actionlint
AUDIT_CMDS := cargo-audit cargo-deny
ifneq ($(V),)
_NOCAPTURE := -- --nocapture
endif
.PHONY: all build release check clean \
test mutants lint lint-extra fmt doc audit semver \
coverage coverage-check \
check-prereqs check-prereqs-extra check-prereqs-audit check-prereqs-nightly \
setup-hooks \
help
# -------------------------------------------------------------------
# All
# -------------------------------------------------------------------
all: build lint lint-extra test audit
# -------------------------------------------------------------------
# Build
# -------------------------------------------------------------------
build:
cargo build --all-targets --features test-support
release:
cargo build --release
check:
cargo check --all-targets --features test-support
clean:
cargo clean
# -------------------------------------------------------------------
# Test
# -------------------------------------------------------------------
test:
cargo test --features test-support $(_NOCAPTURE)
mutants:
cargo mutants --features test-support
# -------------------------------------------------------------------
# Prerequisites
# -------------------------------------------------------------------
check-prereqs:
@for cmd in $(LINT_CMDS); do \
command -v "$$cmd" >/dev/null 2>&1 || { \
echo "\"$$cmd\" is not installed" >&2; \
exit 1; \
}; \
done
check-prereqs-extra:
@for cmd in $(LINT_EXTRA_CMDS); do \
command -v "$$cmd" >/dev/null 2>&1 || { \
echo "\"$$cmd\" is not installed" >&2; \
exit 1; \
}; \
done
check-prereqs-audit:
@for cmd in $(AUDIT_CMDS); do \
command -v "$$cmd" >/dev/null 2>&1 || { \
echo "\"$$cmd\" is not installed" >&2; \
exit 1; \
}; \
done
check-prereqs-nightly:
@cargo +$(NIGHTLY) fmt --version >/dev/null 2>&1 || { \
echo "nightly rustfmt is not installed - run \"rustup toolchain install $(NIGHTLY) --component rustfmt\"" >&2; \
exit 1; \
}
# -------------------------------------------------------------------
# Quality
# -------------------------------------------------------------------
lint: check-prereqs check-prereqs-nightly
cargo clippy --all-targets --features test-support -- -D warnings
cargo +$(NIGHTLY) fmt --all -- --check
cargo machete
lint-extra: check-prereqs-extra
typos
taplo fmt --check
shellcheck .hooks/pre-commit
actionlint
fmt: check-prereqs-nightly
cargo +$(NIGHTLY) fmt --all
doc:
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items --features test-support
audit: check-prereqs-audit
cargo audit
cargo deny check
coverage:
cargo llvm-cov --features test-support \
--html --output-dir target/coverage \
--ignore-filename-regex 'src/main\.rs' \
--fail-under-lines 90 \
--fail-under-regions 80
coverage-check:
cargo llvm-cov --features test-support \
--ignore-filename-regex 'src/main\.rs' \
--fail-under-lines 90 \
--fail-under-regions 80
semver:
cargo semver-checks
# -------------------------------------------------------------------
# Dev Setup
# -------------------------------------------------------------------
setup-hooks:
@ln -sf ../../.hooks/pre-commit .git/hooks/pre-commit
@echo "Git hooks installed"
# -------------------------------------------------------------------
# Help
# -------------------------------------------------------------------
help:
@echo "Variables:"
@echo " V=1 show test output (--nocapture)"
@echo " NIGHTLY nightly toolchain name for rustfmt"
@echo ""
@echo "Top-level:"
@echo " all build + lint + lint-extra + test + audit"
@echo ""
@echo "Build:"
@echo " build cargo build --all-targets"
@echo " release cargo build --release"
@echo " check cargo check --all-targets"
@echo " clean cargo clean"
@echo ""
@echo "Test:"
@echo " test run all tests"
@echo " mutants mutation testing (cargo-mutants)"
@echo ""
@echo "Quality:"
@echo " lint clippy + rustfmt check + machete"
@echo " lint-extra typos + taplo + shellcheck + actionlint"
@echo " fmt format with nightly rustfmt"
@echo " doc build docs with warnings denied"
@echo " audit cargo audit + cargo deny"
@echo " semver cargo semver-checks"
@echo " coverage HTML coverage report"
@echo " coverage-check fail if lines < 90%% or regions < 80%%"
@echo ""
@echo "Dev Setup:"
@echo " setup-hooks install git pre-commit hook"