-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
113 lines (90 loc) · 3.09 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
set positional-arguments
set shell := ["bash", "-cue"]
root_dir := `git rev-parse --show-toplevel`
# General Variables:
# You can chose either "podman" or "docker".
container_mgr := "podman"
# Default recipe to list all recipes.
default:
just --list
# Enter a Nix development shell.
nix-develop *args:
cd "{{root_dir}}" && \
cmd=("$@") && \
{ [ -n "${cmd:-}" ] || cmd=("zsh"); } && \
nix develop ./tools/nix#default --accept-flake-config --command "${cmd[@]}"
nix-develop-ci *args:
#!/usr/bin/env bash
set -eu
cd "{{root_dir}}"
cachix watch-exec "$CACHIX_CACHE_NAME" -- \
nix develop ./tools/nix#ci --accept-flake-config --command "$@"
# Enter nix development shell for benchmarking.
nix-develop-bench *args:
cd "{{root_dir}}" && \
cmd=("$@") && \
{ [ -n "${cmd:-}" ] || cmd=("zsh"); } && \
nix develop ./tools/nix#bench --command "${cmd[@]}"
## Standard stuff =============================================================
# Format the code.
format *args:
cd "{{root_dir}}" && \
"{{root_dir}}/tools/format-rust.sh" {{args}}
# Lint all code.
lint *args:
cd "{{root_dir}}" && \
"{{root_dir}}/tools/lint-rust.sh" {{args}}
# Build the executable.
build *args:
cd "{{root_dir}}" && cargo build "${@:1}"
# Run the tests.
test:
cd "{{root_dir}}" && cargo test "${@:1}"
## Development functionality ==================================================
# Watch source and continuously build the executable.
watch:
cd "{{root_dir}}" && cargo watch -x 'build'
# Run the executable.
run:
cd "{{root_dir}}" && cargo run "${@:1}"
# Create a new release by version bumping.
# Usage:
# ```shell
# just release <sem-version>
# ```
# by updating the version file and triggering the release workflow.
release version:
cd "{{root_dir}}" && \
CONTAINER_MGR="{{container_mgr}}" \
"{{root_dir}}/tools/release.sh" "{{version}}"
## ============================================================================
## CI stuff ===================================================================
# Build the nix package into the folder `package` (first argument).
nix-package *args:
cd "{{root_dir}}" && \
"./tools/build-package.sh" "$@"
# Build the Docker image with Nix (distroless by default!).
nix-image *args:
cd "{{root_dir}}" && \
"./tools/build-image.sh" "$@"
# Upload the dev shell to the Nix cache.
nix-cache-upload-shell:
#!/usr/bin/env bash
set -eu
cd "{{root_dir}}"
profile=./dev-profile
mkdir -p "$profile"
# Cache development shell.
nix develop --profile "$profile/dev" ./tools/nix#ci --command true
cachix push "$CACHIX_CACHE_NAME" "$profile/dev"
rm -rf "$profile"
# Cache flake inputs.
nix flake archive ./tools/nix --json \
| jq -r '.path,(.inputs|to_entries[].value.path)' \
| cachix push "$CACHIX_CACHE_NAME"
# Upload all images for CI (local machine)
upload-ci-images:
cd "{{root_dir}}" && \
CONTAINER_MGR="{{container_mgr}}" \
tools/ci/upload-ci-images.sh
## ============================================================================