This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
generated from clechasseur/rust-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
163 lines (119 loc) · 5.33 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
toolchain := ""
tool := "cargo"
cargo := tool + (if toolchain != "" { " +" + toolchain } else { "" })
all_features := "true"
all_features_flag := if all_features == "true" { "--all-features" } else { "" }
all_targets := "true"
all_targets_flag := if all_targets == "true" { "--all-targets" } else { "" }
message_format := ""
message_format_flag := if message_format != "" { "--message-format " + message_format } else { "" }
target_tuple := ""
target_tuple_flag := if target_tuple != "" { "--target " + target_tuple } else { "" }
cargo_tarpaulin := cargo + " tarpaulin"
docker-compose-build := if toolchain == "nightly" {
"RUST_TAG=nightly docker compose build --build-arg RUST_TOOLCHAIN=nightly"
} else if toolchain != "" {
"RUST_TAG=" + toolchain + " docker compose build --build-arg RUST_VERSION=" + toolchain
} else {
"docker compose build"
}
docker-compose-run := if toolchain == "nightly" {
"RUST_TAG=nightly docker compose run --env RUST_TOOLCHAIN=nightly"
} else if toolchain != "" {
"RUST_TAG=" + toolchain + " docker compose run --env RUST_VERSION=" + toolchain
} else {
"docker compose run"
}
[private]
default:
@just --list
# Run clippy and rustfmt on workspace files
tidy: clippy fmt
# Run clippy on workspace files
clippy:
{{cargo}} clippy --workspace {{all_targets_flag}} {{all_features_flag}} {{target_tuple_flag}} -- -D warnings
# Run rustfmt on workspace files
fmt:
cargo +nightly fmt --all
# Run `cargo check` on workspace
check *extra_args:
{{cargo}} check --workspace {{all_targets_flag}} {{all_features_flag}} {{message_format_flag}} {{target_tuple_flag}} {{extra_args}}
# Run `cargo build` on workspace
build *extra_args:
{{cargo}} build --workspace {{all_targets_flag}} {{all_features_flag}} {{message_format_flag}} {{target_tuple_flag}} {{extra_args}}
# Run `cargo test` on workspace
test *extra_args:
{{cargo}} test --workspace {{all_features_flag}} {{message_format_flag}} {{target_tuple_flag}} {{extra_args}}
# Run `cargo update` to update dependencies in Cargo.lock
update *extra_args:
{{cargo}} update {{extra_args}}
# Run `cargo tarpaulin` to produce code coverage
@tarpaulin *extra_args:
@{{cargo_tarpaulin}} --target-dir target-tarpaulin {{extra_args}}
{{ if env('CI', '') == '' { `just _open-tarpaulin` } else { ` ` } }}
[unix]
@_open-tarpaulin:
open tarpaulin-report.html
[windows]
@_open-tarpaulin:
./tarpaulin-report.html
# Generate documentation with rustdoc
doc: _doc
_doc $RUSTDOCFLAGS="-D warnings":
{{cargo}} doc {{ if env('CI', '') != '' { '--no-deps' } else { '--open' } }} --workspace {{all_features_flag}} {{message_format_flag}}
# Check doc coverage with Nightly rustdoc
doc-coverage: _doc-coverage
_doc-coverage $RUSTDOCFLAGS="-Z unstable-options --show-coverage":
cargo +nightly doc --no-deps --workspace {{all_features_flag}} {{message_format_flag}}
[private]
minimize:
{{cargo}} hack --remove-dev-deps --workspace
cargo +nightly update -Z minimal-versions
# Run `cargo minimal-versions check` on workspace
check-minimal: prep _check-minimal-only && (_rimraf "target-minimal") unprep
_check-minimal-only: (_rimraf "target-minimal")
{{cargo}} minimal-versions check --target-dir target-minimal --workspace --lib --bins {{all_features_flag}} {{message_format_flag}}
# Run `cargo msrv` with `cargo minimal-versions check`
msrv-minimal: (prep "--manifest-backup-suffix .msrv-prep.outer.bak") && (_rimraf "target-minimal") (unprep "--manifest-backup-suffix .msrv-prep.outer.bak")
{{cargo}} msrv -- just all_features="{{all_features}}" message_format="{{message_format}}" target_tuple="{{target_tuple}}" _check-minimal-only
# Run `cargo msrv` with `cargo check`
msrv *extra_args: && (_rimraf "target-msrv")
{{cargo}} msrv -- just all_features="{{all_features}}" all_targets="{{all_targets}}" message_format="{{message_format}}" target_tuple="{{target_tuple}}" _msrv-check {{extra_args}}
_msrv-check *extra_args: (_rimraf "target-msrv")
just all_features="{{all_features}}" all_targets="{{all_targets}}" message_format="{{message_format}}" target_tuple="{{target_tuple}}" check --target-dir target-msrv {{extra_args}}
# Perform `cargo publish` dry-run
test-package *extra_args:
{{cargo}} publish --dry-run {{extra_args}}
# Run `cargo msrv-prep` on workspace
prep *extra_args:
{{cargo}} msrv-prep --workspace {{extra_args}}
# Run `cargo msrv-unprep` on workspace
unprep *extra_args:
{{cargo}} msrv-unprep --workspace {{extra_args}}
migrate:
cargo run --bin run_migrations
seed:
cargo run --bin seed_db
serve:
{{cargo}} run
db command:
docker compose {{ if command == "up" { 'up -d' } else { command } }}
docker-build *extra_args:
{{docker-compose-build}} {{extra_args}} pokedex
-docker rmi $(docker images -f "dangling=true" -q)
docker-migrate *extra_args:
{{docker-compose-run}} {{extra_args}} --rm pokedex-migrate
docker-seed *extra_args:
{{docker-compose-run}} {{extra_args}} --rm pokedex-seed
docker-serve *extra_args:
{{docker-compose-run}} {{extra_args}} --service-ports --rm pokedex
# ----- Utilities -----
@_rimraf target_dir:
{{ if path_exists(target_dir) == "true" { "just _rimraf-it '" + target_dir + "'" } else { "" } }}
[unix]
@_rimraf-it target_dir:
rm -rf '{{target_dir}}'
[windows]
@_rimraf-it target_dir:
Remove-Item "{{target_dir}}" -Recurse