Speed up builds and add pypi step
This commit is contained in:
parent
d005129afe
commit
c66e15dd4f
18
.drone.yml
18
.drone.yml
@ -3,8 +3,22 @@ workspace:
|
|||||||
path: .
|
path: .
|
||||||
|
|
||||||
pipeline:
|
pipeline:
|
||||||
build:
|
test:
|
||||||
image: python:3
|
image: python:3
|
||||||
commands:
|
commands:
|
||||||
|
- python3 -m venv env
|
||||||
|
- ./env/bin/pip install tox
|
||||||
- make test
|
- make test
|
||||||
- make build
|
push_to_pypi:
|
||||||
|
image: python:3
|
||||||
|
commands:
|
||||||
|
- ./env/bin/pip install twine
|
||||||
|
- make upload-test
|
||||||
|
secrets:
|
||||||
|
- source: PYPI_USERNAME
|
||||||
|
target: TWINE_USERNAME
|
||||||
|
- source: PYPI_PASSWORD
|
||||||
|
target: TWINE_PASSWORD
|
||||||
|
when:
|
||||||
|
event: tag
|
||||||
|
branch: master
|
||||||
|
38
Makefile
38
Makefile
@ -1,48 +1,80 @@
|
|||||||
|
.PHONY: default
|
||||||
|
default: test
|
||||||
|
|
||||||
|
# Builds the python3 venv with all dev requirements
|
||||||
env:
|
env:
|
||||||
python3 -m venv env
|
python3 -m venv env
|
||||||
./env/bin/pip install -r requirements-dev.txt
|
./env/bin/pip install -r requirements-dev.txt
|
||||||
|
|
||||||
|
# Runs Minitor
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: env
|
run: env
|
||||||
./env/bin/python -m minitor.main
|
./env/bin/python -m minitor.main
|
||||||
|
|
||||||
|
# Generates a smaller env for running tox, which builds it's own env
|
||||||
|
.PHONY: test-env
|
||||||
|
test-env:
|
||||||
|
python3 -m venv env
|
||||||
|
./env/bin/pip install tox
|
||||||
|
|
||||||
|
# Runs tests with tox
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: env
|
test: env
|
||||||
./env/bin/tox
|
./env/bin/tox
|
||||||
|
|
||||||
|
# Generates a small build env for building and uploading dists
|
||||||
|
.PHONY: build-env
|
||||||
|
build-env:
|
||||||
|
python3 -m venv env
|
||||||
|
./env/bin/pip install twine wheel
|
||||||
|
|
||||||
|
# Builds wheel for package to upload
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: env
|
build: env
|
||||||
./env/bin/python setup.py sdist
|
./env/bin/python setup.py sdist
|
||||||
./env/bin/python setup.py bdist_wheel
|
./env/bin/python setup.py bdist_wheel
|
||||||
|
|
||||||
|
# Verify that the python version matches the git tag so we don't push bad shas
|
||||||
|
.PHONY: verify-tag-version
|
||||||
|
verify-tag-version:
|
||||||
|
test "v$(shell python setup.py -V)" = "$(shell git describe --tags --exact-match)"
|
||||||
|
|
||||||
|
# Uses twine to upload to pypi
|
||||||
.PHONY: upload
|
.PHONY: upload
|
||||||
upload: env
|
upload: verify-tag-version build
|
||||||
./env/bin/twine upload dist/*
|
./env/bin/twine upload dist/*
|
||||||
|
|
||||||
|
# Uses twine to upload to test pypi
|
||||||
.PHONY: upload-test
|
.PHONY: upload-test
|
||||||
upload-test: env
|
upload-test: verify-tag-version build
|
||||||
./env/bin/twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
./env/bin/twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
||||||
|
|
||||||
|
# Cleans all build, runtime, and test artifacts
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -fr ./build ./minitor.egg-info ./htmlcov ./.coverage ./.pytest_cache ./.tox
|
rm -fr ./build ./minitor.egg-info ./htmlcov ./.coverage ./.pytest_cache ./.tox
|
||||||
find . -name '*.pyc' -delete
|
find . -name '*.pyc' -delete
|
||||||
find . -name '__pycache__' -delete
|
find . -name '__pycache__' -delete
|
||||||
|
|
||||||
|
# Cleans dist and env
|
||||||
.PHONY: dist-clean
|
.PHONY: dist-clean
|
||||||
dist-clean: clean
|
dist-clean: clean
|
||||||
rm -fr ./dist ./env
|
rm -fr ./dist ./env
|
||||||
|
|
||||||
|
# Install pre-commit hooks
|
||||||
.PHONY: install-hooks
|
.PHONY: install-hooks
|
||||||
install-hooks:
|
install-hooks: env
|
||||||
./env/bin/tox -e pre-commit -- install -f --install-hooks
|
./env/bin/tox -e pre-commit -- install -f --install-hooks
|
||||||
|
|
||||||
|
# Generates test coverage
|
||||||
.coverage:
|
.coverage:
|
||||||
./env/bin/tox
|
./env/bin/tox
|
||||||
|
|
||||||
|
# Builds coverage html
|
||||||
htmlcov/index.html: .coverage
|
htmlcov/index.html: .coverage
|
||||||
./env/bin/coverage html
|
./env/bin/coverage html
|
||||||
|
|
||||||
|
# Opens coverage html in browser (on macOS)
|
||||||
.PHONY: open-coverage
|
.PHONY: open-coverage
|
||||||
open-coverage: htmlcov/index.html
|
open-coverage: htmlcov/index.html
|
||||||
open htmlcov/index.html
|
open htmlcov/index.html
|
||||||
|
Loading…
Reference in New Issue
Block a user