-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78a6628
commit ae84546
Showing
4 changed files
with
397 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
|
||
# use this Makefile as base in your project by running | ||
# git remote add make https://github.com/spraakbanken/python-pdm-make-conf | ||
# git fetch make | ||
# git merge --allow-unrelated-histories make/main | ||
# | ||
# To later update this makefile: | ||
# git fetch make | ||
# git merge make/main | ||
# | ||
.default: help | ||
|
||
.PHONY: help | ||
help: | ||
@echo "usage:" | ||
@echo "dev | install-dev" | ||
@echo " setup development environment" | ||
@echo "install" | ||
@echo " setup production environment" | ||
@echo "" | ||
@echo "info" | ||
@echo " print info about the system and project" | ||
@echo "" | ||
@echo "test" | ||
@echo " run all tests" | ||
@echo "" | ||
@echo "test-w-coverage [cov=] [cov_report=]" | ||
@echo " run all tests with coverage collection. (Default: cov_report='term-missing', cov='--cov=${PROJECT_SRC}')" | ||
@echo "" | ||
@echo "lint" | ||
@echo " lint the code" | ||
@echo "" | ||
@echo "type-check" | ||
@echo " check types" | ||
@echo "" | ||
@echo "fmt" | ||
@echo " format the code" | ||
@echo "" | ||
@echo "check-fmt" | ||
@echo " check that the code is formatted" | ||
@echo "" | ||
@echo "bumpversion [part=]" | ||
@echo " bumps the given part of the version of the project. (Default: part='patch')" | ||
@echo "" | ||
@echo "publish [branch=]" | ||
@echo " pushes the given branch including tags to origin, for CI to publish based on tags. (Default: branch='main')" | ||
@echo " Typically used after `make bumpversion`" | ||
@echo "" | ||
@echo "prepare-release" | ||
@echo " run tasks to prepare a release" | ||
@echo "" | ||
|
||
PLATFORM := `uname -o` | ||
REPO := "sparv-word-prediction-plugin" | ||
PROJECT_SRC := "word-prediction--kb-bert/src" | ||
|
||
ifeq (${VIRTUAL_ENV},) | ||
VENV_NAME = .venv | ||
INVENV = pdm run | ||
else | ||
VENV_NAME = ${VIRTUAL_ENV} | ||
INVENV = | ||
endif | ||
|
||
default_cov := "--cov=word-prediction--kb-bert/src/" | ||
cov_report := "term-missing" | ||
cov := ${default_cov} | ||
|
||
all_tests := word-prediction--kb-bert/tests | ||
tests := word-prediction--kb-bert/tests | ||
|
||
info: | ||
@echo "Platform: ${PLATFORM}" | ||
@echo "INVENV: '${INVENV}'" | ||
|
||
dev: install-dev | ||
|
||
# setup development environment | ||
install-dev: | ||
pdm install --dev | ||
|
||
# setup production environment | ||
install: | ||
pdm sync --prod | ||
|
||
.PHONY: test | ||
test: | ||
${INVENV} pytest -vv ${tests} | ||
|
||
.PHONY: test-w-coverage | ||
# run all tests with coverage collection | ||
test-w-coverage: | ||
${INVENV} pytest -vv ${cov} --cov-report=${cov_report} ${all_tests} | ||
|
||
.PHONY: doc-tests | ||
doc-tests: | ||
${INVENV} pytest ${cov} --cov-report=${cov_report} --doctest-modules ${PROJECT_SRC} | ||
|
||
.PHONY: type-check | ||
# check types | ||
type-check: | ||
${INVENV} mypy ${PROJECT_SRC} ${tests} | ||
|
||
.PHONY: lint | ||
# lint the code | ||
lint: | ||
${INVENV} ruff ${PROJECT_SRC} ${tests} | ||
|
||
# run formatter(s) | ||
fmt: | ||
${INVENV} ruff format ${PROJECT_SRC} ${tests} | ||
|
||
.PHONY: check-fmt | ||
# check formatting | ||
check-fmt: | ||
${INVENV} ruff format --check ${PROJECT_SRC} ${tests} | ||
|
||
build: | ||
pdm build | ||
|
||
branch := "main" | ||
publish: | ||
git push -u origin ${branch} --tags | ||
|
||
|
||
.PHONY: prepare-release | ||
prepare-release: tests/requirements-testing.lock | ||
|
||
# we use lock extension so that dependabot doesn't pick up changes in this file | ||
tests/requirements-testing.lock: pyproject.toml | ||
pdm export --dev --format requirements --output $@ |
Oops, something went wrong.