-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile.toml
120 lines (101 loc) · 2.81 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
[tasks.run_coverage]
run_task = { name = [
"run_rustlib_coverage_tests",
"get_lcov_report",
"clean_profraw_files",
] }
script_runner = "@shell"
[tasks.get_lcov_report]
cwd = ".."
description = "Generates `lcov` report for `collab`"
script_runner = "@shell"
script = '''
echo Getting 'lcov' results for 'collab'
grcov . \
--binary-path target/debug/deps \
--source-dir . \
--output-type lcov \
--branch \
--ignore-not-existing \
--log-level WARN \
--output-path target/coverage.lcov
echo "--- Done! Generated 'target/coverage.lcov' for collab."
'''
[tasks.run_rustlib_coverage_tests]
cwd = ".."
description = "Run tests with coverage instrumentation"
script_runner = "@shell"
script = '''
echo --- Running coverage tests ---
CARGO_INCREMENTAL=0 \
RUSTFLAGS='-C instrument-coverage' \
LLVM_PROFILE_FILE='prof-%p-%m.profraw' \
cargo test
'''
[tasks.check_grcov]
description = "Check if `grcov` is installled"
script_runner = "@shell"
script = '''
export PATH=$PATH:"$HOME/.cargo/bin/"
if command -v grcov > /dev/null; then
echo "Found 'grcov' executable."
else
echo "[!] Could not find 'grcov' executable."
echo "[!] Please install 'grcov' by running 'cargo install grcov'."
echo "[!] You may also need to install 'llvm-tools-preview' using 'rustup component add llvm-tools-preview'."
echo "[!] If installed, check if 'grcov' is in PATH."
echo "[!] Exiting..."
exit -1
fi
'''
[tasks.clean_profraw_files]
description = "Cleans profraw files that are created by `cargo test`"
script_runner = "@duckscript"
script = ["""
profs = glob_array ./**/*.profraw
for prof in ${profs}
full_path = canonicalize ${prof}
rm ${full_path}
end
"""]
[config]
default_to_workspace = false
#on_error_task = "catch"
#[tasks.catch]
#run_task = { name = ["clean_profraw_files"] }
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
[tasks.wasm_build]
script_runner = "bash"
script = [
"""
#!/bin/bash
BASE_DIR=$(pwd)
crates=("collab" "collab-document" "collab-folder" "collab-user" "collab-plugins")
# Iterate over each crate and build it
for crate in "${crates[@]}"; do
echo "🔥🔥🔥 Building $crate with wasm-pack..."
# Navigate to the crate directory
cd "$BASE_DIR/$crate" || { echo "Failed to enter directory $crate"; exit 1; }
# Build the crate
wasm-pack build || { echo "Build failed for $crate"; exit 1; }
done
"""
]
[tasks.wasm_test]
script_runner = "bash"
script = [
"""
#!/bin/bash
BASE_DIR=$(pwd)
crates=("collab-plugins")
# Iterate over each crate and build it
for crate in "${crates[@]}"; do
echo "🔥🔥🔥 Running $crate tests with wasm-pack..."
# Navigate to the crate directory
cd "$BASE_DIR/$crate" || { echo "Failed to enter directory $crate"; exit 1; }
# Build the crate
wasm-pack test --headless --firefox
done
"""
]