forked from a5chin/python-uv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
133 lines (123 loc) · 2.7 KB
/
dev.sh
File metadata and controls
133 lines (123 loc) · 2.7 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
#!/usr/bin/env bash
set -e
# Help function
show_help() {
echo "Usage: $0 [command]"
echo ""
echo "Commands:"
echo " format Run code formatting (Ruff)"
echo " lint Run linters and type checking (Ruff, MyPy)"
echo " test Run tests with coverage (Pytest)"
echo " docs Manage documentation (dev, build, deploy)"
echo " bump Bump version and update changelog"
echo " check Run full pre-commit pipeline (Format, Lint, Tests, pre-commit)"
echo ""
}
# 1. Format Function
run_format() {
echo "running formatter..."
set -x
ruff check src tests --fix
ruff format src tests
set +x
echo "format complete."
}
# 2. Lint Function
run_lint() {
echo "running linter..."
set -x
mypy src # type check
ruff check src # linter
ruff format src --check # formatter check
set +x
echo "lint complete."
}
# 3. Test Function
run_test() {
echo "running tests..."
set -x
coverage run --source=src -m pytest "$@"
coverage report --show-missing
coverage html --title "python-uv-coverage"
set +x
echo "tests complete."
}
# 4. Docs Function
run_docs() {
local cmd=$1
shift
run_uvx() {
uvx --with mkdocs-material \
--with mkdocs-git-revision-date-localized-plugin \
--with mkdocs-glightbox \
--with mkdocs-obsidian-bridge \
--with pymdown-extensions \
"$@"
}
case "$cmd" in
dev)
run_uvx mkdocs serve "$@"
;;
deploy)
run_uvx mkdocs gh-deploy --force "$@"
;;
build)
run_uvx mkdocs build "$@"
;;
*)
echo "usage: $0 docs {dev|deploy|build}"
exit 1
;;
esac
}
# 5. Bump Function
run_bump() {
echo "bumping version..."
set -x
# update CHANGELOG.md use GITHUB_REPO ENV as github token
git-cliff -o -v --github-repo "atticuszeller/python-uv"
# bump version and commit with tags
bump-my-version bump patch
# push remote
git push origin main --tags
set +x
echo "bump complete."
}
# 6. Pre-commit/Check Function
run_check() {
echo "running pre-commit pipeline..."
run_format
run_lint
run_test
set -x
pre-commit run --all-files
set +x
echo "all checks passed."
}
# Main Dispatcher
case "$1" in
format)
run_format
;;
lint)
run_lint
;;
test)
shift
run_test "$@"
;;
docs)
shift
run_docs "$@"
;;
bump)
run_bump
;;
check)
run_check
;;
*)
show_help
exit 1
;;
esac