From 5d30333587f718fac6b5c70304eb8ee27c587778 Mon Sep 17 00:00:00 2001 From: Danyal Faheem Date: Tue, 20 May 2025 17:29:13 +0500 Subject: [PATCH] test: verify python package distribution build when running make test (#65) * test: python package distribution build when running make test Pushing to pypi would occasionally fail because of breaking distribution build. We verify the build in the github CI now so that we can mitigate those errors later on. --- Makefile | 11 ++++++++++- .../20250408_141332_danyal.faheem_twine_build_ci.md | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20250408_141332_danyal.faheem_twine_build_ci.md diff --git a/Makefile b/Makefile index 900866e..20fa3ad 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SRC_DIRS = ./tutorcairn BLACK_OPTS = --exclude templates ${SRC_DIRS} # Warning: These checks are not necessarily run on every PR. -test: test-lint test-types test-format # Run some static checks. +test: test-lint test-types test-format test-pythonpackage # Run some static checks. test-format: ## Run code formatting tests black --check --diff $(BLACK_OPTS) @@ -15,6 +15,12 @@ test-lint: ## Run code linting tests test-types: ## Run type checks. mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ${SRC_DIRS} +build-pythonpackage: ## Build the "tutor-cairn" python package for upload to pypi + python -m build --sdist + +test-pythonpackage: build-pythonpackage ## Test that package can be uploaded to pypi + twine check dist/tutor_cairn-$(shell make version).tar.gz + format: ## Format code automatically black $(BLACK_OPTS) @@ -27,6 +33,9 @@ changelog-entry: ## Create a new changelog entry. changelog: ## Collect changelog entries in the CHANGELOG.md file. scriv collect +version: ## Print the current tutor-cairn version + @python -c 'import io, os; about = {}; exec(io.open(os.path.join("tutorcairn", "__about__.py"), "rt", encoding="utf-8").read(), about); print(about["__version__"])' + ESCAPE =  help: ## Print this help @grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \ diff --git a/changelog.d/20250408_141332_danyal.faheem_twine_build_ci.md b/changelog.d/20250408_141332_danyal.faheem_twine_build_ci.md new file mode 100644 index 0000000..b63ccd6 --- /dev/null +++ b/changelog.d/20250408_141332_danyal.faheem_twine_build_ci.md @@ -0,0 +1 @@ +- [Improvement] Test python package distribution build when running make test. (by @Danyal-Faheem)