-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrust-pre-commit
More file actions
executable file
·47 lines (43 loc) · 1.42 KB
/
rust-pre-commit
File metadata and controls
executable file
·47 lines (43 loc) · 1.42 KB
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
#!/bin/sh
# A pre-commit hook that ensures a Rust project with ast-grep rules and Python
# bindings contains no errors or warnings.
# Fail the entire hook immediately if any of the commands fails.
set -e
# Set the profiles to use for all of the cargo-based tools that supports it.
profiles="dev release"
# Ensure the following commands does not emit any errors or warnings.
# - Compilers: cargo build
# - Linters: ast-grep, cargo clippy, and cargo machette
# - Documentation Generator: cargo doc
# - Unit Tests and Integration Tests: cargo test and python unittest
for profile in $profiles
do
echo "Profile $profile"
echo "Ast-grep Scan"
sg scan
echo
echo "Cargo Build"
RUSTFLAGS="-D warnings" cargo build --profile $profile --all-targets
echo
echo "Cargo Clippy"
RUSTFLAGS="-D warnings" cargo clippy --profile $profile --all-targets
echo
echo "Cargo Doc"
RUSTDOCFLAGS="-D warnings" cargo doc --profile $profile --no-deps
echo
echo "Cargo Machette"
cargo machete --with-metadata
echo
echo "Cargo Test"
RUSTFLAGS="-D warnings" cargo test --profile $profile --all-targets -- --nocapture
echo
echo "Python Sphinx"
pushd "crates/modelardb_embedded/bindings/python/docs" > /dev/null
make html
popd > /dev/null
echo
echo "Python Test"
pushd "crates/modelardb_embedded/bindings/python" > /dev/null
python -m unittest --verbose
popd > /dev/null
done