-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
justfile
216 lines (174 loc) · 5.48 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
set shell := ["bash", "-uc"]
export TAG := `cat Cargo.toml | grep '^version =' | cut -d " " -f3 | xargs`
export MSRV := `cat hiqlite/Cargo.toml | grep '^rust-version =' | cut -d " " -f3 | xargs`
export USER := `echo "$(id -u):$(id -g)"`
[private]
default:
@just -l
# Creates a new Root + Intermediate CA for development and testing TLS certificates
create-root-ca:
# Password for both root and intermediate dev CA is always: 123SuperMegaSafe
mkdir -p tls/ca
chmod 0766 tls/ca
# Root CA
docker run --rm -it -v ./tls/ca:/ca -u $USER \
ghcr.io/sebadob/nioca \
x509 \
--stage root \
--clean
# Intermediate CA
docker run --rm -it -v ./tls/ca:/ca -u $USER \
ghcr.io/sebadob/nioca \
x509 \
--stage intermediate
cp tls/ca/x509/intermediate/ca-chain.pem tls/ca-chain.pem
# Create a new End Entity TLS certificate for development and testing
# Intermediate CA DEV password: 123SuperMegaSafe
create-end-entity-tls:
# create the new certificate
docker run --rm -it -v ./tls/ca:/ca -u $USER \
ghcr.io/sebadob/nioca \
x509 \
--cn 'localhost' \
--alt-name-dns 'localhost' \
--alt-name-dns 'hiqlite.local' \
--alt-name-ip '127.0.0.1' \
--usages-ext server-auth \
--usages-ext client-auth \
--o 'Hiqlite DEV Certificate' \
--stage end-entity
# copy it in the correct place
cp tls/ca/x509/end_entity/$(cat tls/ca/x509/end_entity/serial)/cert-chain.pem tls/cert-chain.pem
cp tls/ca/x509/end_entity/$(cat tls/ca/x509/end_entity/serial)/key.pem tls/key.pem
# prints out the currently set version
version:
#!/usr/bin/env bash
echo "v$TAG"
# cleanup the data dir
cleanup:
rm -rf data/*
# clippy lint + check with minimal versions from nightly
check:
#!/usr/bin/env bash
set -euxo pipefail
clear
cargo update
cargo +nightly clippy -- -D warnings
cargo minimal-versions check -p hiqlite --all-features
# just update at the end again for following clippy and testing
cargo update
# checks all combinations of features with clippy
clippy:
#!/usr/bin/env bash
set -euxo pipefail
clear
cargo clippy
cargo clippy --no-default-features
cargo clippy --no-default-features --features sqlite
# auto-heal should only apply to sqlite
cargo clippy --no-default-features --features auto-heal
cargo clippy --no-default-features --features sqlite,auto-heal
# backup / s3 should only apply to sqlite
cargo clippy --no-default-features --features backup
cargo clippy --no-default-features --features sqlite,backup
cargo clippy --no-default-features --features sqlite,auto-heal,backup
cargo clippy --no-default-features --features cache
cargo clippy --no-default-features --features dlock
cargo clippy --no-default-features --features listen_notify
cargo clippy --no-default-features --features sqlite,cache
cargo clippy --no-default-features --features dashboard
cargo clippy --no-default-features --features shutdown-handle
clippy-examples:
#!/usr/bin/env bash
set -euxo pipefail
clear
cd examples
for example in */; do
cd $example
cargo clippy
cd ..
done
cd ..
# build and open the docs
docs:
cargo +nightly doc --all-features --no-deps --open
# runs the full set of tests
test:
#!/usr/bin/env bash
set -euxo pipefail
clear
# we need to run the tests with nightly to not get an error for docs auto cfg
cargo +nightly test --features cache,dlock,listen_notify
# builds the code
build ty="server":
#!/usr/bin/env bash
set -euxo pipefail
if [[ {{ ty }} == "server" ]]; then
cargo build
elif [[ {{ ty }} == "ui" ]]; then
rm -rf hiqlite/static
cd dashboard
rm -rf build
npm run build
git add ../hiqlite/static
fi
# builds a container image
build-image name="ghcr.io/sebadob/hiqlite":
#!/usr/bin/env bash
set -euxo pipefail
rm -rf hiqlite/static
cd dashboard
npm run build
cd ..
git add hiqlite/static
#cargo build --features server --release
#mkdir -p out
#cp target/release/hiqlite out/
docker build -t {{ name }}:{{ TAG }} .
docker push {{ name }}:{{ TAG }}
# builds the code in --release mode
build-release:
#!/usr/bin/env bash
set -euxo pipefail
cargo build --release
run ty="server":
#!/usr/bin/env bash
set -euxo pipefail
clear
if [[ {{ ty }} == "server" ]]; then
cargo run --features server -- serve
elif [[ {{ ty }} == "ui" ]]; then
cd dashboard
npm run dev -- --host=0.0.0.0
fi
# verifies the MSRV
msrv-verify:
#!/usr/bin/env bash
set -euxo pipefail
cd hiqlite
cargo msrv verify
# find's the new MSRV, if it needs a bump
msrv-find:
cargo msrv --min {{ MSRV }}
# verify thats everything is good
verify: check clippy clippy-examples test msrv-verify
# makes sure everything is fine
verfiy-is-clean: verify
#!/usr/bin/env bash
set -euxo pipefail
# make sure everything has been committed
git diff --exit-code
echo all good
# sets a new git tag and pushes it
release: verfiy-is-clean
#!/usr/bin/env bash
set -euxo pipefail
# make sure git is clean
git diff --quiet || exit 1
git tag "v$TAG"
git push origin "v$TAG"
# publishes the current lib version to cargo.io
publish: verfiy-is-clean
#!/usr/bin/env bash
set -euxo pipefail
cargo publish -p hiqlite