forked from flox/flox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
185 lines (136 loc) · 5.29 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
# ============================================================================ #
#
# Think of this as a `Makefile' except you run `just <TARGET>' instead
# of `make <TARGET>'.
#
# The difference between `just' and `make' is that `just' does not check
# timestamps to determine if files are stale; so in that sense you can imagine
# it as `make' except "all targets are `.PHONY' targets".
#
#
# ---------------------------------------------------------------------------- #
nix_options := "--extra-experimental-features nix-command \
--extra-experimental-features flakes"
PKGDB_BIN := "${PWD}/pkgdb/bin/pkgdb"
FLOX_BIN := "${PWD}/cli/target/debug/flox"
WATCHDOG_BIN := "${PWD}/cli/target/debug/flox-watchdog"
GENERATED_DATA := "${PWD}/test_data/generated"
INPUT_DATA := "${PWD}/test_data/input_data"
cargo_test_invocation := "PKGDB_BIN=${PKGDB_BIN} cargo nextest run --manifest-path ${PWD}/cli/Cargo.toml --workspace"
# ---------------------------------------------------------------------------- #
@_default:
just --list --unsorted
# ---------------------------------------------------------------------------- #
# Print the paths of all of the binaries
@bins:
echo "{{PKGDB_BIN}}"
echo "{{FLOX_BIN}}"
# ---------------------------------------------------------------------------- #
# Build the compilation database
build-cdb:
@make -C pkgdb -j 8 -s cdb
# Build only pkgdb
@build-pkgdb:
make -C pkgdb -j 8;
# Build pkgdb with debug symbols
@build-pkgdb-debug:
# Note that you need to clean pkgdb first
make -C pkgdb -j 8 -s DEBUG=1
# Clean the pkgdb build cache
@clean-pkgdb:
make -C pkgdb -j 8 -s clean
# Build only flox
@build-cli: build-pkgdb
pushd cli; cargo build -q --workspace
# Build just the data generator
@build-data-gen:
pushd cli; cargo build -q -p mk_data; popd
# Build the binaries
build: build-cli
# Generate test data
@gen-data +mk_data_args="": build-data-gen
mkdata="$PWD/cli/target/debug/mk_data"; pushd test_data; "$mkdata" {{mk_data_args}} config.toml; popd
# ---------------------------------------------------------------------------- #
# Run the pkgdb tests
@test-pkgdb: build-pkgdb
make -C pkgdb -j 8 tests;
make -C pkgdb check;
# Run the CLI integration test suite
@integ-tests +bats_args="": build
flox-cli-tests \
--pkgdb "{{PKGDB_BIN}}" \
--flox "{{FLOX_BIN}}" \
--watchdog "{{WATCHDOG_BIN}}" \
--input-data "{{INPUT_DATA}}" \
--generated-data "{{GENERATED_DATA}}" \
{{bats_args}}
# Run the CLI integration test suite using Nix-built binaries
@nix-integ-tests:
nix run \
--accept-flake-config \
--extra-experimental-features 'nix-command flakes' \
.#flox-cli-tests
# Run the CLI unit tests
@unit-tests regex="": build
{{cargo_test_invocation}} {{regex}}
# Run the CLI unit tests, including impure tests
@impure-tests regex="": build
{{cargo_test_invocation}} {{regex}} --features "extra-tests"
# Run the entire CLI test suite
test-cli: impure-tests integ-tests
# Run the test suite except for pkgdb
@test-rust: impure-tests integ-tests nix-integ-tests
# Run the entire test suite, including impure unit tests
test-all: test-pkgdb impure-tests integ-tests nix-integ-tests
# ---------------------------------------------------------------------------- #
# Enters the Rust development environment
@work:
# Note that this command is only really useful if you have
# `just` installed outside of the `flox` environment already
nix {{nix_options}} develop
# ---------------------------------------------------------------------------- #
# Bump all flake dependencies and commit with a descriptive message
@bump-all:
nix {{nix_options}} flake update --commit-lock-file \
--commit-lockfile-summary "chore: flake bump";
# Bump a specific flake input and commit with a descriptive message
@bump input:
nix {{nix_options}} flake lock --update-input {{input}} \
--commit-lock-file --commit-lockfile-summary \
"chore: bump '{{input}}' flake input";
# ---------------------------------------------------------------------------- #
# Output licenses of all dependency crates
@license:
pushd cli; \
cargo metadata --format-version 1 \
|jq -r '.packages[]|[.name,.license]|@csv';
# ---------------------------------------------------------------------------- #
# Run a `flox` command
@flox +args="": build
cli/target/debug/flox {{args}}
# Run a `flox` command using the catalog
@catalog-flox +args="": build
echo "just: DEPRECATED TARGET: Use 'flox' instead" >&2;
cli/target/debug/flox {{args}}
# Run a `pkgdb` command
@pkgdb +args="": build-pkgdb
pkgdb/bin/pkgdb {{args}}
# ---------------------------------------------------------------------------- #
# Clean ( remove ) built artifacts
@clean:
pushd cli; cargo clean;
make -C pkgdb clean;
# ---------------------------------------------------------------------------- #
@format-cli:
pushd cli; cargo fmt; popd
@format-pkgdb:
pushd pkgdb; make fmt; popd
@format-nix:
treefmt
# Format all the code
format: format-cli format-pkgdb format-nix
# ---------------------------------------------------------------------------- #
#
#
#
# ============================================================================ #