-
Notifications
You must be signed in to change notification settings - Fork 11
/
justfile
236 lines (198 loc) · 6.11 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
229
230
231
232
233
234
235
export RUST_BACKTRACE := "1"
set dotenv-load := true
set positional-arguments := true
# default recipe to display help information
default:
@just --list
# Clean up development files and images
clean:
cargo clean
command -v docker \
&& docker buildx --builder bluebuild prune -f \
&& docker system prune -f \
|| true
command -v podman \
&& podman system prune -f \
|| true
command -v earthly \
&& earthly prune --reset \
|| true
# Install bluebuild using cargo with release optimization
install:
cargo install --path . --locked
# Install bluebuild with all features with release optimizations
install-all-features:
cargo install --all-features --path . --locked
# Install bluebuild using cargo with debug targets
install-debug:
cargo install --debug --path . --locked
# Install bluebuild with all features and debug target
install-debug-all-features:
cargo install --debug --all-features --path . --locked
# Run unit tests
test:
cargo test --workspace -- --show-output
# Run unit tests for all features
test-all-features:
cargo test --workspace --all-features -- --show-output
# Run clippy
lint:
cargo clippy
# Run clippy for all features
lint-all-features:
cargo clippy --all-features
# Watch the files and run cargo check on changes
watch:
cargo watch -c
# Install bluebuild whenever there is a change in the project files
watch-install:
cargo watch -c -x 'install --debug --locked --path .'
# Install bluebuild whenever there is a change in the project files
watch-install-all-features:
cargo watch -c -x 'install --debug --locked --all-features --path .'
# Run tests anytime a file is changed
watch-test:
cargo watch -c -x 'test --workspace -- --show-output'
# Run all feature tests anytime a file is changed
watch-test-all-features:
cargo watch -c -x 'test --workspace --all-features -- --show-output'
# Run lint anytime a file is changed
watch-lint:
cargo watch -c -x 'clippy'
# Run all feature lint anytime a file is changed
watch-lint-all-features:
cargo watch -c -x 'clippy --all-features'
# Expand the macros of a module for debugging
expand *args:
cargo expand $@ > ./expand.rs
$EDITOR ./expand.rs
# Installs cargo tools that help with development
tools:
rustup toolchain install stable
rustup override set stable
rustup component add --toolchain stable rust-analyzer clippy rustfmt
cargo install --locked cargo-watch cargo-expand bacon
# Run cargo release and push the tag separately
release *args:
#!/usr/bin/env bash
set -euxo pipefail
earthly --ci +run-checks
# --workspace: updating all crates in the workspace
# --no-tag: do not push tag for each new version
# --no-confirm: don't look for user input, just run the command
# --execute: not a dry run
cargo release $1 -v \
--workspace \
--no-tag \
--no-confirm \
--execute
VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "blue-build") .version')
echo "Pushing tag: v${VERSION}"
git tag "v${VERSION}"
git push origin "v${VERSION}"
gh release create --generate-notes --latest "v${VERSION}"
should_push := if env('GITHUB_ACTIONS', '') != '' {
if env('COSIGN_PRIVATE_KEY', '') != '' {
'--push'
} else {
''
}
} else {
''
}
cargo_bin := if env('CARGO_HOME', '') != '' {
x"${CARGO_HOME:-}/bin"
} else {
x"$HOME/.cargo/bin"
}
# Run all integration tests
integration-tests: test-docker-build test-arm64-build test-podman-build test-buildah-build test-generate-iso-image test-generate-iso-recipe
# Run docker driver integration test
test-docker-build: install-debug-all-features
cd integration-tests/test-repo \
&& bluebuild build \
--retry-push \
-B docker \
-I docker \
-S sigstore \
{{ should_push }} \
-vv \
recipes/recipe.yml recipes/recipe-gts.yml
test-rechunk-build: install-debug-all-features
cd integration-tests/test-repo \
&& sudo -E {{ cargo_bin }}/bluebuild build \
{{ should_push }} \
-vv \
--rechunk \
recipes/recipe-rechunk.yml
test-fresh-rechunk-build: install-debug-all-features
cd integration-tests/test-repo \
&& sudo -E {{ cargo_bin }}/bluebuild build \
{{ should_push }} \
-vv \
--rechunk \
--rechunk-clear-plan \
recipes/recipe-rechunk.yml
# Run arm integration test
test-arm64-build: install-debug-all-features
cd integration-tests/test-repo \
&& bluebuild build \
--retry-push \
--platform linux/arm64 \
{{ should_push }} \
-vv \
recipes/recipe-arm64.yml
# Run docker driver external login integration test
test-docker-build-external-login: install-debug-all-features
cd integration-tests/test-repo \
&& bluebuild build \
--retry-push \
-S sigstore \
{{ should_push }} \
-vv \
recipes/recipe.yml recipes/recipe-gts.yml
# Run docker driver oauth login integration test
test-docker-build-oauth-login: install-debug-all-features
cd integration-tests/test-repo \
&& bluebuild build \
--registry us-east1-docker.pkg.dev \
--registry-namespace bluebuild-oidc/bluebuild \
--retry-push \
{{ should_push }} \
-vv \
recipes/recipe.yml recipes/recipe-gts.yml
# Run podman driver integration test
test-podman-build: install-debug-all-features
cd integration-tests/test-repo \
&& bluebuild build \
--retry-push \
-B podman \
-I podman \
-S sigstore \
{{ should_push }} \
-vv \
recipes/recipe.yml recipes/recipe-gts.yml
# Run buildah driver integration test
test-buildah-build: install-debug-all-features
cd integration-tests/test-repo \
&& bluebuild build \
--retry-push \
-B buildah \
-I podman \
-S sigstore \
{{ should_push }} \
-vv \
recipes/recipe.yml recipes/recipe-gts.yml
# Run ISO generator for images
test-generate-iso-image: install-debug-all-features
#!/usr/bin/env bash
set -eu
ISO_OUT=$(mktemp -d)
bluebuild generate-iso -vv --output-dir "$ISO_OUT" image ghcr.io/blue-build/cli/test:40
# Run ISO generator for images
test-generate-iso-recipe: install-debug-all-features
#!/usr/bin/env bash
set -eu
ISO_OUT=$(mktemp -d)
cd integration-tests/test-repo
bluebuild generate-iso -vv --output-dir "$ISO_OUT" recipe recipes/recipe.yml