-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
147 lines (119 loc) · 4.69 KB
/
justfile
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
#!/usr/bin/env just --justfile
sqlite3 := 'sqlite3'
@_default:
just --list --unsorted
# Clean all build artifacts
clean:
cargo clean
update:
cargo +nightly -Z unstable-options update --breaking
cargo update
build: build-lib build-ext
build-lib:
cargo build --workspace
build-ext *ARGS:
cargo build --example sqlite_compressions --no-default-features --features default_loadable_extension {{ ARGS }}
cross-build-ext *ARGS:
cross build --example sqlite_compressions --no-default-features --features default_loadable_extension {{ ARGS }}
cross-build-ext-aarch64: (cross-build-ext "--target=aarch64-unknown-linux-gnu" "--release")
# Run cargo clippy
clippy:
cargo clippy -- -D warnings
cargo clippy --workspace --all-targets -- -D warnings
# Test code formatting
test-fmt:
cargo fmt --all -- --check
# Run cargo fmt
fmt:
cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate
# Build and open code documentation
docs:
cargo doc --no-deps --open
# Quick compile
check:
RUSTFLAGS='-D warnings' cargo check --workspace --all-targets
# Quick compile - lib-only
check-lib:
RUSTFLAGS='-D warnings' cargo check --workspace
# Test the library
test *ARGS: \
( test-one-lib ) \
( test-one-lib "--no-default-features" "--features" "gzip,brotli,bzip2,bsdiff4,bsdiffraw" ) \
( test-one-lib "--no-default-features" "--features" "trace,brotli" ) \
( test-one-lib "--no-default-features" "--features" "trace,bsdiff4" ) \
( test-one-lib "--no-default-features" "--features" "trace,bsdiffraw" ) \
( test-one-lib "--no-default-features" "--features" "trace,bzip2" ) \
( test-one-lib "--no-default-features" "--features" "trace,gzip" )
test-ext: build-ext
./tests/test-ext.sh
cross-test-ext-aarch64:
docker run \
--rm \
-v "$(pwd):/workspace" \
-w /workspace \
--entrypoint sh \
-e EXTENSION_FILE=target/aarch64-unknown-linux-gnu/release/examples/libsqlite_compressions \
--platform linux/arm64 \
arm64v8/ubuntu \
-c 'apt-get update && apt-get install -y sqlite3 && tests/test-ext.sh'
[private]
test-one-lib *ARGS:
@echo "### TEST {{ ARGS }} #######################################################################################################################"
cargo test {{ ARGS }}
# Test documentation
test-doc:
cargo test --doc
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
rust-info:
rustc --version
cargo --version
# Run all tests as expected by CI
ci-test: rust-info test-fmt clippy check test test-ext test-doc
# Run minimal subset of tests to ensure compatibility with MSRV
ci-test-msrv: rust-info check-lib test
[private]
is-sqlite3-available:
#!/usr/bin/env sh
set -eu
if ! command -v {{ sqlite3 }} &> /dev/null; then
echo "{{ sqlite3 }} executable could not be found"
exit 1
fi
echo "Found {{ sqlite3 }} executable:"
{{ sqlite3 }} --version
# Run integration tests and save its output as the new expected output
bless *ARGS: (cargo-install "cargo-insta")
cargo insta test --accept --unreferenced=auto {{ ARGS }}
# Check if a certain Cargo command is installed, and install it if needed
[private]
cargo-install $COMMAND $INSTALL_CMD="" *ARGS="":
#!/usr/bin/env sh
set -eu
if ! command -v $COMMAND > /dev/null; then
if ! command -v cargo-binstall > /dev/null; then
echo "$COMMAND could not be found. Installing it with cargo install ${INSTALL_CMD:-$COMMAND} {{ ARGS }}"
cargo install ${INSTALL_CMD:-$COMMAND} {{ ARGS }}
else
echo "$COMMAND could not be found. Installing it with cargo binstall ${INSTALL_CMD:-$COMMAND} {{ ARGS }}"
cargo binstall ${INSTALL_CMD:-$COMMAND} {{ ARGS }}
fi
fi
# Run benchmarks
bench:
cargo bench
open target/criterion/report/index.html
# Verify that the current version of the crate is not the same as the one published on crates.io
check-if-published:
#!/usr/bin/env bash
LOCAL_VERSION="$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]*)".*/\1/')"
echo "Detected crate version: $LOCAL_VERSION"
CRATE_NAME="$(grep '^name =' Cargo.toml | head -1 | sed -E 's/name = "(.*)"/\1/')"
echo "Detected crate name: $CRATE_NAME"
PUBLISHED_VERSION="$(cargo search ${CRATE_NAME} | grep "^${CRATE_NAME} =" | sed -E 's/.* = "(.*)".*/\1/')"
echo "Published crate version: $PUBLISHED_VERSION"
if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
echo "ERROR: The current crate version has already been published."
exit 1
else
echo "The current crate version has not yet been published."
fi