Skip to content

Commit 7eb5828

Browse files
authored
feat: add support for value objects. (#28)
1 parent 3a213cd commit 7eb5828

20 files changed

Lines changed: 2645 additions & 2330 deletions

.github/workflows/release.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,35 @@ jobs:
3030
with:
3131
python-version: '3.12'
3232

33-
- name: Install pipenv and dependencies
33+
- name: Install Poetry
3434
run: |
3535
python -m pip install --upgrade pip
36-
pip install pipenv
37-
pipenv install --dev
36+
pip install poetry
3837
39-
- name: Auto bump version
38+
- name: Install dependencies
39+
run: poetry install --with dev
40+
41+
- name: Bump version
4042
id: bump
4143
run: |
4244
python scripts/bump_version.py
4345
VERSION=$(grep '__version__' src/codius/version.py | cut -d'"' -f2)
4446
echo "version=$VERSION" >> $GITHUB_OUTPUT
4547
48+
- name: Sync version to pyproject.toml
49+
run: |
50+
python scripts/sync_version.py
51+
4652
- name: Commit and push version bump
4753
run: |
4854
git config user.name "GitHub Actions"
4955
git config user.email "actions@github.com"
50-
git add src/codius/version.py
56+
git add src/codius/version.py pyproject.toml
5157
git commit -m "chore(release): bump version to ${{ steps.bump.outputs.version }}"
5258
git push
5359
5460
- name: Build package
55-
run: pipenv run python -m build
61+
run: poetry build
5662

5763
- name: Publish to PyPI
5864
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/run-unittests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ jobs:
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030

31-
- name: Install pipenv
31+
- name: Install Poetry
3232
run: |
3333
python -m pip install --upgrade pip
34-
pip install pipenv
34+
pip install poetry
3535
3636
- name: Install dependencies
37-
run: pipenv install --dev --deploy
37+
run: poetry install --with dev
3838

3939
- name: Run unittests
4040
run: |
4141
mkdir -p reports
42-
PYTHONPATH=./src:./tests pipenv run pytest ./tests/unit --junitxml=reports/report.xml
42+
PYTHONPATH=./src:./tests poetry run pytest ./tests/unit --junitxml=reports/report.xml
4343
4444
- name: Upload JUnit report
4545
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ __pycache__/
1818
env/
1919
venv/
2020
ENV/
21-
env.bak/
22-
venv.bak/
2321

2422
# Logs
2523
*.log

Makefile

Lines changed: 100 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -30,99 +30,60 @@ help:
3030

3131
.PHONY: test
3232
test: ## run test suite
33-
PYTHONPATH=$(SRC):$(TESTS) pipenv run pytest $(TESTS)
34-
35-
##########################################################################
36-
# DOCS
37-
##########################################################################
38-
39-
.PHONY: sphinx-quickstart
40-
sphinx-quickstart: ## run the sphinx quickstart
41-
pipenv run docker run -it --rm -v $(PWD)/docs:/docs sphinxdoc/sphinx sphinx-quickstart
42-
43-
.PHONY: sphinx-html
44-
sphinx-html: ## build the sphinx html
45-
pipenv run make -C docs html
46-
47-
.PHONY: sphinx-rebuild
48-
sphinx-rebuild: ## re-build the sphinx docs
49-
cd $(DOCS) && \
50-
pipenv run make clean && pipenv run make html
51-
52-
.PHONY: sphinx-autobuild
53-
sphinx-autobuild: ## activate autobuild of docs
54-
cd $(DOCS) && \
55-
pipenv run sphinx-autobuild . _build/html --watch $(SRC)
56-
57-
################################################################################
58-
# WORKFLOWS
59-
################################################################################
33+
PYTHONPATH=$(SRC):$(TESTS) poetry run pytest $(TESTS)
6034

6135
.PHONY: test-all-versions
62-
test-all-versions: ## Run tests across all supported Python versions with pyenv + pipenv
36+
test-all-versions: ## Run tests across all supported Python versions with pyenv + poetry
6337
@for PY in 3.9 3.10 3.11 3.12; do \
6438
echo "\n>>> Running tests with Python $$PY"; \
6539
PYTHON_BIN=$$(pyenv prefix $$PY)/bin/python; \
6640
VENV_DIR=.venv-$$PY; \
6741
$$PYTHON_BIN -m venv $$VENV_DIR && \
68-
$$VENV_DIR/bin/pip install --upgrade pip && \
69-
$$VENV_DIR/bin/pip install pipenv && \
70-
cd $(PWD) && \
71-
$$VENV_DIR/bin/pipenv install --dev --deploy && \
72-
PYTHONPATH=./src:./tests $$VENV_DIR/bin/pipenv run pytest ./tests/unit || exit 1; \
73-
rm -rf $$VENV_DIR; \
42+
. $$VENV_DIR/bin/activate && \
43+
pip install --upgrade pip && \
44+
pip install poetry && \
45+
poetry install --with dev && \
46+
PYTHONPATH=./src:./tests poetry run pytest ./tests || exit 1; \
47+
deactivate && rm -rf $$VENV_DIR; \
7448
done
7549

7650
.PHONY: test-version
77-
test-version: ## Run tests with a specific Python version via pyenv + pipenv. Usage: make test-version PY=3.10
51+
test-version: ## Run tests with a specific Python version via pyenv + poetry. Usage: make test-version PY=3.10
7852
@if [ -z "$(PY)" ]; then \
7953
echo "❌ PY is required. Usage: make test-version PY=3.10"; exit 1; \
8054
fi
8155
PYTHON_BIN=$$(pyenv prefix $(PY))/bin/python; \
8256
VENV_DIR=.venv-$(PY); \
8357
$$PYTHON_BIN -m venv $$VENV_DIR && \
84-
$$VENV_DIR/bin/pip install --upgrade pip && \
85-
$$VENV_DIR/bin/pip install pipenv && \
86-
cd $(PWD) && \
87-
$$VENV_DIR/bin/pipenv install --dev --deploy && \
88-
PYTHONPATH=./src:./tests $$VENV_DIR/bin/pipenv run pytest ./tests/unit || exit 1; \
89-
rm -rf $$VENV_DIR
90-
91-
.PHONY: release-please-pr-dry-run
92-
release-please-pr-dry-run: ## Preview next release version and change log using release-please
93-
release-please release-pr \
94-
--config-file release-please-config.json \
95-
--manifest-file .release-please-manifest.json \
96-
--token=${GITHUB_TOKEN} \
97-
--repo-url=runemalm/codius-cli \
98-
--target-branch=master \
99-
--release-type=python \
100-
--debug \
101-
--dry-run
58+
. $$VENV_DIR/bin/activate && \
59+
pip install --upgrade pip && \
60+
pip install poetry && \
61+
poetry install --with dev && \
62+
PYTHONPATH=./src:./tests poetry run pytest ./tests || exit 1; \
63+
deactivate && rm -rf $$VENV_DIR
10264

10365
################################################################################
104-
# RELEASE (LOCALLY)
66+
# RELEASE
10567
################################################################################
10668

10769
.PHONY: build
10870
build: ## build the python package
109-
pipenv run python setup.py sdist bdist_wheel
71+
poetry build
11072

11173
.PHONY: clean
11274
clean: ## clean the build
113-
python setup.py clean
11475
rm -rf build dist
11576
find . -type f -name '*.py[co]' -delete
11677
find . -type d -name __pycache__ -exec rm -rf {} +
11778
find . -type d -name '*.egg-info' -exec rm -rf {} +
11879

11980
.PHONY: upload-test
120-
upload-test: ## upload package to testpypi repository
121-
TWINE_USERNAME=$(PYPI_USERNAME_TEST) TWINE_PASSWORD=$(PYPI_PASSWORD_TEST) pipenv run twine upload --repository testpypi --skip-existing --repository-url https://test.pypi.org/legacy/ dist/*
81+
upload-test: ## upload package to test.pypi.org
82+
poetry publish --repository testpypi
12283

12384
.PHONY: upload
124-
upload: ## upload package to pypi repository
125-
TWINE_USERNAME=$(PYPI_USERNAME) TWINE_PASSWORD=$(PYPI_PASSWORD) pipenv run twine upload --skip-existing dist/*
85+
upload: ## upload package to PyPI
86+
poetry publish
12687

12788
.PHONY: act-release
12889
act-release: ## Run release workflow locally with act
@@ -131,97 +92,114 @@ act-release: ## Run release workflow locally with act
13192
.PHONY: test-install-all-py
13293
test-install-all-py:
13394
@for PY in 3.9 3.10 3.11 3.12; do \
134-
echo "\n>>> Testing with Python $$PY"; \
135-
PYTHON_BIN=$$(pyenv prefix $$PY)/bin/python; \
136-
VENV_DIR=.venv-$$PY; \
137-
$$PYTHON_BIN -m venv $$VENV_DIR && \
138-
$$VENV_DIR/bin/pip install --upgrade pip && \
139-
$$VENV_DIR/bin/pip install --index-url https://test.pypi.org/simple/ \
140-
--extra-index-url https://pypi.org/simple \
141-
codius && \
142-
mkdir -p /tmp/test-codius && \
143-
$$VENV_DIR/bin/codius /tmp/test-codius --version || echo "❌ Failed to run codius with Python $$PY"; \
144-
rm -rf $$VENV_DIR /tmp/test-codius; \
95+
( \
96+
set -e; \
97+
echo "\n>>> Testing with Python $$PY"; \
98+
PYTHON_BIN=$$(pyenv prefix $$PY)/bin/python; \
99+
VENV_DIR=.venv-$$PY; \
100+
TRAP_CMD="rm -rf $$VENV_DIR /tmp/test-codius"; \
101+
trap "$$TRAP_CMD" EXIT; \
102+
$$PYTHON_BIN -m venv $$VENV_DIR; \
103+
$$VENV_DIR/bin/pip install --upgrade pip; \
104+
$$VENV_DIR/bin/pip install --index-url https://test.pypi.org/simple/ \
105+
--extra-index-url https://pypi.org/simple \
106+
codius; \
107+
mkdir -p /tmp/test-codius; \
108+
$$VENV_DIR/bin/codius /tmp/test-codius --version; \
109+
) || exit 1; \
145110
done
146111

112+
.PHONY: test-install-version
113+
test-install-version: ## Test installing package from TestPyPI with a specific Python version. Usage: make test-install-version PY...
114+
@if [ -z "$(PY)" ]; then \
115+
echo "❌ PY is required. Usage: make test-install-version PY=3.10"; exit 1; \
116+
fi
117+
PYTHON_BIN=$$(pyenv prefix $(PY))/bin/python; \
118+
VENV_DIR=.venv-$(PY); \
119+
$$PYTHON_BIN -m venv $$VENV_DIR && \
120+
$$VENV_DIR/bin/pip install --upgrade pip && \
121+
$$VENV_DIR/bin/pip install --index-url https://test.pypi.org/simple/ \
122+
--extra-index-url https://pypi.org/simple \
123+
codius && \
124+
mkdir -p /tmp/test-codius && \
125+
$$VENV_DIR/bin/codius /tmp/test-codius --version || echo "❌ Failed to run codius with Python $(PY)"; \
126+
rm -rf $$VENV_DIR /tmp/test-codius
127+
128+
.PHONY: bump-version
129+
bump-version: ## Bump version and update pyproject.toml
130+
python scripts/bump_version.py
131+
make sync-version
132+
133+
.PHONY: sync-version
134+
sync-version: ## Sync version.py to pyproject.toml
135+
python scripts/sync_version.py
136+
147137
################################################################################
148138
# PRE-COMMIT HOOKS
149139
################################################################################
150140

151141
.PHONY: black
152142
black: ## format code using black
153-
pipenv run black --line-length 88 $(SRC)
143+
poetry run black --line-length 88 $(SRC)
154144

155145
.PHONY: black-check
156146
black-check: ## check code don't violate black formatting rules
157-
pipenv run black --check --line-length 88 $(SRC)
147+
poetry run black --check --line-length 88 $(SRC)
158148

159149
.PHONY: flake
160150
flake: ## lint code with flake
161-
pipenv run flake8 --max-line-length=200 $(SRC)
151+
poetry run flake8 --max-line-length=200 $(SRC)
162152

163153
.PHONY: pre-commit-install
164154
pre-commit-install: ## install the pre-commit git hook
165-
pipenv run pre-commit install
155+
poetry run pre-commit install
166156

167157
.PHONY: pre-commit-run
168158
pre-commit-run: ## run the pre-commit hooks
169-
pipenv run pre-commit run --all-files
159+
poetry run pre-commit run --all-files
170160

171161
################################################################################
172-
# PIPENV
162+
# POETRY
173163
################################################################################
174164

175-
.PHONY: pipenv-rm
176-
pipenv-rm: ## remove the virtual environment
177-
pipenv --rm
165+
.PHONY: poetry-install-with-dev
166+
poetry-install-with-dev: ## Install all dependencies including dev group
167+
poetry install --with dev
178168

179-
.PHONY: pipenv-install
180-
pipenv-install: ## setup the virtual environment
181-
pipenv install --dev
169+
.PHONY: poetry-env-remove
170+
poetry-env-remove: ## Remove the Poetry virtual environment
171+
poetry env info --path >/dev/null 2>&1 && poetry env remove python || echo "No Poetry environment found."
182172

183-
.PHONY: pipenv-install-package
184-
pipenv-install-package: ## install a package (uses PACKAGE)
185-
pipenv install $(PACKAGE)
173+
.PHONY: poetry-shell
174+
poetry-shell: ## Activate the Poetry virtual environment
175+
poetry shell
186176

187-
.PHONY: pipenv-install-package-dev
188-
pipenv-install-package-dev: ## install a dev package (uses PACKAGE)
189-
pipenv install --dev $(PACKAGE)
177+
.PHONY: poetry-env-info-path
178+
poetry-env-info-path: ## Show the path to the Poetry virtual environment
179+
poetry env info --path
190180

191-
.PHONY: pipenv-graph
192-
pipenv-graph: ## Check installed packages
193-
pipenv graph
194-
195-
.PHONY: pipenv-generate-requirements
196-
pipenv-generate-requirements: ## Check a requirements.txt
197-
pipenv lock -r > requirements.txt
198-
199-
.PHONY: pipenv-shell
200-
pipenv-shell: ## Activate the virtual environment
201-
pipenv shell
202-
203-
.PHONY: pipenv-venv
204-
pipenv-venv: ## Show the path to the venv
205-
pipenv --venv
206-
207-
.PHONY: pipenv-lock-and-install
208-
pipenv-lock-and-install: ## Lock the pipfile and install (after updating Pipfile)
209-
pipenv lock && \
210-
pipenv install --dev
211-
212-
.PHONY: pipenv-pip-freeze
213-
pipenv-pip-freeze: ## Run pip freeze in the virtual environment
214-
pipenv run pip freeze
181+
.PHONY: poetry-add
182+
poetry-add: ## Install a runtime package (uses PACKAGE)
183+
@if [ -z "$(PACKAGE)" ]; then \
184+
echo "❌ PACKAGE is required. Usage: make poetry-add PACKAGE=your-package"; exit 1; \
185+
fi
186+
poetry add $(PACKAGE)
215187

216-
.PHONY: pipenv-sync-setup
217-
pipenv-sync-setup: ## Update install_requires in setup.py from Pipfile
218-
pipenv run python scripts/sync_setup.py --sync Pipfile setup.py
188+
.PHONY: poetry-add-dev
189+
poetry-add-dev: ## Install a dev package (uses PACKAGE)
190+
@if [ -z "$(PACKAGE)" ]; then \
191+
echo "❌ PACKAGE is required. Usage: make poetry-add-dev PACKAGE=your-package"; exit 1; \
192+
fi
193+
poetry add --group dev $(PACKAGE)
219194

220-
.PHONY: pipenv-sync-setup-dry-run
221-
pipenv-sync-setup-dry-run: ## Dry run: preview install_requires from Pipfile
222-
pipenv run python scripts/sync_setup.py --dry-run Pipfile setup.py
195+
.PHONY: poetry-show-tree
196+
poetry-show-tree: ## Show dependency tree
197+
poetry show --tree
223198

224-
.PHONY: pipenv-install-cli-editable
225-
pipenv-install-cli-editable: ## Install the package in editable mode (for CLI use)
226-
pipenv run pip install -e .
199+
.PHONY: poetry-export-requirements-txt
200+
poetry-export-requirements-txt: ## Export requirements.txt (for Docker or CI)
201+
poetry export --without-hashes --format=requirements.txt > requirements.txt
227202

203+
.PHONY: poetry-show-codius
204+
poetry-show-codius: ## Show installed details for the codius package
205+
poetry run pip show -f codius || echo "❌ codius is not installed yet. Run 'make poetry-install'"

0 commit comments

Comments
 (0)