-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
121 lines (101 loc) · 2.92 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
set shell := ["bash", "-uc"]
export RTX_DATA_DIR := "/tmp/rtx"
export PATH := env_var_or_default("CARGO_TARGET_DIR", justfile_directory() / "target") / "debug:" + env_var("PATH")
export RTX_MISSING_RUNTIME_BEHAVIOR := "autoinstall"
export RUST_TEST_THREADS := "1"
# defaults to `just test`
default: test
alias b := build
alias e := test-e2e
alias t := test
alias l := lint
alias lf := lint-fix
# just `cargo build`
build *args:
cargo build {{ args }}
# run all test types
test *args: (test-unit args) test-e2e lint
# update all test snapshot files
test-update-snapshots:
cargo insta test --accept
# run the rust "unit" tests
test-unit *args:
cargo test {{ args }}
# runs the E2E tests in ./e2e
# specify a test name to run a single test
test-e2e TEST=("all"): build
#!/usr/bin/env bash
set -euo pipefail
if [ "{{ TEST }}" = all ]; then
./e2e/run_all_tests
else
FILES="$(fd {{ TEST }} e2e/)"
./e2e/run_test "$FILES"
fi
# run unit tests w/ coverage
test-coverage:
#!/usr/bin/env bash
set -euxo pipefail
source <(cargo llvm-cov show-env --export-prefix)
cargo llvm-cov clean --workspace
if [[ -n "${RTX_GITHUB_BOT_TOKEN:-}" ]]; then
export GITHUB_API_TOKEN="$RTX_GITHUB_BOT_TOKEN"
fi
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$PWD/target}"
export PATH="${CARGO_TARGET_DIR}/debug:$PATH"
cargo build --all-features
./e2e/run_all_tests
if [[ "${TEST_TRANCHE:-}" == 0 ]]; then
cargo test
rtx trust
rtx implode
elif [[ "${TEST_TRANCHE:-}" == 1 ]]; then
rtx trust
RTX_SELF_UPDATE_VERSION=1.0.0 rtx self-update <<EOF
y
EOF
fi
cargo llvm-cov report --lcov --output-path lcov.info
# delete built files
clean:
cargo clean
rm -f lcov.info
rm -rf e2e/.{asdf,config,local,rtx}/
rm -rf target
rm -rf *.profraw
rm -rf coverage
# clippy, cargo fmt --check, and just --fmt
lint:
cargo clippy -- -Dwarnings
cargo fmt --all -- --check
shellcheck scripts/*.sh
shfmt -d scripts/*.sh
just --unstable --fmt --check
# runs linters but makes fixes when possible
lint-fix:
cargo clippy --fix --allow-staged --allow-dirty -- -Dwarnings
cargo fmt --all
shellcheck scripts/*.sh
shfmt -w scripts/*.sh
just --unstable --fmt
# regenerate README.md
render-help: build
NO_COLOR=1 rtx render-help
#npx markdown-magic
md-magic
# regenerate shell completion files
render-completions: build
NO_COLOR=1 rtx completion bash > completions/rtx.bash
NO_COLOR=1 rtx completion zsh > completions/_rtx
NO_COLOR=1 rtx completion fish > completions/rtx.fish
# regenerate manpages
render-mangen:
NO_COLOR=1 cargo xtask mangen
# called by lefthook precommit hook
pre-commit: render-help render-completions render-mangen
git add README.md
git add completions
git add man
# create/publish a new version of rtx
release *args:
cargo release {{ args }}