-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathjustfile
More file actions
73 lines (57 loc) · 2.07 KB
/
justfile
File metadata and controls
73 lines (57 loc) · 2.07 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
# VARIABLE DEFINITIONS
venv := ".venv"
bin := venv + "/bin"
python_version := "python3.14"
run := "poetry run"
target_dirs := "src tests scripts"
image := "docker.io/elementsinteractive/lgtm-ai"
# SENTINELS
venv-exists := path_exists(venv)
# RECIPES
# Shows list of recipes.
help:
just --list --unsorted
# Generate the virtual environment.
venv with-extras="false":
@if ! {{ venv-exists }}; \
then \
POETRY_VIRTUALENVS_IN_PROJECT=1 poetry env use {{ python_version }}; \
if [ "{{ with-extras }}" = "true" ]; then \
POETRY_VIRTUALENVS_IN_PROJECT=1 poetry install --all-extras; \
else \
POETRY_VIRTUALENVS_IN_PROJECT=1 poetry install; \
fi \
fi
# Cleans all artifacts generated while running this project, including the virtualenv.
clean:
@rm -f .coverage*
@rm -rf {{ venv }}
alias t := test
# Runs the tests with the specified arguments (any path or pytest argument).
test *test-args='': venv
{{ run }} pytest {{ test-args }} --no-cov
# Runs all tests including coverage report.
test-all *test-args='': venv
{{ run }} pytest -v --junitxml=pytest.xml --cov-report=xml:coverage.xml {{ test-args }}
# Format all code in the project.
format *files=target_dirs: venv
{{ run }} ruff check {{ files }} --fix
{{ run }} ruff format {{ files }}
# Lint all code in the project.
lint report="false": venv
{{ run }} ruff format --check {{ target_dirs }}
{{ run }} ruff check {{ target_dirs }} {{ if report == "true" { "--output-format gitlab > tests/gl-code-quality-report.json" } else { "" } }}
{{ run }} mypy {{ target_dirs }}
# Runs pre-commit with the given arguments (defaults to install).
pre-commit *precommit-args="install": venv
{{ run }} pre-commit {{ precommit-args }}
# Lints commit messages according to conventional commit rules.
lint-commit: venv
{{ run }} cz check --rev-range main..HEAD
# Runs docker build
build:
docker build -t lgtm-ai .
# Pushes the docker image to the registry
push version: build
docker image tag lgtm-ai {{ image }}:{{ version }}
docker image push {{ image }}:{{ version }}