forked from juspay/hyperswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
149 lines (115 loc) · 3.33 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
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
# = 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)
ROOT_DIR_WITH_SLASH := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
ROOT_DIR := $(realpath $(ROOT_DIR_WITH_SLASH))
#
# = Targets
#
.PHONY : \
doc \
fmt \
clippy \
test \
audit \
git.sync \
build \
push \
shell \
run \
start \
stop \
rm \
release
# Check a local package and all of its dependencies for errors
#
# Usage :
# make check
check:
cargo check
# 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
cargo doc --all-features --package router \
$(if $(call eq,$(private),no),,--document-private-items) \
$(if $(call eq,$(open),no),,--open)
# Format Rust sources with rustfmt.
#
# Usage :
# make fmt [dry_run=(no|yes)]
fmt :
cargo +nightly fmt --all $(if $(call eq,$(dry_run),yes),-- --check,)
# Lint Rust sources with Clippy.
#
# Usage :
# make clippy
clippy :
cargo clippy --all-features --all-targets -- -D warnings
# Build the DSL crate as a WebAssembly JS library
#
# Usage :
# make euclid-wasm
euclid-wasm:
wasm-pack build --target web --out-dir $(ROOT_DIR)/wasm --out-name euclid $(ROOT_DIR)/crates/euclid_wasm -- --features dummy_connector
# Run Rust tests of project.
#
# Usage :
# make test
test :
cargo test --all-features
# Next-generation test runner for Rust.
# cargo nextest ignores the doctests at the moment. So if you are using it locally you also have to run `cargo test --doc`.
# Usage:
# make nextest
nextest:
cargo nextest run
# Run format clippy test and tests.
#
# Usage :
# make precommit
precommit : fmt clippy test
hack:
cargo hack check --workspace --each-feature --all-targets
# Run database migrations using `diesel_cli`.
# Assumes `diesel_cli` is already installed.
#
# Usage :
# make migrate [database-url=<PSQL connection string>] [locked-schema=<yes|no>]
# This proceeds as follows:
# Creates a temporary migrations directory, cleans it up if it already exists
# Copies all migrations to the temporary migrations directory and runs migrations
# Cleans up migrations, removing tmp directory if empty, ignoring otherwise
migrate:
mkdir -p $(ROOT_DIR)/tmp/migrations
find $(ROOT_DIR)/tmp/migrations/ -mindepth 1 -delete
cp -r $(ROOT_DIR)/migrations/. $(ROOT_DIR)/v2_migrations/. $(ROOT_DIR)/tmp/migrations/
diesel migration run --migration-dir=$(ROOT_DIR)/tmp/migrations \
$(if $(strip $(database-url)),--database-url="$(database-url)",) \
$(if $(strip $(call eq,$(locked-schema),yes)),--locked-schema,)
rm -r $(ROOT_DIR)/tmp/migrations
rmdir $(ROOT_DIR)/tmp 2>/dev/null || true
redo_migrate:
mkdir -p $(ROOT_DIR)/tmp/migrations
find $(ROOT_DIR)/tmp/migrations/ -mindepth 1 -delete
cp -r $(ROOT_DIR)/migrations/. $(ROOT_DIR)/v2_migrations/. $(ROOT_DIR)/tmp/migrations/
diesel migration redo --all --migration-dir=$(ROOT_DIR)/tmp/migrations \
$(if $(strip $(database-url)),--database-url="$(database-url)",) \
$(if $(strip $(call eq,$(locked-schema),yes)),--locked-schema,)
rm -r $(ROOT_DIR)/tmp/migrations
rmdir $(ROOT_DIR)/tmp 2>/dev/null || true