-
Notifications
You must be signed in to change notification settings - Fork 4
/
Justfile
102 lines (73 loc) · 2.67 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
# 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
# Parse current version from pyproject.toml
current_version := `grep -Po 'version\s*=\s*"\K[^"]*' pyproject.toml | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'`
# 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 autoupdate pre-commit hooks
@install-pre-commit:
pre-commit install
git add .pre-commit-config.yaml
pre-commit autoupdate
git reset HEAD --
# PROJECT: Re-compile requirements.txt
@lock-requirements:
pip-compile --strip-extras --output-file=requirements.txt pyproject.toml > /dev/null
# PROJECT: Release version info, commits since last release)
@version:
cz bump --dry-run | grep -E 'change\(bump\)|tag to create|increment detected'; \
echo "\nCommits since last release:"; \
git log -n 30 --graph --pretty="{{gitstyle}}" v{{current_version}}..HEAD
# TESTS: Run local tests with pytest (config in pyproject.toml)
@test:
python -m pytest
# DOCKER: Build Docker image
docker-build:
docker build -t espressif/sample-project:latest .
# DOCKER: Run in Docker container
docker-run:
docker run espressif/sample-project
# Build and run Docker
docker:
just docker-build
just docker-run
# PROJECT: Remove caches, builds, reports and other generated files
@clean:
rm -rf \
dist \
build \
*.egg-info \
**/__pycache__/ \
.pytest_cache \
.mypy_cache \
.coverage* \
.ruff_cache \
:
# GIT: Revert the last commit - keeping changes staged
@uncommit:
git reset --soft HEAD~1
# GIT: Fix failed commit message
@recommit:
git commit --edit --file=$(git rev-parse --git-dir)/COMMIT_EDITMSG
# GIT: Show commits only on current branch
@branch-commits base="v1":
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