-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
executable file
·162 lines (130 loc) · 3.59 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
#!/usr/bin/env -S just --justfile
set dotenv-load := true
alias d := dev
alias r := run
alias f := fmt
alias l := lint
alias t := test
alias c := comply
alias k := check
# List available commands.
_default:
just --list --unsorted
# Setup the repository.
setup: _areyousure
just _cargo-install 'cargo-edit cargo-nextest cargo-outdated dprint git-cliff bacon typos-cli'
just _cargo-install 'sqlx-cli'
# Tasks to make the code-base comply with the rules. Mostly used in git hooks.
comply: _doc-check _update-sqlx-schema fmt lint test
# Check if the repository comply with the rules and ready to be pushed.
check: _doc-check _check-sqlx-schema fmt-check lint test
# Develop the app.
dev:
bacon
# Run the app.
run:
cargo run
# Build the container image.
image-build:
docker build --tag pulseapi:latest --build-arg VCS_REVISION=$(git rev-parse --short HEAD) .
# Run the container.
image-start service="":
docker-compose --file docker-compose.local.yml up {{ service }} -d
# Stop the container.
image-stop:
docker-compose --file docker-compose.local.yml down
# Restart the containers.
image-restart:
just image-stop
just image-run
# Format the codebase.
fmt:
cargo fmt --all
dprint fmt
# Check is the codebase properly formatted.
fmt-check:
cargo fmt --all -- --check
dprint check
# Lint the codebase.
lint:
cargo clippy --all-targets --all-features
typos --config configs/typos.toml
# Test the codebase.
test:
cargo nextest run --config-file configs/nextest.toml
# Run the unit tests.
test-unit:
cargo nextest run --lib
# Create a new release. Example `cargo-release release minor --tag-name v0.2.0`
release level:
cargo-release release {{ level }} --execute
# Make sure the repo is ready for release
release-check level: check
just up
cargo-release release {{ level }}
# Setup the database schema.
db-migrate:
sqlx database create
# sqlx migrate run # auto migration enabled
# reset the database schema.
db-reset:
sqlx database drop && sqlx database create
# Check the documentation.
_doc-check:
cargo doc --all-features --no-deps
_update-sqlx-schema:
cargo sqlx prepare -- --lib
_check-sqlx-schema:
cargo sqlx prepare --check -- --lib
# Release hooks
_release-prepare version:
git-cliff --config configs/cliff.toml --output CHANGELOG.md --tag {{ version }}
just fmt
# Check dependencies health. Pass `--write` to uppgrade dependencies.
[unix]
up arg="":
#!/usr/bin/env bash
if [ "{{ arg }}" = "--write" ]; then
cargo upgrade
cargo update
else
cargo outdated --root-deps-only
fi;
[windows]
up arg="":
#!powershell.exe
if ( "tool" -eq "--write") {
cargo upgrade
cargo update
}
else {
cargo outdated --root-deps-only
}
#
# Helper
#
[unix]
_cargo-install tool:
#!/usr/bin/env bash
if command -v cargo-binstall >/dev/null 2>&1; then
echo "cargo-binstall..."
cargo binstall --no-confirm --no-symlinks {{ tool }}
else
echo "Building from source"
cargo install --locked {{ tool }}
fi
[unix]
_areyousure:
#!/usr/bin/env bash
echo -e "This command will alter your system. ⚠️
You are advised to run in inside containerized environment.
Such as [toolbx](https://containertoolbx.org/).
If you are unsure. Run the installation commands manually.
Take a look at the 'setup' recipe in the Justfile.\n"
read -p "Are you sure you want to proceed? (Y/n) " response;
if [[ $response =~ ^[Yy] ]]; then
echo "Continue!";
else
echo "Cancelled!";
exit 1;
fi