-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
111 lines (90 loc) · 2 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
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
# Derived from https://github.com/juspay/hyperswitch/blob/main/Makefile
# = Parameters
# Override envars using -e
#
# = Common
#
# Checks two given strings for equality.
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
$(findstring $(2),$(1))),1)
#
# = Targets
#
.PHONY : \
init-repo \
migrate-run \
migrate-create \
prepare \
prepare-check \
doc \
fmt \
clippy \
test \
audit \
git.sync \
build \
push \
shell \
run \
start \
stop \
rm \
release \
coverage
init-repo:
cargo install --version="~0.8" sqlx-cli --no-default-features --features rustls,postgres
./cpast_api/scripts/init_db.sh
./cpast_api/scripts/init_redis.sh
# Compile application for running on local machine
#
# Usage :
# make build
build :
cargo build
# Generate crates documentation from Rust sources.
#
# Usage :
# make doc [private=(yes|no)] [open=(yes|no)] [clean=(no|yes)]
doc :
ifeq ($(clean),yes)
@rm -rf target/doc/
endif
SQLX_OFFLINE=true cargo doc --all-features --no-deps\
$(if $(call eq,$(private),no),,--document-private-items) \
$(if $(call eq,$(open),no),,--open)
# Format Rust sources with rustfmt.
#
# Usage :
# make fmt [fix=(no|yes)]
fmt :
cargo fmt --all $(if $(call eq,$(fix),yes),,-- --check)
# Lint Rust sources with Clippy.
#
# Usage :
# make clippy
clippy :
cargo clippy --all-features --all-targets -- -D warnings
# Run Rust tests of project.
#
# Usage :
# make test
test :
cargo test --all-features
# Usage
# make migrate-run new_fancy_table
migrate-create:
cd cpast_api && cargo sqlx migrate add -r $(1)
migrate-run:
cd cpast_api && cargo sqlx migrate run
prepare:
cargo sqlx prepare --workspace -- --all-targets
prepare-check:
cargo sqlx prepare --workspace --check -- --all-targets
# Run format clippy test and tests.
#
# Usage :
# make precommit
coverage:
cargo llvm-cov clean --workspace --html --output-dir=coverage
cargo llvm-cov --all-features --workspace --no-clean --html --output-dir=coverage --open
precommit : fmt clippy test prepare-check