-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
115 lines (90 loc) · 2.94 KB
/
justfile
File metadata and controls
115 lines (90 loc) · 2.94 KB
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
set dotenv-load := true
set positional-arguments := true
# List available commands
default:
@"{{ just_executable() }}" --list
# Create a valid .env if none exists
_dotenv:
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -f .env ]]; then
echo "No '.env' file found; creating a default '.env' from 'dotenv-sample'"
cp dotenv-sample .env
fi
# Check if a .env exists
# Use this (rather than _dotenv or devenv) for recipes that require that a .env file exists.
# just will not pick up environment variables from a .env that it's just created,
# and there isn't an easy way to load those into the environment, so we just
# prompt the user to run just devenv to set up their local environment properly.
_checkenv:
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -f .env ]]; then
echo "No '.env' file found; run 'just devenv' to create one"
exit 1
fi
# Clean up temporary files
clean:
rm -rf .venv
# Install production requirements into and remove extraneous packages from venv
prodenv:
uv sync --no-dev
# && dependencies are run after the recipe has run. Needs just>=0.9.9. This is
# a killer feature over Makefiles.
#
# Install dev requirements into venv without removing extraneous packages
devenv: _dotenv
uv sync --inexact
# Upgrade a single package to the latest version as of the cutoff in pyproject.toml
upgrade-package package: && devenv
uv lock --upgrade-package {{ package }}
# Upgrade all packages to the latest versions as of the cutoff in pyproject.toml
upgrade-all: && devenv
uv lock --upgrade
# *args is variadic, 0 or more. This allows us to do `just test -k match`, for example.
# Run the tests
test *args:
uv run coverage run --module pytest "$@"
uv run coverage report || uv run coverage html
format *args:
uv run ruff format --diff --quiet "$@"
lint *args:
uv run ruff check "$@" .
lint-actions:
docker run --rm -v $(pwd):/repo:ro --workdir /repo rhysd/actionlint:1.7.8 -color
# Run the various dev checks but does not change any files
check:
#!/usr/bin/env bash
set -euo pipefail
failed=0
check() {
echo -e "\e[1m=> ${1}\e[0m"
rc=0
# Run it
eval $1 || rc=$?
# Increment the counter on failure
if [[ $rc != 0 ]]; then
failed=$((failed + 1))
# Add spacing to separate the error output from the next check
echo -e "\n"
fi
}
check "just format"
check "just lint"
check "just lint-actions"
test -d docker/ && check "just docker/lint"
if [[ $failed > 0 ]]; then
echo -en "\e[1;31m"
echo " $failed checks failed"
echo -e "\e[0m"
exit 1
fi
# Fix formatting, import sort ordering, and justfile
fix:
-uv run ruff check --fix .
-uv run ruff format .
-just --fmt --unstable
manage-github *ARGS="--dry-run": _checkenv
uv run python manage-github.py {{ ARGS }}
repoupdater *ARGS: _checkenv
uv run python repoupdater.py {{ ARGS }}