-
Notifications
You must be signed in to change notification settings - Fork 6
/
justfile
228 lines (181 loc) · 5.57 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
218
219
220
221
222
223
224
225
226
227
228
binary-crate := "."
set dotenv-load
export JUST_ROOT := justfile_directory()
# Build service for development
build:
@echo '==> Building project'
cargo build
run:
@echo '==> Running project (ctrl+c to exit)'
ANSI_LOGS=true cargo run
# Fast check project for errors
check:
@echo '==> Checking project for compile errors'
RUST_BACKTRACE=1 cargo check
test := ""
# Run project test suite
test:
@echo '==> Testing project (default)'
RUST_BACKTRACE=1 cargo test --lib --bins -- {{test}}
# Run project test suite
test-all:
@echo '==> Testing project (all features)'
RUST_BACKTRACE=1 cargo test --all-features --lib --bins -- {{test}}
test-integration:
@echo '==> Testing integration'
RUST_BACKTRACE=1 ANSI_LOGS=true cargo test --test integration -- {{test}}
# Clean build artifacts
clean:
@echo '==> Cleaning project target/*'
cargo clean
# Make sure we are running the right submodule versions
update-submodules:
git submodule update --init --recursive
# Lint the project for any quality issues
lint: clippy fmt
unit: update-submodules lint test test-all lint-tf
devloop: unit fmt-imports
#!/bin/bash -eux
trap 'jobs -lp | xargs -L 1 pkill -SIGINT -P' EXIT
pushd rs-relay
RELAY_REGISTRY_API_AUTH_TOKEN=$REGISTRY_AUTH_TOKEN just --unstable relay run-all-docker
while ! nc -z 127.0.0.1 9010; do sleep 1; done
popd
just run-storage-docker test-integration
just run &
while ! nc -z 127.0.0.1 3000; do sleep 1; done
just test-deployment
echo "✅ Success! ✅"
# Run project linter
clippy:
#!/bin/bash
set -euo pipefail
if command -v cargo-clippy >/dev/null; then
echo '==> Running clippy'
cargo clippy --workspace --all-features --all-targets -- -D warnings
else
echo '==> clippy not found in PATH, skipping'
fi
# Check unused depdenencies
udeps:
#!/bin/bash
set -euo pipefail
if command -v cargo-udeps >/dev/null; then
echo '==> Running udeps'
cargo +nightly udeps
else
echo '==> udeps not found in PATH, skipping'
fi
# Run code formatting check
fmt:
#!/bin/bash
set -euo pipefail
if command -v cargo-fmt >/dev/null; then
echo '==> Running rustfmt'
cargo fmt
else
echo '==> rustfmt not found in PATH, skipping'
fi
fmt-imports:
#!/bin/bash
set -euo pipefail
if command -v cargo-fmt >/dev/null; then
echo '==> Running rustfmt'
cargo +nightly fmt -- --config group_imports=StdExternalCrate,imports_granularity=One
else
echo '==> rustfmt not found in PATH, skipping'
fi
lint-tf: tf-validate tf-fmt tfsec tflint tfdocs
# Check Terraform formating
tf-fmt:
#!/bin/bash
set -euo pipefail
if command -v terraform >/dev/null; then
echo '==> Running terraform fmt'
terraform -chdir=terraform fmt -recursive
else
echo '==> Terraform not found in PATH, skipping'
fi
tf-validate:
#!/bin/bash
set -euo pipefail
if command -v terraform >/dev/null; then
echo '==> Running terraform fmt'
terraform -chdir=terraform validate
else
echo '==> Terraform not found in PATH, skipping'
fi
# Check Terraform for potential security issues
tfsec:
#!/bin/bash
set -euo pipefail
if command -v tfsec >/dev/null; then
echo '==> Running tfsec'
cd terraform
tfsec
else
echo '==> tfsec not found in PATH, skipping'
fi
# Run Terraform linter
tflint:
#!/bin/bash
set -euo pipefail
if command -v tflint >/dev/null; then
echo '==> Running tflint'
cd terraform; tflint
cd ecs; tflint
cd ../monitoring; tflint
cd ../private_zone; tflint
cd ../redis; tflint
else
echo '==> tflint not found in PATH, skipping'
fi
# Run terraform-docs
tfdocs:
#!/bin/bash
set -euo pipefail
if command -v terraform-docs >/dev/null; then
echo '==> Running terraform-docs'
terraform-docs terraform
else
echo '==> terraform-docs not found in PATH, skipping'
fi
test-deployment:
@echo '==> Running deployment tests'
RUST_BACKTRACE=1 cargo test --test deployment
test-deployment-nocapture:
@echo '==> Running deployment tests'
RUST_BACKTRACE=1 cargo test --test deployment -- --nocapture
deploy-terraform ENV:
@echo '==> Deploying terraform on env {{ENV}}'
terraform -chdir=terraform workspace select {{ENV}}
terraform -chdir=terraform apply --var-file=vars/{{ENV}}.tfvars
tarp ENV:
@echo '==> Checking test coverage'
ENVIRONMENT={{ENV}} cargo tarpaulin
# Build docker image
build-docker:
@echo '=> Build notify-server image'
docker-compose -f ./docker-compose.notify-server.yml -f ./docker-compose.storage.yml build notify-server
# Start notify-server & storage services on docker
run-docker:
@echo '==> Start services on docker'
@echo '==> Use run notify-server app on docker with "cargo-watch"'
@echo '==> for more details check https://crates.io/crates/cargo-watch'
docker-compose -f ./docker-compose.notify-server.yml -f ./docker-compose.storage.yml up -d
# Stop notify-server & storage services on docker
stop-docker:
@echo '==> Stop services on docker'
docker-compose -f ./docker-compose.notify-server.yml -f ./docker-compose.storage.yml down --remove-orphans
# Start storage services on docker
run-storage-docker:
@echo '==> Start storage services on docker'
docker-compose -f ./docker-compose.storage.yml up -d --remove-orphans
# Stop gilgamesh & storage services on docker
stop-storage-docker:
@echo '==> Stop storage services on docker'
docker-compose -f ./docker-compose.storage.yml down --remove-orphans
# List services running on docker
ps-docker:
@echo '==> List services on docker'
docker-compose -f ./docker-compose.notify-server.yml -f ./docker-compose.storage.yml ps