-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile.toml
301 lines (247 loc) · 9.13 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
[config]
default_to_workspace = false
skip_core_tasks = true
[tasks.clean]
command = "cargo"
args = ["clean"]
[tasks.clippy]
command = "cargo"
args = ["clippy", "--all"]
[tasks.clippy-tests]
command = "cargo"
args = ["clippy", "--all", "--tests", "--features=localhost-testing,multi-threaded"]
[tasks.fmt]
command = "cargo"
args = ["fmt", "--all"]
[tasks.git_lfs_fetch]
command = "git"
args = ["lfs", "fetch"]
[tasks.git_lfs]
command = "git"
args = ["lfs", "pull"]
dependencies = ["git_lfs_fetch"]
[tasks.docs-html]
command = "cargo"
args = ["doc", "--package", "citadel_sdk", "--features=webrtc,doc-images", "--no-deps", "--release"]
dependencies = ["git_lfs"]
[tasks.pr]
dependencies = ["fmt", "clippy", "clippy-tests"]
[tasks.install-binstall]
install_crate = { crate_name = "cargo-binstall", binary = "cargo", test_arg = ["binstall", "--help"] }
[tasks.install-nextest]
command = "cargo"
args = ["binstall", "cargo-nextest", "--secure", "-y"]
dependencies = ["install-binstall"]
[tasks.test-local]
command = "cargo"
description = "Tests all available unit/integration tests locally without using SQL/redis backends and appropriate localhost network settings"
env = { "SKIP_EXT_BACKENDS" = "true" }
args = ["nextest", "run", "--features", "localhost-testing"]
dependencies = ["install-nextest"]
[tasks.test]
command = "cargo"
description = "Tests all available unit/integration tests locally using SQL/redis backends and appropriate localhost network settings"
condition = { env_set = [ "TESTING_SQL_SERVER_ADDR_CLIENT", "TESTING_SQL_SERVER_ADDR_SERVER" ], env_not_set = ["SKIP_EXT_BACKENDS"] }
args = ["nextest", "run", "--features", "localhost-testing"]
dependencies = ["install-nextest"]
[tasks.install.mac]
command = "brew"
args = ["install", "llvm@13", "openssl", "cmake"]
[tasks.install.windows]
command = "set"
args = ["OPENSSL_ROOT_DIR=C:/Program Files/OpenSSL-Win64"]
dependencies = ["install_deps"]
[tasks.install_deps.windows]
command = "choco"
args = ["install", "-y", "llvm", "openssl", "cmake"]
[tasks.docs]
script_runner = "@rust"
env = { "CARGO_MAKE_RUST_SCRIPT_PROVIDER" = "cargo-script" }
dependencies = ["docs-html"]
script = '''
//! ```cargo
fn main() {
std::fs::copy(
"./resources/avarok.png",
"./target/doc/citadel_sdk/avarok.png",
)
.expect("Failed to copy crate logo when building documentation.");
std::fs::copy(
"./resources/favicon.png",
"./target/doc/citadel_sdk/favicon.png",
)
.expect("Failed to copy crate favicon when building documentation.");
}
'''
[tasks.install-llvm-tools]
command = "rustup"
args = ["component", "add", "llvm-tools-preview", "--toolchain", "nightly"]
[tasks.install-llvm-cov]
install_crate = { crate_name = "cargo-llvm-cov", binary = "cargo", test_arg = ["llvm-cov", "--help"] }
dependencies = ["install-llvm-tools"]
[tasks.cov]
command = "cargo"
description = "Used to generate coverage information. Add --html (local) or --lcov (pipeline) for an exportable report"
env = { "SKIP_EXT_BACKENDS" = "true" }
args = ["llvm-cov", "nextest", "--features=filesystem,localhost-testing,multi-threaded", "--ignore-filename-regex=\"firebase-rtdb/src/lib.rs|netbeam/src/sync/operations/net_join.rs|netbeam/src/sync/operations/net_select.rs|citadel_sdk/src/test_common.rs|citadel_wire/src/upnp_handler.rs\"", "${@}"]
dependencies = ["install-nextest", "install-llvm-cov"]
[tasks.bump-proto-inner]
script_runner = "@rust"
description = "Bumps the version of the inner protocol. Should not be syned with the crate versions"
script = '''
//! ```cargo
use std::str::FromStr;
fn main() {
let bump_major = std::env::var("BUMP_PROTO_CITADEL_MAJOR").ok();
let bump_minor = std::env::var("BUMP_PROTO_CITADEL_MINOR").ok();
let bump_patch = std::env::var("BUMP_PROTO_CITADEL_PATCH").ok();
const MAJOR_VERS_STR: &str = "pub const MAJOR_VERSION: u8 = ";
const MINOR_VERS_STR: &str = "pub const MINOR_VERSION: u8 = ";
const PATCH_VERS_STR: &str = "pub const PATCH_VERSION: u8 = ";
let cnt = bump_major.is_some() as u8 + bump_minor.is_some() as u8 + bump_patch.is_some() as u8;
if cnt == 0 || cnt > 1 {
panic!("Exactly one relevant environment variable must be set")
}
let constants_file_str = std::fs::read_to_string("./citadel_proto/src/constants.rs").unwrap();
let mut new_constants_file = vec![];
let mut current_major_version = None;
let mut current_minor_version = None;
let mut current_patch_version = None;
// step 1: extract current values
for line in constants_file_str.lines() {
if let Some(major) = maybe_extract_value_for(line, MAJOR_VERS_STR) {
current_major_version = Some(major)
}
if let Some(minor) = maybe_extract_value_for(line, MINOR_VERS_STR) {
current_minor_version = Some(minor)
}
if let Some(patch) = maybe_extract_value_for(line, PATCH_VERS_STR) {
current_patch_version = Some(patch)
}
if current_major_version.is_some()
&& current_minor_version.is_some()
&& current_patch_version.is_some()
{
break;
}
}
let (current_major_version, current_minor_version, current_patch_version) = (
current_major_version.unwrap(),
current_minor_version.unwrap(),
current_patch_version.unwrap(),
);
// step 2: calculate next values
let (new_major, new_minor, new_patch) = if bump_major.is_some() {
(current_major_version + 1, 0u8, 0u8)
} else if bump_minor.is_some() {
(current_major_version, current_minor_version + 1, 0u8)
} else {
// bump patch
(
current_major_version,
current_minor_version,
current_patch_version + 1,
)
};
// step 3: begin writing the new file
for line in constants_file_str.lines() {
if line.contains(MAJOR_VERS_STR) {
new_constants_file.push(format!("{}{};", MAJOR_VERS_STR, new_major));
continue;
}
if line.contains(MINOR_VERS_STR) {
new_constants_file.push(format!("{}{};", MINOR_VERS_STR, new_minor));
continue;
}
if line.contains(PATCH_VERS_STR) {
new_constants_file.push(format!("{}{};", PATCH_VERS_STR, new_patch));
continue;
}
new_constants_file.push(line.to_string())
}
new_constants_file.push("\n".to_string());
std::fs::write(
"./citadel_proto/src/constants.rs",
new_constants_file.join("\n"),
)
.unwrap()
}
fn maybe_extract_value_for(line: &str, line_str_name: &str) -> Option<u8> {
if line.contains(line_str_name) {
let current_value = line
.split(line_str_name)
.skip(1)
.next()
.unwrap()
.trim()
.replace(";", "");
Some(u8::from_str(¤t_value).unwrap())
} else {
None
}
}
'''
[tasks.format-proto]
command = "cargo"
args = ["fmt", "--package", "citadel_proto"]
[tasks.bump-proto-major]
env = { "BUMP_PROTO_CITADEL_MAJOR" = "true" }
run_task = [
{ name = "bump-proto-inner" },
{ name = "format-proto" }
]
[tasks.bump-proto-minor]
env = { "BUMP_PROTO_CITADEL_MINOR" = "true" }
run_task = [
{ name = "bump-proto-inner" },
{ name = "format-proto" }
]
[tasks.bump-proto-patch]
env = { "BUMP_PROTO_CITADEL_PATCH" = "true" }
run_task = [
{ name = "bump-proto-inner" },
{ name = "format-proto" }
]
[tasks.publish-install-deps]
install_crate = { crate_name = "cargo-workspaces", binary = "cargo", test_arg = ["workspaces", "--help"] }
[tasks.publish-bump-version-patch]
condition = { env_set = [ "CARGO_REGISTRY_TOKEN" ] }
command = "cargo"
args = ["workspaces", "version", "-y", "minor"]
[tasks.publish-bump-version-minor]
condition = { env_set = [ "CARGO_REGISTRY_TOKEN" ] }
command = "cargo"
args = ["workspaces", "version", "-y", "minor"]
[tasks.publish-bump-version-major]
condition = { env_set = [ "CARGO_REGISTRY_TOKEN" ] }
command = "cargo"
args = ["workspaces", "version", "-y", "major"]
[tasks.publish-patch]
command = "cargo"
condition = { env_set = [ "CARGO_REGISTRY_TOKEN" ] }
args = ["workspaces", "publish", "-y", "--token", "${CARGO_REGISTRY_TOKEN}", "--allow-dirty", "patch", "${@}"]
dependencies = ["publish-install-deps"]
[tasks.publish-minor]
command = "cargo"
condition = { env_set = [ "CARGO_REGISTRY_TOKEN" ] }
args = ["workspaces", "publish", "-y", "--token", "${CARGO_REGISTRY_TOKEN}", "--allow-dirty", "minor", "${@}"]
dependencies = ["publish-install-deps"]
[tasks.publish-major]
command = "cargo"
condition = { env_set = [ "CARGO_REGISTRY_TOKEN" ] }
args = ["workspaces", "publish", "-y", "--token", "${CARGO_REGISTRY_TOKEN}", "--allow-dirty", "major", "${@}"]
dependencies = ["publish-install-deps"]
[tasks.check-docs]
command = "cargo"
args = ["test", "--package", "citadel_sdk", "--doc"]
[tasks.install-cargo-wasix]
command = "cargo"
args = ["install", "cargo-wasix"]
[tasks.wasix-fix]
description = "If you have a wasix error, run this task to potentially fix it"
command = "cargo"
args = ["wasix", "download-toolchain"]
[tasks.wasix]
command = "cargo"
args = ["--config=Cargo.wasix.toml", "wasix", "${@}", "--profile=wasix"]
dependencies = ["install-nextest", "install-cargo-wasix"]