-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
233 lines (184 loc) · 5.57 KB
/
Copy pathjustfile
File metadata and controls
233 lines (184 loc) · 5.57 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
set dotenv-load := true
# By default, run checks and tests, then format and lint
default:
if [ ! -d .venv ]; then just install; fi
@just format
@just check
@just test
@just lint
#
# Installing, updating and upgrading dependencies
#
venv:
if [ ! -d .venv ]; then uv venv; fi
clean-venv:
rm -rf .venv
# Install all dependencies
install:
@just venv
if [[ "$(uname -s)" == Linux ]]; then uv sync --dev --extra dbus; else uv sync --dev; fi
uv pip install -e .
# Update all dependencies
update:
@just install
# Update all dependencies and rebuild the environment
upgrade:
if [ -d venv ]; then just update && just check && just _upgrade; else just update; fi
_upgrade:
@just clean-venv
@just venv
@just install
# Generate locked requirements files based on dependencies in pyproject.toml
compile:
uv pip compile -o requirements.txt pyproject.toml
cp requirements.txt requirements_dev.txt
python3 -c 'import tomllib; print("\n".join(tomllib.load(open("pyproject.toml", "rb"))["dependency-groups"]["dev"]))' >> requirements_dev.txt
clean-compile:
rm -f requirements.txt
rm -f requirements_dev.txt
#
# Running the CLI
#
# Run a command or script
run *argv:
uv run {{ argv }}
# Run plusdeck client cli
client *argv:
uv run -- python -m plusdeck {{ argv }}
# Run plusdeck.dbus.service cli
service *argv:
uv run -- python -m plusdeck.dbus.service --user {{ argv }}
# Run plusdeck.dbus.client cli
dbus-client *argv:
uv run -- python -m plusdeck.dbus.client --user {{ argv }}
#
# Development tooling - linting, formatting, etc
#
# Format with black and isort
format:
uv run black './plusdeck' ./tests ./scripts
uv run isort --settings-file . './plusdeck' ./tests ./scripts
# Lint with flake8
lint:
uv run flake8 './plusdeck' ./tests ./scripts
uv run validate-pyproject ./pyproject.toml
shellcheck ./scripts/*.sh
# Check type annotations with pyright
check:
uv run npx pyright@latest
# Run tests with pytest
test *argv:
uv run pytest {{ argv }} ./tests --ignore-glob='./tests/integration/**'
@just clean-test
# Update snapshots
snap:
uv run pytest --snapshot-update ./tests --ignore-glob='./tests/integration/**'
@just clean-test
# Run integration tests
integration *argv:
./scripts/integration.sh {{ argv }}
clean-test:
rm -f pytest_runner-*.egg
rm -rf tests/__pycache__
# Install systemd service files and dbus config for development purposes
install-service:
sudo install -p -D -m 0644 systemd/plusdeck.service /usr/lib/systemd/system/plusdeck.service
sudo install -p -D -m 0644 dbus/org.jfhbrook.plusdeck.conf /usr/share/dbus-1/system.d/org.jfhbrook.plusdeck.conf
# Pull the plusdeck service's logs with journalctl
service-logs:
journalctl -xeu plusdeck.service
# Display the raw XML introspection of the live dbus service
print-iface:
dbus-send --system --dest=org.jfhbrook.plusdeck "/" --print-reply org.freedesktop.DBus.Introspectable.Introspect
#
# Shell and console
#
shell:
uv run bash
jupyterlab:
uv run jupyter lab
#
# Documentation
#
# Live generate docs and host on a development webserver
docs:
uv run mkdocs serve
# Build the documentation
build-docs:
uv run mkdocs build
# Render markdown documentation based on the live service from dbus
generate-dbus-iface-docs *ARGV:
@bash ./scripts/generate-dbus-iface-docs.sh {{ ARGV }}
#
# Package publishing
#
# Build the package
build:
uv build
# Clean the build
clean-build:
rm -rf dist
# Generate plusdeck.spec
generate-spec:
./scripts/generate-spec.sh "$(./scripts/version.py)" "$(./scripts/release-version.py)"
# Update the package version in ./copr/python-plusdeck.yml
copr-update-version:
VERSION="$(./scripts/version.py)" yq -i '.spec.packageversion = strenv(VERSION)' ./copr/python-plusdeck.yml
# Commit generated files
commit-generated-files:
git add requirements.txt
git add requirements_dev.txt
git add plusdeck.spec
git add ./copr
git commit -m 'Update generated files' || echo 'No changes to files'
# Fail if there are uncommitted files
check-dirty:
./scripts/is-dirty.sh
# Fail if not on the main branch
check-main-branch:
./scripts/is-main-branch.sh
# Tag the release with tito
tag:
./scripts/tag.sh
# Push main and tags
push:
git push origin main --follow-tags
# Publish package to PyPI
publish-pypi: build
uv publish -t "$(op item get 'PyPI' --fields 'API Token' --reveal)"
# Create a GitHub release
gh-release:
bash ./scripts/gh-release.sh "$(python3 ./scripts/version.py)-$(python3 ./scripts/release-version.py)"
# Apply a COPR package configuration
apply-copr package:
coprctl apply -f ./copr/{{ package }}.yml
# Build a COPR package
build-copr package:
copr build-package jfhbrook/joshiverse --name '{{ package }}'
# Publish the release on PyPI, GitHub and Copr
publish:
# Generate files and commit
@just compile
@just generate-spec
@just copr-update-version
@just commit-generated-files
# Ensure git is in a good state
@just check-main-branch
@just check-dirty
# Tag and push
@just tag
@just push
# Build package and cut github release
if [[ "$(./scripts/release-version.py)" == '1' ]]; then just clean-build; fi
@just gh-release
if [[ "$(./scripts/release-version.py)" == '1' ]]; then just publish-pypi; fi
# Update packages on COPR
if [[ "$(./scripts/release-version.py)" == '1' ]]; then just apply-copr python-plusdeck; fi
@just apply-copr plusdeck
if [[ "$(./scripts/release-version.py)" == '1' ]]; then just build-copr python-plusdeck; fi
@just build-copr plusdeck
# Clean up loose files
clean: clean-venv clean-compile clean-test clean-build
rm -rf plusdeck.egg-info
rm -f plusdeck/*.pyc
rm -rf plusdeck/__pycache__