This commit is contained in:
parent
8b9ff334a5
commit
30801c5927
18
.drone.star
18
.drone.star
@ -43,24 +43,20 @@ def tests():
|
|||||||
"name": "tests",
|
"name": "tests",
|
||||||
"workspace": get_workspace(),
|
"workspace": get_workspace(),
|
||||||
"steps": [
|
"steps": [
|
||||||
tox_step("python:"+version)
|
test_step("python:"+version)
|
||||||
for version in PYTHON_VERSIONS
|
for version in PYTHON_VERSIONS
|
||||||
],
|
],
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
# Builds a single python test step
|
# Builds a single python test step
|
||||||
def tox_step(docker_tag, python_cmd="python", tox_env="py3"):
|
def test_step(docker_tag, python_cmd="python"):
|
||||||
return {
|
return {
|
||||||
"name": "test {}".format(docker_tag.replace(":", "")),
|
"name": "test {}".format(docker_tag.replace(":", "")),
|
||||||
"image": docker_tag,
|
"image": docker_tag,
|
||||||
"environment": {
|
|
||||||
"TOXENV": tox_env,
|
|
||||||
},
|
|
||||||
"commands": [
|
"commands": [
|
||||||
"{} -V".format(python_cmd),
|
"{} -V".format(python_cmd),
|
||||||
"pip install tox",
|
"make test"
|
||||||
"tox",
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,10 +119,10 @@ def push_to_pypi():
|
|||||||
"name": "push to test pypi",
|
"name": "push to test pypi",
|
||||||
"image": "python:3",
|
"image": "python:3",
|
||||||
"environment": {
|
"environment": {
|
||||||
"TWINE_USERNAME": {
|
"HATCH_INDEX_USER": {
|
||||||
"from_secret": "PYPI_USERNAME",
|
"from_secret": "PYPI_USERNAME",
|
||||||
},
|
},
|
||||||
"TWINE_PASSWORD": {
|
"HATCH_INDEX_AUTH": {
|
||||||
"from_secret": "TEST_PYPI_PASSWORD",
|
"from_secret": "TEST_PYPI_PASSWORD",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -136,10 +132,10 @@ def push_to_pypi():
|
|||||||
"name": "push to pypi",
|
"name": "push to pypi",
|
||||||
"image": "python:3",
|
"image": "python:3",
|
||||||
"environment": {
|
"environment": {
|
||||||
"TWINE_USERNAME": {
|
"HATCH_INDEX_USER": {
|
||||||
"from_secret": "PYPI_USERNAME",
|
"from_secret": "PYPI_USERNAME",
|
||||||
},
|
},
|
||||||
"TWINE_PASSWORD": {
|
"HATCH_INDEX_AUTH": {
|
||||||
"from_secret": "PYPI_PASSWORD",
|
"from_secret": "PYPI_PASSWORD",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
75
Makefile
75
Makefile
@ -5,7 +5,7 @@ ENV := venv
|
|||||||
.PHONY: default
|
.PHONY: default
|
||||||
default: test
|
default: test
|
||||||
|
|
||||||
# Creates virtualenv
|
# Creates de virtualenv
|
||||||
$(ENV):
|
$(ENV):
|
||||||
python3 -m venv $(ENV)
|
python3 -m venv $(ENV)
|
||||||
|
|
||||||
@ -13,87 +13,74 @@ $(ENV):
|
|||||||
$(ENV)/bin/$(NAME): $(ENV)
|
$(ENV)/bin/$(NAME): $(ENV)
|
||||||
$(ENV)/bin/pip install -r requirements-dev.txt
|
$(ENV)/bin/pip install -r requirements-dev.txt
|
||||||
|
|
||||||
# Install tox into virtualenv for running tests
|
# Install hatch into virtualenv for running tests
|
||||||
$(ENV)/bin/tox: $(ENV)
|
$(ENV)/bin/hatch: $(ENV)
|
||||||
$(ENV)/bin/pip install tox
|
$(ENV)/bin/pip install hatch
|
||||||
|
|
||||||
# Install wheel for building packages
|
|
||||||
$(ENV)/bin/wheel: $(ENV)
|
|
||||||
$(ENV)/bin/pip install wheel
|
|
||||||
|
|
||||||
# Install twine for uploading packages
|
|
||||||
$(ENV)/bin/twine: $(ENV)
|
|
||||||
$(ENV)/bin/pip install twine
|
|
||||||
|
|
||||||
# Installs dev requirements to virtualenv
|
# Installs dev requirements to virtualenv
|
||||||
.PHONY: devenv
|
.PHONY: devenv
|
||||||
devenv: $(ENV)/bin/$(NAME)
|
devenv: $(ENV)/bin/$(NAME)
|
||||||
|
|
||||||
# Generates a smaller env for running tox, which builds it's own env
|
# Runs tests for current python
|
||||||
.PHONY: test-env
|
|
||||||
test-env: $(ENV)/bin/tox
|
|
||||||
|
|
||||||
# Generates a small build env for building and uploading dists
|
|
||||||
.PHONY: build-env
|
|
||||||
build-env: $(ENV)/bin/twine $(ENV)/bin/wheel
|
|
||||||
|
|
||||||
# Runs package
|
|
||||||
.PHONY: run
|
|
||||||
run: $(ENV)/bin/$(NAME)
|
|
||||||
$(ENV)/bin/$(NAME)
|
|
||||||
|
|
||||||
# Runs tests with tox
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: $(ENV)/bin/tox
|
test: $(ENV)/bin/hatch
|
||||||
$(ENV)/bin/tox
|
$(ENV)/bin/hatch run +py=3 test:run
|
||||||
|
|
||||||
|
# Runs test matrix
|
||||||
|
.PHONY: test-matrix
|
||||||
|
test-matrix: $(ENV)/bin/hatch
|
||||||
|
$(ENV)/bin/hatch run test:run
|
||||||
|
|
||||||
# Builds wheel for package to upload
|
# Builds wheel for package to upload
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: $(ENV)/bin/wheel
|
build: $(ENV)/bin/hatch
|
||||||
$(ENV)/bin/python setup.py sdist
|
$(ENV)/bin/hatch build
|
||||||
$(ENV)/bin/python setup.py bdist_wheel
|
|
||||||
|
|
||||||
# Verify that the python version matches the git tag so we don't push bad shas
|
# Verify that the python version matches the git tag so we don't push bad shas
|
||||||
.PHONY: verify-tag-version
|
.PHONY: verify-tag-version
|
||||||
verify-tag-version:
|
verify-tag-version:
|
||||||
$(eval TAG_NAME = $(shell [ -n "$(DRONE_TAG)" ] && echo $(DRONE_TAG) || git describe --tags --exact-match))
|
$(eval TAG_NAME = $(shell [ -n "$(DRONE_TAG)" ] && echo $(DRONE_TAG) || git describe --tags --exact-match))
|
||||||
test "v$(shell python setup.py -V)" = "$(TAG_NAME)"
|
test "v$(shell $(ENV)/bin/hatch version)" = "$(TAG_NAME)"
|
||||||
|
|
||||||
# Uses twine to upload to pypi
|
# Upload to pypi
|
||||||
.PHONY: upload
|
.PHONY: upload
|
||||||
upload: verify-tag-version build $(ENV)/bin/twine
|
upload: verify-tag-version build
|
||||||
$(ENV)/bin/twine upload dist/*
|
$(ENV)/bin/hatch publish
|
||||||
|
|
||||||
# Uses twine to upload to test pypi
|
# Uses twine to upload to test pypi
|
||||||
.PHONY: upload-test
|
.PHONY: upload-test
|
||||||
upload-test: build $(ENV)/bin/twine
|
upload-test: build
|
||||||
$(ENV)/bin/twine check dist/*
|
$(ENV)/bin/hatch upload --repo test
|
||||||
$(ENV)/bin/twine upload --skip-existing --repository-url https://test.pypi.org/legacy/ dist/*
|
|
||||||
|
|
||||||
# Cleans all build, runtime, and test artifacts
|
# Cleans all build, runtime, and test artifacts
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -fr ./build *.egg-info ./htmlcov ./.coverage ./.pytest_cache ./.tox
|
rm -fr ./build *.egg-info ./htmlcov ./.coverage ./.pytest_cache
|
||||||
find . -name '*.pyc' -delete
|
find . -name '*.pyc' -delete
|
||||||
find . -name '__pycache__' -delete
|
find . -name '__pycache__' -delete
|
||||||
|
|
||||||
# Cleans dist and env
|
# Cleans dist and env
|
||||||
.PHONY: dist-clean
|
.PHONY: dist-clean
|
||||||
dist-clean: clean
|
dist-clean: clean
|
||||||
|
-$(ENV)/bin/hatch env prune
|
||||||
rm -fr ./dist $(ENV)
|
rm -fr ./dist $(ENV)
|
||||||
|
|
||||||
|
# Run linters
|
||||||
|
.PHONY: lint
|
||||||
|
lint: $(ENV)/bin/hatch
|
||||||
|
$(ENV)/bin/hatch run lint:all
|
||||||
|
|
||||||
# Install pre-commit hooks
|
# Install pre-commit hooks
|
||||||
.PHONY: install-hooks
|
.PHONY: install-hooks
|
||||||
install-hooks: devenv
|
install-hooks: devenv
|
||||||
$(ENV)/bin/pre-commit install -f --install-hooks
|
$(ENV)/bin/hatch run lint:install-hooks
|
||||||
|
|
||||||
# Generates test coverage
|
# Generates test coverage
|
||||||
.coverage:
|
.coverage: test
|
||||||
$(ENV)/bin/tox
|
|
||||||
|
|
||||||
# Builds coverage html
|
# Builds coverage html
|
||||||
htmlcov/index.html: .coverage
|
htmlcov/index.html: .coverage
|
||||||
$(ENV)/bin/coverage html
|
$(ENV)/bin/hatch run coverage html
|
||||||
|
|
||||||
# Opens coverage html in browser (on macOS and some Linux systems)
|
# Opens coverage html in browser (on macOS and some Linux systems)
|
||||||
.PHONY: open-coverage
|
.PHONY: open-coverage
|
||||||
@ -107,7 +94,7 @@ docs-clean:
|
|||||||
|
|
||||||
# Builds docs
|
# Builds docs
|
||||||
docs/build/html/index.html:
|
docs/build/html/index.html:
|
||||||
$(ENV)/bin/tox -e docs
|
$(ENV)/bin/hatch run docs:build
|
||||||
|
|
||||||
# Shorthand for building docs
|
# Shorthand for building docs
|
||||||
.PHONY: docs
|
.PHONY: docs
|
||||||
|
@ -36,3 +36,26 @@ Homepage = "https://git.iamthefij.com/iamthefij/release-gitter"
|
|||||||
|
|
||||||
[tool.hatch.build]
|
[tool.hatch.build]
|
||||||
include = ["release_gitter.py", "pseudo_builder.py"]
|
include = ["release_gitter.py", "pseudo_builder.py"]
|
||||||
|
|
||||||
|
[tool.hatch.envs.test]
|
||||||
|
dependencies = [
|
||||||
|
"coverage",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.hatch.envs.test.scripts]
|
||||||
|
run = [
|
||||||
|
"coverage erase",
|
||||||
|
"coverage run --source=release_gitter -m unittest discover . *_test.py",
|
||||||
|
"coverage report -m # --fail-under 70",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[tool.hatch.envs.test.matrix]]
|
||||||
|
python = ["3", "3.7", "3.8", "3.9", "3.10", "3.11"]
|
||||||
|
|
||||||
|
[tool.hatch.envs.lint]
|
||||||
|
detached = true
|
||||||
|
dependencies = ["pre-commit"]
|
||||||
|
|
||||||
|
[tool.hatch.envs.lint.scripts]
|
||||||
|
all = "pre-commit run --all-files"
|
||||||
|
install-hooks = "pre-commit install --install-hooks"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-e .
|
-e .
|
||||||
coverage
|
hatch
|
||||||
mypy
|
mypy
|
||||||
pre-commit
|
pre-commit
|
||||||
types-requests
|
types-requests
|
||||||
|
17
tox.ini
17
tox.ini
@ -1,17 +0,0 @@
|
|||||||
[tox]
|
|
||||||
envlist = py3,py37,py38,py39,py310,py311
|
|
||||||
|
|
||||||
[testenv]
|
|
||||||
deps =
|
|
||||||
-rrequirements-dev.txt
|
|
||||||
commands =
|
|
||||||
coverage erase
|
|
||||||
coverage run --source=release_gitter -m unittest discover . {posargs:"*_test.py"}
|
|
||||||
coverage report -m # --fail-under 70
|
|
||||||
pre-commit run --all-files
|
|
||||||
|
|
||||||
[testenv:pre-commit]
|
|
||||||
deps =
|
|
||||||
pre-commit
|
|
||||||
commands =
|
|
||||||
pre-commit {posargs}
|
|
Loading…
Reference in New Issue
Block a user