-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
151 lines (126 loc) · 4.18 KB
/
Taskfile.yml
File metadata and controls
151 lines (126 loc) · 4.18 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
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'
tasks:
dependencies:
desc: Updates the poetry.lock file and installs all dependencies
cmds:
- pip install --upgrade pip
- poetry lock
- poetry install --extras dev
silent: true
dependencies-with-pip:
desc: Installs all dependencies using pip only
cmds:
- pip install --upgrade pip
- pip install .[dev]
silent: true
tests:
desc: Runs the tests
cmds:
- pytest --doctest-modules
tests-with-cov:
desc: Runs the tests with coverage
cmds:
- pytest --doctest-modules --cov=pedantic --cov-branch --cov-report= --cov-report=term
silent: true
lint:
desc: Runs the linter (ruff)
silent: true
cmds:
- ruff check pedantic tests {{.CLI_ARGS}}
lint-fix:
desc: Runs the linter and fixes all fixable errors automatically
silent: true
cmds:
- ruff check pedantic --fix
validate:
desc: Runs all checks and updates the docu. It is recommended to do this before making a commit.
cmds:
- task: list-crlf
- task: check-changelog
- task: check-version
- task: tests
- task: lint
- task: generate-docs
docs:
desc: Creates the HTML documentation and opens is Chrome
cmds:
- task: generate-docs
- google-chrome ./docs/index.html
silent: true
generate-docs:
desc: Creates the HTML documentation
cmds:
- rm -rf ./docs
- pip install pdoc
- pdoc -o docs pedantic
silent: true
check-lock:
desc: Check if poetry.lock is in sync with pyproject.toml
cmds:
- poetry check
list-crlf:
desc: List all Python files with CRLF line endings
silent: true
cmds:
- |
files=$(find . -type d -name ".*" ! -name "." -prune -o -name "*.py" -type f -exec grep -Iq . {} \; -and -exec grep -l $'\r' {} \;)
if [ -n "$files" ]; then
echo "$files"
exit 1
fi
check-changelog:
desc: Fails if CHANGELOG.md was not modified compared to master
silent: true
cmds:
- |
set -e
echo "Checking that CHANGELOG.md was updated..."
# Ensure we have master available (works both locally and in CI)
if git show-ref --verify --quiet refs/remotes/origin/master; then
BASE=origin/master
elif git show-ref --verify --quiet refs/heads/master; then
BASE=master
else
echo "❌ Could not find master branch to diff against."
exit 1
fi
# Fetch latest master if we're in a repo with a remote
git fetch origin master >/dev/null 2>&1 || true
if git diff --name-only "$BASE"...HEAD | grep -qx "CHANGELOG.md"; then
echo "✅ CHANGELOG.md was updated."
else
echo "❌ CHANGELOG.md was NOT updated."
echo ""
echo "Please add an entry describing your change."
exit 1
fi
check-version:
desc: Fails if the version in pyproject.toml was not bumped compared to master
silent: true
cmds:
- |
set -e
echo "Checking that project version was updated..."
# Determine comparison base (works locally and in CI)
if git show-ref --verify --quiet refs/remotes/origin/master; then
BASE=origin/master
elif git show-ref --verify --quiet refs/heads/master; then
BASE=master
else
echo "❌ Could not find master branch to diff against."
exit 1
fi
# Try to fetch latest master (no-op if no remote available)
git fetch origin master >/dev/null 2>&1 || true
# Extract versions
CURRENT_VERSION=$(grep -E '^version\s*=' pyproject.toml | head -1 | sed -E 's/.*"(.*)".*/\1/')
BASE_VERSION=$(git show "$BASE:pyproject.toml" | grep -E '^version\s*=' | head -1 | sed -E 's/.*"(.*)".*/\1/')
echo "Base version: $BASE_VERSION"
echo "Current version: $CURRENT_VERSION"
if [ "$CURRENT_VERSION" = "$BASE_VERSION" ]; then
echo "❌ Version was not updated."
echo "Please bump the version in pyproject.toml."
exit 1
fi
echo "✅ Version was updated."