-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
217 lines (171 loc) · 5.7 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
image_name := 'mbari/odss2dash'
# version read from Cargo.toml
# List recipes
list:
@just --list --unsorted
#############################################
# Development:
# Good to run before committing changes
all: test format clippy
# cargo check
check:
cargo check
# cargo watch (with check by default)
watch *cmd='check':
cargo watch -c -x '{{ cmd }}'
# Run tests
test *args='':
cargo test {{args}}
# Run tests with --nocapture
test-nocapture *args='':
cargo test -- --nocapture {{args}}
# Format source code
format:
cargo fmt
# Run clippy
clippy:
cargo clippy --all-targets -- -D warnings
# Build
build *args='--release':
cargo build {{ args }}
# Install
install: build
cargo install --path .
# Create musl based binary
build-musl:
docker run -v $PWD:/volume --rm -t clux/muslrust:stable cargo build --release
ls -lrth target/x86_64-unknown-linux-musl/release/
# List git tags
tags:
git tag -l | sort -V | tail
# Create and push git tag
tag-and-push:
#!/usr/bin/env bash
version=$(tq -f Cargo.toml 'package.version')
echo "tagging and pushing v${version}"
git tag v${version}
git push origin v${version}
# Clean
clean:
cargo clean
# (cargo install cargo-modules)
# Show module tree
tree:
cargo modules generate tree --with-types --with-traits --with-fns
# (cargo install --locked cargo-outdated)
# Show outdated dependencies
outdated:
cargo outdated --root-deps-only
# (cargo install --locked cargo-udeps)
# Find unused dependencies
udeps:
cargo +nightly udeps
# cargo update
update:
cargo update
#############################################
# Exercise the program (via cargo):
# Run program
run *args='':
cargo run -- {{args}}
# Check configuration
check-config *args='':
cargo run -- check-config {{args}}
# Get all platforms
get-platforms *args:
cargo run -- get-platforms {{args}}
# Get platform information
get-platform platform='5d5b2ea653a65f9ec656d872':
cargo run -- get-platform {{platform}}
# Get platform positions
get-positions platform='54065b5560d0e168c88d4043':
cargo run -- get-positions {{platform}}
# Add platforms to be dispatched
add-dispatched *args='':
cargo run -- add-dispatched {{args}}
# Run dispatch
dispatch *args='':
cargo run -- dispatch {{args}}
# Run server and dispatch
serve *args:
cargo run -- serve {{args}}
# Run server but no dispatch
serve-no-dispatch *args:
cargo run -- serve --no-dispatch {{args}}
#############################################
# docker recipes:
# Dockerize the program
dockerize *args='':
#!/usr/bin/env bash
version=$(cat Cargo.toml | grep version | head -1 | cut -d\" -f2)
docker build -f docker/Dockerfile -t "mbari/odss2dash:$version" {{args}} .
# Save image
docker-save-image suffix='':
#!/usr/bin/env bash
version=$(cat Cargo.toml | grep version | head -1 | cut -d\" -f2)
suffix={{suffix}}
docker save "mbari/odss2dash:$version" | gzip > "image_mbari_o2d_$version$suffix.tgz"
# Load image
docker-load-image suffix='':
#!/usr/bin/env bash
version=$(cat Cargo.toml | grep version | head -1 | cut -d\" -f2)
suffix={{suffix}}
docker load --input "image_mbari_o2d_$version$suffix.tgz"
#############################################
# Exercise dockerized program:
# docker run
docker-run *args='':
#!/usr/bin/env bash
version=$(cat Cargo.toml | grep version | head -1 | cut -d\" -f2)
docker run --name=odss2dash -it --rm \
-e RUST_LOG=info \
-e RUST_BACKTRACE=full \
-v $(pwd):/public \
-p 3033:3033 \
"mbari/odss2dash:$version" {{args}}
# Push image to Docker Hub, including x.y.z, x.y, x, and 'latest' tags
docker-push-image:
#!/usr/bin/env bash
version=$(cat Cargo.toml | grep version | head -1 | cut -d\" -f2)
mayor_minor=$(echo $version | cut -d. -f1,2)
mayor=$(echo $version}| cut -d. -f1)
echo " version='${version}'"
echo "mayor_minor='${mayor_minor}'"
echo " mayor='${mayor}'"
docker push "{{image_name}}:$version"
just docker-tag-push-image $version "$mayor_minor"
just docker-tag-push-image $version "$mayor"
just docker-tag-push-image $version latest
# tag and push image
docker-tag-push-image version tag:
docker tag "{{image_name}}:{{version}}" "{{image_name}}:{{tag}}"
docker push "{{image_name}}:{{tag}}"
#############################################
# With local server running:
# Get platforms via REST API against TrackingDB
rest-trackdb-get-platforms:
curlie get http://localhost:3033/api/trackdb/platforms
# Get platform information via REST API against TrackingDB
rest-trackdb-get-platform platform='5d5b2ea653a65f9ec656d872':
curlie get http://localhost:3033/api/trackdb/platforms/{{platform}}
# Get platform positions via REST API against TrackingDB
rest-trackdb-get-positions platform='54065b5560d0e168c88d4043' lastNumberOfFixes='2':
curlie get http://localhost:3033/api/trackdb/platforms/{{platform}}/positions?lastNumberOfFixes={{lastNumberOfFixes}}
# Get dispatched platforms via REST API
rest-dispatched-get-platforms:
curlie get http://localhost:3033/api/runtime/platforms
# Get dispatched platform information via REST API
rest-dispatched-get-platform platform='5d5b2ea653a65f9ec656d872':
curlie get http://localhost:3033/api/runtime/platforms/{{platform}}
# Add dispatched platform via REST API
rest-dispatched-add-platforms platformIds='["001", "002", "003"]':
curlie post http://localhost:3033/api/runtime/platforms \
platformIds:='{{platformIds}}'
# Delete dispatched platform via REST API
rest-dispatched-delete-platform platform:
curlie delete http://localhost:3033/api/runtime/platforms/{{platform}}
# Delete dispatched platforms via REST API
rest-dispatched-delete-platforms:
just rest-dispatched-delete-platform 002
just rest-dispatched-delete-platform 001
just rest-dispatched-delete-platform 003