-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
80 lines (63 loc) · 2.01 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
set dotenv-load := false
version := `cat ./crates/prbot/Cargo.toml | sed -n "s/^version = \"\(.*\)\"/\1/p"`
_default:
@just -l
# Check code style
fmt:
cargo +nightly fmt --all -- \
--unstable-features \
--config \
imports_granularity=Crate,\
group_imports=StdExternalCrate
# Check code style and error if changes are needed
fmt-check:
cargo fmt --all -- --check
# Lint files
lint:
cargo clippy --all-features --all --tests
# Lint files and error on warnings
lint-err:
cargo clippy --all-features --all --tests -- -D warnings
# Debug build
build:
cargo build --all
# Release build
build-release:
cargo build --all --release
# Test
test:
cargo test --all
# Test with coverage
test-cov:
rm -rf .cov
RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE=".cov/test-%p-%m.profraw" cargo build
RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE=".cov/test-%p-%m.profraw" cargo test
grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
# Build HTML coverage
test-cov-html:
rm -rf .cov
rm -rf htmlcov
RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE=".cov/test-%p-%m.profraw" cargo build
RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE=".cov/test-%p-%m.profraw" cargo test
grcov . --binary-path ./target/debug/ -s . -t html --branch --ignore-not-existing --ignore "/*" -o htmlcov
# Set crates version
set-version v:
ls -d crates/prbot-*/Cargo.toml | xargs sed -i "s/^version = \"\(.*\)\"/version = \"{{ v }}\"/"
# Show version
show-version:
@echo {{ version }}
# Run server (debug)
run-server:
RUST_LOG=info,prbot=debug,sqlx=warn cargo run -q -- server
# Run server (release)
run-server-release:
RUST_LOG=info,prbot=debug,sqlx=warn cargo run -q --release -- server
# Run server (watch)
run-server-watch:
RUST_LOG=info,prbot=debug,sqlx=warn cargo watch -x "run -- server"
# Build Docker image
docker-build:
docker build --rm -t prbot:v{{ version }} -f ./docker/Dockerfile .
# Push Docker image
docker-push reg:
docker push {{ reg }}/prbot:v{{ version }}