From 29701d764ff75cb45ae92b81d96d58371870bad5 Mon Sep 17 00:00:00 2001 From: Neil Horner Date: Fri, 13 May 2022 14:31:56 +0100 Subject: [PATCH] add some ci components --- .gitlab-ci.yml | 99 +++++++++++++++++++++++++++++++-------- CHANGELOG.md | 9 ++++ Makefile | 124 +++++++++++++++++++++---------------------------- MakefileOld | 72 ++++++++++++++++++++++++++++ 4 files changed, 212 insertions(+), 92 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 MakefileOld diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24f4312..b5e975c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,25 +1,84 @@ -image: ubuntu:xenial +include: + - project: "epi2melabs/ci-templates" + file: "push-github.yaml" + - project: "epi2melabs/ci-templates" + file: "push-conda.yaml" + +image: ${UBUNTUIMAGE}:20.04 + +.prep-image: &prep-image | + export DEBIAN_FRONTEND=noninteractive + apt update -qq + apt install -y --no-install-recommends make wget python3-all-dev python3-venv + stages: - test - - pages + - build + - prerelease - release + - postrelease + +# Insist that the version in __init__.py matches the git tag +.check-versions: &check-versions | + PYVER="v"$(grep "__version__ = " ${CI_PROJECT_NAME}/__init__.py | awk '{gsub("\"","",$3); print $3}') + TAGVER=${CI_COMMIT_TAG} + if [[ "${PYVER}" != "${TAGVER}" ]]; then + echo "Mismatching TAG and PACKAGE versions:" + echo " - TAG:'$TAGVER'" + echo " - PACKAGE:'$TAGVER'" + exit 1 + else + echo "TAG and PACKAGE versions agree: '${PYVER}'" + fi + +# Insist a CHANGELOG entry has been made for tags +.check-changelog: &check-changelog | + TAGVER=${CI_COMMIT_TAG} + MATCHES=$(grep -c "## \[${TAGVER}\]" CHANGELOG.md || exit 0) + if [[ "${MATCHES}" != "1" ]]; then + echo "Expected one match to '${CI_COMMIT_TAG}' in CHANGELOG, found ${MATCHES}" + exit 1 + else + echo "Found CHANGELOG.md entry for tag" + fi + +test: + stage: test + script: + - *prep-image #? + - make test + - make docs + - make sdist + artifacts: + paths: + - dist/*.tar.gz + +deploy-checks: + stage: prerelease + script: + - *check-versions + - *check-changelog + rules: + - if: '$CI_COMMIT_TAG =~ /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$/' + +deploy:pypi: + stage: release + script: + - *prep-image + - make pypi_build/bin/activate + - source pypi_build/bin/activate + - twine upload --non-interactive dist/*.tar.gz + rules: + - if: '$CI_COMMIT_TAG =~ /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$/' + +conda: + extends: + - .deploy-conda + before_script: + - *prep-image + - export CONDA_PKG=${CI_PROJECT_NAME} + - export CONDA_PKG_VERSION=${CI_COMMIT_TAG/v/} + - cd conda -before_script: - - apt-get update - - apt-get remove python - - apt-get install -y python3 python3-pip make python3-numpy python3-matplotlib hmmer - - update-alternatives --install /usr/bin/python python /usr/bin/python3 10 - - alias python=python3; pip3 install --upgrade pip - - hash -r pip3 - - alias python=python3; pip3 install sphinx sphinx-argparse sphinx_rtd_theme pytest pandas - - alias python=python3; pip3 install -e ./ - - -do_testing: - stage: test - script: - - alias python=python3; make test - except: - - tags - +# Don't need a mac conda package since the project is pure python diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0425e78 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v2.7.0] +### Added +- PCS111 cDNA sequencing kit added diff --git a/Makefile b/Makefile index c051c0c..9a07748 100644 --- a/Makefile +++ b/Makefile @@ -1,72 +1,52 @@ -MODULE=pychopper - -.PHONY: clean clean-test clean-pyc clean-build docs com help - -.DEFAULT_GOAL := help - -define PRINT_HELP_PYSCRIPT -import re, sys - -for line in sys.stdin: - match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) - if match: - target, help = match.groups() - print("%-20s %s" % (target, help)) -endef -export PRINT_HELP_PYSCRIPT - -help: - @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) - -clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts - - -clean-build: ## remove build artifacts - rm -fr build/ - rm -fr dist/ - rm -fr .eggs/ - find . -name '*.egg-info' -exec rm -fr {} + - find . -name '*.egg' -exec rm -f {} + - -clean-pyc: ## remove Python file artifacts - find . -name '*.pyc' -exec rm -f {} + - find . -name '*.pyo' -exec rm -f {} + - find . -name '*~' -exec rm -f {} + - find . -name '__pycache__' -exec rm -fr {} + - -clean-test: ## remove test and coverage artifacts - rm -f .coverage - rm -fr htmlcov/ - -lint: ## check style with flake8 - @(flake8 --max-line-length=120 $(MODULE) | grep -v "E501 line too long") || true - @(flake8 --max-line-length=120 scripts/*.py | grep -v "E501 line too long") || true - -test: ## run tests quickly with the default Python - py.test - -coverage: ## check code coverage quickly with the default Python - coverage run --source $(MODULE) --omit="*/tests/*,*__init__.py" `which py.test` - coverage report -m --omit="*/tests/*,*__init__.py" - coverage html - -docs: ## generate Sphinx HTML documentation, including API docs - @cd docs; make clean html - -servedocs: docs ## compile the docs watching for changes - watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . - -release: clean ## package and upload a release - python setup.py sdist upload - python setup.py bdist_wheel upload - -dist: clean ## builds source and wheel package - python setup.py sdist - python setup.py bdist_wheel - ls -l dist - -install: clean ## install the package to the active Python's site-packages - python setup.py install - -com: ## commit all changes to git - git commit -a +.PHONY: develop docs + +PYTHON ?= python3 + +IN_VENV=. ./venv/bin/activate + +venv/bin/activate: + test -d venv || $(PYTHON) -m venv venv + ${IN_VENV} && pip install pip --upgrade + ${IN_VENV} && pip install -r requirements.txt + +develop: venv/bin/activate + ${IN_VENV} && python setup.py develop + +test: venv/bin/activate + ${IN_VENV} && pip install flake8 flake8-rst-docstrings flake8-docstrings flake8-import-order flake8-forbid-visual-indent + ${IN_VENV} && flake8 aplanat \ + --import-order-style google --application-import-names aplanat \ + --statistics + # demo should run without error + ${IN_VENV} && python setup.py install + ${IN_VENV} && aplanat demo + +IN_BUILD=. ./pypi_build/bin/activate +pypi_build/bin/activate: + test -d pypi_build || $(PYTHON) -m venv pypi_build --prompt "(pypi) " + ${IN_BUILD} && pip install pip --upgrade + ${IN_BUILD} && pip install --upgrade pip setuptools twine wheel readme_renderer[md] keyrings.alt + +.PHONY: sdist +sdist: pypi_build/bin/activate + ${IN_BUILD} && python setup.py sdist + +.PHONY: clean +clean: + rm -rf __pycache__ dist build venv aplanat.egg-info tmp docs/_build + +# Documentation +SPHINXOPTS = +SPHINXBUILD = sphinx-build +BUILDDIR = _build +PAPER = +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +DOCSRC = docs +docs: venv/bin/activate + ${IN_VENV} && pip install sphinx sphinx_rtd_theme sphinx-argparse + ${IN_VENV} && cd $(DOCSRC) && $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(DOCSRC)/$(BUILDDIR)/html." + touch $(DOCSRC)/$(BUILDDIR)/html/.nojekyll diff --git a/MakefileOld b/MakefileOld new file mode 100644 index 0000000..c051c0c --- /dev/null +++ b/MakefileOld @@ -0,0 +1,72 @@ +MODULE=pychopper + +.PHONY: clean clean-test clean-pyc clean-build docs com help + +.DEFAULT_GOAL := help + +define PRINT_HELP_PYSCRIPT +import re, sys + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print("%-20s %s" % (target, help)) +endef +export PRINT_HELP_PYSCRIPT + +help: + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts + + +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -f {} + + +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +clean-test: ## remove test and coverage artifacts + rm -f .coverage + rm -fr htmlcov/ + +lint: ## check style with flake8 + @(flake8 --max-line-length=120 $(MODULE) | grep -v "E501 line too long") || true + @(flake8 --max-line-length=120 scripts/*.py | grep -v "E501 line too long") || true + +test: ## run tests quickly with the default Python + py.test + +coverage: ## check code coverage quickly with the default Python + coverage run --source $(MODULE) --omit="*/tests/*,*__init__.py" `which py.test` + coverage report -m --omit="*/tests/*,*__init__.py" + coverage html + +docs: ## generate Sphinx HTML documentation, including API docs + @cd docs; make clean html + +servedocs: docs ## compile the docs watching for changes + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . + +release: clean ## package and upload a release + python setup.py sdist upload + python setup.py bdist_wheel upload + +dist: clean ## builds source and wheel package + python setup.py sdist + python setup.py bdist_wheel + ls -l dist + +install: clean ## install the package to the active Python's site-packages + python setup.py install + +com: ## commit all changes to git + git commit -a