-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJustfile
108 lines (77 loc) · 2.88 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
# This Justfile contains rules/targets/scripts/commands that are used when
# developing. Unlike a Makefile, running `just <cmd>` will always invoke
# that command. For more information, see https://github.com/casey/just
# This setting will allow passing arguments through to recipes
set positional-arguments
# Custom git log format
gitstyle := '%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'
# Helper function for quick menu
[private]
@default:
just --list
# ... Edit this Justfile
@edit-just:
$EDITOR ./Justfile
# PROJECT: Install development environment
@install:
pip install --require-virtualenv -e '.[dev,test]'
pip install --require-virtualenv --upgrade pip
# PROJECT: Install and update pre-commit hooks
@install-precommit:
pre-commit install
pre-commit autoupdate
# PROJECT: Re-compile requirements.txt from dev-dependencies in pyproject.toml
@lock-requirements:
pip-compile --strip-extras --output-file=requirements.txt pyproject.toml > /dev/null
# PROJECT: Remove caches, builds, reports and other generated files
@clean:
rm -rf \
.coverage \
.coverage.* \
.mypy_cache \
.pytest_cache \
.ruff_cache \
*.egg-info \
**/__pycache__/ \
build \
**/__pycache__/ \
**/*.test.md \
build \
demo \
dist \
:
# PROJECT: Build and check distribution package
@build:
just clean
python -m build
twine check dist/*
## PYTEST: Run tests with coverage report
@test:
pytest
# PYTEST: Updade snapshots (known results) for pytest
@update-snapshots:
pytest --snapshot-update
# DOCKER: Test Build Docker image for demo
@docker-test-buildx:
cd docker && docker buildx build --platform linux/arm64,linux/amd64 -t tomasad/czespressif-demo . && cd -
# DOCKER: Build and push Docker image for demo
@docker-push-buildx:
cd docker && docker buildx build --platform linux/arm64,linux/amd64 -t tomasad/czespressif-demo --push . && cd -
# DOCKER: Run Docker image for demo
@docker-run directory=".":
pushd {{directory}} && docker run --rm -v $(pwd):/app -u $(id -u):$(id -g) tomasad/czespressif-demo && popd
# GIT: Show commits only on current branch
@branch-commits base="master":
@if git rev-parse --verify "{{base}}" > /dev/null 2>&1; then \
git log --first-parent --no-merges --graph --pretty="{{gitstyle}}" {{base}}..HEAD; \
else \
echo 'E: Provide base (target) branch as argument to `just branch-commits <base-branch>`' >&2; \
exit 128; \
fi
# GIT: Try commit again, open failed commit message it in the editor for corrections
@recommit:
git commit --edit --file=$(git rev-parse --git-dir)/COMMIT_EDITMSG
# GIT: Run interactive "git rebase" command
@rebase base="master":
git fetch origin {{base}}
git rebase -i origin/{{base}}