Skip to content

Commit

Permalink
Updates docs and tests. (#83)
Browse files Browse the repository at this point in the history
* Updates docs and tests.
  • Loading branch information
hiwakaba authored Oct 17, 2024
1 parent f18b7bc commit 0560833
Show file tree
Hide file tree
Showing 14 changed files with 448 additions and 1,436 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ name: Python package

on:
push:
branches: [ main ]
branches: [ master ]
pull_request:
branches: [ main ]
branches: [ master ]
release:
types: [published]

Expand Down
81 changes: 31 additions & 50 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,10 @@ BROWSER := python3 -c "$$BROWSER_PYSCRIPT"
help:
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

# Initialize development environment
# Initialization fails if dependency problems happens or security vulnerabilities are detected.
#
# Note:
# Make sure python3-devel or python3-dev is installed. Because oslo-message(or dependent libs) requires Python.h
init:
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade pipenv
pipenv install --dev --skip-lock
python3 -m pip install pipenv
pipenv install --dev
pipenv graph
pipenv check --use-installed

# Lint code and docs
# lint fails if there are syntax errors or undefined names.
#
# Note:
# lint commands should be emit in virtualenv activated environment.
lint:
pipenv run flake8 --version
pipenv run flake8 k2hr3_osnl tests
pipenv run mypy k2hr3_osnl tests
pipenv run pylint k2hr3_osnl tests -r n
pipenv run python3 setup.py checkdocs

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

Expand All @@ -94,78 +75,78 @@ clean-test: ## remove test and coverage artifacts
rm -fr htmlcov/
rm -fr .pytest_cache

test-only: ## run tests quickly with the default Python
pipenv run python3 -m unittest
lint: ## check style with flake8
flake8 --version
flake8 src/k2hr3_osnl
mypy src/k2hr3_osnl
pylint src/k2hr3_osnl
python3 setup.py checkdocs

test: ## run tests quickly with the default Python
python3 -m unittest discover src

build: ## run build
$ python3 -m pip install --upgrade build
$ python3 -m build

# Check version strings consistency
# Make sure the following version strings are same.
# 1. HISTORY.rst
# 2. python-k2hr3-osnl.spec
# 3. __init__.py
version:
@rm -f VERSION RPMSPEC_VERSION
@perl -ne 'print if /^[0-9]+.[0-9]+.[0-9]+ \([0-9]{4}-[0-9]{2}-[0-9]{2}\)$$/' HISTORY.rst \
| head -n 1 | perl -lne 'print $$1 if /^([0-9]+.[0-9]+.[0-9]+) \(.*\)/' > VERSION
@perl -ne 'print $$2 if /^Version:(\s+)([0-9]+.[0-9]+.[0-9]+)$$/' python-k2hr3-osnl.spec > RPMSPEC_VERSION

SOURCE_VERSION = $(shell pipenv run python3 -c 'import k2hr3_osnl; print(k2hr3_osnl.version())')
SOURCE_VERSION = $(shell cd src; python3 -c 'import k2hr3_osnl; print(k2hr3_osnl.version())')
HISTORY_VERSION = $(shell cat VERSION)
RPMSPEC_VERSION = $(shell cat RPMSPEC_VERSION)

# Check version strings consistency
# Make sure the following version strings are same.
# 1. HISTORY.rst
# 2. python-k2hr3-osnl.spec
# 3. __init__.py
test: version ## builds source and wheel package
test-version: version ## builds source and wheel package
@echo 'source ' ${SOURCE_VERSION}
@echo 'history ' ${HISTORY_VERSION}
@echo 'rpmspec ' ${RPMSPEC_VERSION}
@if test "${SOURCE_VERSION}" = "${HISTORY_VERSION}" -a "${HISTORY_VERSION}" = "${RPMSPEC_VERSION}" ; then \
pipenv run python3 -m unittest ; \
python3 -m unittest discover src; \
else \
exit 1; \
fi

test-all: lint test
test-all: lint test-version

coverage: ## check code coverage quickly with the default Python
pipenv run coverage run --source k2hr3_osnl -m unittest
pipenv run coverage report -m
pipenv run coverage xml
pipenv run coverage html
coverage run --source src/k2hr3_osnl -m unittest
coverage report -m
coverage xml
coverage html
# $(BROWSER) htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/k2hr3_osnl.rst
rm -f docs/modules.rst
pipenv run sphinx-apidoc -o docs/ k2hr3_osnl
sphinx-apidoc -o docs/ src/k2hr3_osnl
$(MAKE) -C docs clean
$(MAKE) -C docs html
# $(BROWSER) docs/_build/html/index.html

servedocs: docs ## compile the docs watching for changes
pipenv run watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .

release: dist ## package and upload a release
pipenv run twine check dist/*
pipenv run twine upload dist/*
twine check dist/*
twine upload dist/*

test-release:
pipenv run twine check dist/*
pipenv run twine upload --repository-url https://test.pypi.org/legacy/ dist/*
twine check dist/*
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

dist: clean version ## builds source and wheel package
@echo 'source ' ${SOURCE_VERSION}
@echo 'history ' ${HISTORY_VERSION}
@if test "${SOURCE_VERSION}" = "${HISTORY_VERSION}" -a "${HISTORY_VERSION}" = "${RPMSPEC_VERSION}" ; then \
pipenv run python3 setup.py sdist ; \
pipenv run python3 setup.py bdist_wheel ; \
python3 -m build ; \
ls -l dist ; \
fi

install: clean ## install the package to the active Python's site-packages
pipenv run python3 setup.py install
python3 -m pip install .

#
# Local variables:
Expand Down
33 changes: 20 additions & 13 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
build = ">=0.10.0"
"collective.checkdocs" = ">=0.2"
coverage = ">=7.2.5"
flake8-docstrings = ">=1.7.0"
mypy = ">=1.2.0"
"oslo.messaging" = ">=14.2.0"
pep8-naming = ">=0.13.3"
pylint = ">=2.17.4"
sphinx = ">=7.0.0"
twine = ">=4.0.2"
typed-ast = ">=1.5.4"
watchdog = ">=3.0.0"
xmlrunner = ">=1.7.7"
coverage = "*"
flake8 = "*"
flake8-docstrings = "*"
pep8-naming = "*"
pycodestyle = "*"
mccabe = "*"
sphinx-autoapi = "*"
sphinx-intl = "*"
sphinx-rtd-theme = "*"
sphinx = "*"
watchdog = "*"
wheel = "*"
twine = "*"
pylint = "*"
typed-ast = "*"
astroid = "*"
mypy = "*"
"collective.checkdocs" = "*"
tomli = "*"
dill = "*"

[packages]
build = ">=0.10.0"
Expand Down
Loading

0 comments on commit 0560833

Please sign in to comment.