forked from shuttle-hq/shuttle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.toml
185 lines (163 loc) · 4.5 KB
/
Makefile.toml
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# 1. cargo install cargo-make
# 2. cargo make <task_name>
# cargo make docs: https://sagiegurari.github.io/cargo-make/
# duckscript docs: https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md
[config]
default_to_workspace = false
[env]
RUST_BACKTRACE = 0
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
# TAG = { script = ["git describe --tags --abbrev=0"] }
[tasks.fmt]
command = "cargo"
args = ["fmt", "--all", "--check"]
[tasks.clippy]
command = "cargo"
args = [
"clippy",
"--tests",
"--all-targets",
"--all-features",
"--no-deps",
"--",
"--D",
"warnings",
]
# Provide the name of the workspace member
# Example: cargo make test-member shuttle-proto
[tasks.test-member]
# run unit tests for a workspace crate
command = "cargo"
args = [
"test",
"-p",
"${@}",
"--all-features",
"--lib",
"--",
"--nocapture",
]
[tasks.test-member-integration]
# run integration tests for a workspace crate
command = "cargo"
args = [
"test",
"-p",
"${@}",
"--all-features",
"--test",
"*",
"--",
"--skip",
"needs_docker",
"--nocapture",
]
[tasks.test-member-integration-docker]
# run integration tests for a workspace crate that need access to docker
command = "cargo"
args = [
"test",
"-p",
"${@}",
"--all-features",
"--test",
"*",
"--",
"needs_docker",
"--nocapture",
]
[tasks.audit]
install_crate = { crate_name = "cargo-audit", binary = "cargo", test_arg = ["audit", "-V"], min_version = "0.18.3" }
command = "cargo"
args = ["audit", "-D", "warnings"]
[tasks.check-lockfile-patches]
script = '''
if [ -n "$(grep "\[\[patch.unused\]\]" Cargo.lock)" ]; then
echo "Please remove unused patches from Cargo.lock"
exit 1
fi
'''
[tasks.check-lockfile]
script = '''
if ! git diff --exit-code Cargo.lock; then
echo "Please commit an up to date Cargo.lock"
exit 1
fi
'''
[tasks.proto]
# To generate: cargo make proto
# To validate: cargo make proto validate
# Requires `protoc` to be installed
install_crate = { crate_name = "proto-gen", binary = "proto-gen", test_arg = "-V", version = "0.2.0" }
script = '''
OP="generate"
if [ "$1" = "validate" ]; then
OP="validate"
fi
proto-gen \
--generate-transport --build-client --build-server --format \
$OP \
-d proto \
-o proto/src/generated \
-f proto/logger.proto \
-f proto/provisioner.proto \
-f proto/resource-recorder.proto \
-f proto/runtime.proto
'''
[tasks.changelog]
# Provide the version to generate for
# Example: cargo make changelog 0.37.0
install_crate = { crate_name = "git-cliff", binary = "git-cliff", test_arg = ["-V"], min_version = "2.1.2" }
command = "git-cliff"
args = ["-o", "CHANGELOG.md", "-t", "${@}"]
### CI TASKS
[tasks.ci-workspace]
run_task = { name = [
"check-lockfile-patches",
"fmt",
"clippy",
"check-lockfile",
] }
[tasks.ci-standalone]
# Provide paths to crates to test
# Example: cargo make ci-standalone services/shuttle-axum
script_runner = "@duckscript"
script = '''
alias run exec --fail-on-error
for path in ${@}
if not ${path}
echo No crate path provided
exit 1
end
manifest = set "${path}/Cargo.toml"
if not is_path_exists ${manifest}
echo manifest not found: ${manifest}
exit 1
end
feature_flags = array "--all-features"
###### Crates that have mutually exclusive features define
###### their own set of feature flags to test:
if eq ${path} "resources/shared-db"
feature_flags = array "-F mongodb" "-F postgres" "-F postgres,sqlx" "-F postgres,sqlx-native-tls" "-F postgres,diesel-async" "-F postgres,diesel-async-bb8" "-F postgres,diesel-async-deadpool"
elseif eq ${path} "services/shuttle-axum"
feature_flags = array "-F axum" "-F axum-0-6"
elseif eq ${path} "services/shuttle-serenity"
feature_flags = array "-F serenity,rustls_backend" "-F serenity,native_tls_backend" "-F serenity-0-11-rustls_backend" "-F serenity-0-11-native_tls_backend"
end
echo
println -s bold "### Manifest:"
println -s bold " ${manifest}"
echo
run cargo fmt --all --check --manifest-path ${manifest}
for f in ${feature_flags}
echo
println -s bold "### Feature flags:"
println -s bold " ${f}"
echo
# In the default case, --all-features overrides --no-default-features.
# --no-default-features is used for enabling special sets of feature flags.
run cargo clippy --tests --all-targets --no-default-features ${f} --manifest-path ${manifest} --no-deps -- --D warnings
run cargo test --no-default-features ${f} --manifest-path ${manifest} -- --nocapture
end
end
'''