Skip to content

Commit f9d62d7

Browse files
CI: added a check that the poetry package version was updated
1 parent ff81141 commit f9d62d7

9 files changed

Lines changed: 119 additions & 1041 deletions

File tree

.github/workflows/main.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
- '*'
77

88
jobs:
9-
changelog-check:
10-
# Do not run this on master itself
9+
feature-branch-checks:
10+
# these checks do not run this on master itself
1111
if: github.ref != 'refs/heads/master'
1212
runs-on: ubuntu-latest
1313

@@ -26,8 +26,12 @@ jobs:
2626
run: |
2727
task check-changelog
2828
29+
- name: Verify that the package version was updated. This is needed because master is automatically deployed to pypi.org
30+
run: |
31+
task check-version
32+
2933
test:
30-
needs: changelog-check # ensures this runs first
34+
needs: feature-branch-checks
3135
runs-on: ubuntu-latest
3236
strategy:
3337
matrix:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- removed `create_pdoc.sh`
1212
- moved `examples` out of the package
1313
- CI: added a check that `CHANGELOG.md` is modified on feature branches
14+
- CI: added a check that the poetry package version was updated
1415

1516
## Pedantic 2.4.0
1617
- migrate from unittest to pytest

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ There are no hard dependencies. But if you want to use some advanced features yo
177177

178178
## Contributing
179179
This project is based on [poetry](https://python-poetry.org/) and [taskfile](https://taskfile.dev).
180+
**Tip:** Run `task validate` before making commits.
180181

181182
## Risks and side effects
182183
The usage of decorators may affect the performance of your application.

Taskfile.yml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,48 @@ tasks:
1010
- poetry lock
1111
- poetry install --extras dev
1212
silent: true
13+
1314
dependencies-with-pip:
1415
desc: Installs all dependencies using pip only
1516
cmds:
1617
- pip install --upgrade pip
1718
- pip install .[dev]
1819
silent: true
20+
1921
tests:
2022
desc: Runs the tests
2123
cmds:
2224
- pytest --doctest-modules
25+
2326
tests-with-cov:
2427
desc: Runs the tests with coverage
2528
cmds:
2629
- pytest --doctest-modules --cov=pedantic --cov-branch --cov-report= --cov-report=term
2730
silent: true
31+
32+
validate:
33+
desc: Runs all checks and updates the docu. It is recommended to do this before making a commit.
34+
cmds:
35+
- task: check-changelog
36+
- task: check-version
37+
- task: tests
38+
- task: generate-docs
39+
2840
docs:
41+
desc: Creates the HTML documentation and opens is Chrome
42+
cmds:
43+
- task: generate-docs
44+
- google-chrome ./docs/index.html
45+
silent: true
46+
47+
generate-docs:
2948
desc: Creates the HTML documentation
3049
cmds:
3150
- rm -rf ./docs
3251
- pip install pdoc
3352
- pdoc -o docs pedantic
34-
- google-chrome ./docs/index.html
3553
silent: true
54+
3655
check-changelog:
3756
desc: Fails if CHANGELOG.md was not modified compared to master
3857
silent: true
@@ -63,3 +82,40 @@ tasks:
6382
echo "Please add an entry describing your change."
6483
exit 1
6584
fi
85+
86+
check-version:
87+
desc: Fails if the version in pyproject.toml was not bumped compared to master
88+
silent: true
89+
cmds:
90+
- |
91+
set -e
92+
93+
echo "Checking that project version was updated..."
94+
95+
# Determine comparison base (works locally and in CI)
96+
if git show-ref --verify --quiet refs/remotes/origin/master; then
97+
BASE=origin/master
98+
elif git show-ref --verify --quiet refs/heads/master; then
99+
BASE=master
100+
else
101+
echo "❌ Could not find master branch to diff against."
102+
exit 1
103+
fi
104+
105+
# Try to fetch latest master (no-op if no remote available)
106+
git fetch origin master >/dev/null 2>&1 || true
107+
108+
# Extract versions
109+
CURRENT_VERSION=$(grep -E '^version\s*=' pyproject.toml | head -1 | sed -E 's/.*"(.*)".*/\1/')
110+
BASE_VERSION=$(git show "$BASE:pyproject.toml" | grep -E '^version\s*=' | head -1 | sed -E 's/.*"(.*)".*/\1/')
111+
112+
echo "Base version: $BASE_VERSION"
113+
echo "Current version: $CURRENT_VERSION"
114+
115+
if [ "$CURRENT_VERSION" = "$BASE_VERSION" ]; then
116+
echo "❌ Version was not updated."
117+
echo "Please bump the version in pyproject.toml."
118+
exit 1
119+
fi
120+
121+
echo "✅ Version was updated."

docs/pedantic.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ <h2>Submodules</h2>
2727
<li><a href="pedantic/constants.html">constants</a></li>
2828
<li><a href="pedantic/decorators.html">decorators</a></li>
2929
<li><a href="pedantic/env_var_logic.html">env_var_logic</a></li>
30-
<li><a href="pedantic/examples.html">examples</a></li>
3130
<li><a href="pedantic/exceptions.html">exceptions</a></li>
3231
<li><a href="pedantic/get_context.html">get_context</a></li>
3332
<li><a href="pedantic/mixins.html">mixins</a></li>

0 commit comments

Comments
 (0)