This commit is contained in:
parent
8b9ff334a5
commit
30801c5927
18
.drone.star
18
.drone.star
@ -43,24 +43,20 @@ def tests():
|
||||
"name": "tests",
|
||||
"workspace": get_workspace(),
|
||||
"steps": [
|
||||
tox_step("python:"+version)
|
||||
test_step("python:"+version)
|
||||
for version in PYTHON_VERSIONS
|
||||
],
|
||||
}]
|
||||
|
||||
|
||||
# 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 {
|
||||
"name": "test {}".format(docker_tag.replace(":", "")),
|
||||
"image": docker_tag,
|
||||
"environment": {
|
||||
"TOXENV": tox_env,
|
||||
},
|
||||
"commands": [
|
||||
"{} -V".format(python_cmd),
|
||||
"pip install tox",
|
||||
"tox",
|
||||
"make test"
|
||||
],
|
||||
}
|
||||
|
||||
@ -123,10 +119,10 @@ def push_to_pypi():
|
||||
"name": "push to test pypi",
|
||||
"image": "python:3",
|
||||
"environment": {
|
||||
"TWINE_USERNAME": {
|
||||
"HATCH_INDEX_USER": {
|
||||
"from_secret": "PYPI_USERNAME",
|
||||
},
|
||||
"TWINE_PASSWORD": {
|
||||
"HATCH_INDEX_AUTH": {
|
||||
"from_secret": "TEST_PYPI_PASSWORD",
|
||||
},
|
||||
},
|
||||
@ -136,10 +132,10 @@ def push_to_pypi():
|
||||
"name": "push to pypi",
|
||||
"image": "python:3",
|
||||
"environment": {
|
||||
"TWINE_USERNAME": {
|
||||
"HATCH_INDEX_USER": {
|
||||
"from_secret": "PYPI_USERNAME",
|
||||
},
|
||||
"TWINE_PASSWORD": {
|
||||
"HATCH_INDEX_AUTH": {
|
||||
"from_secret": "PYPI_PASSWORD",
|
||||
},
|
||||
},
|
||||
|
75
Makefile
75
Makefile
@ -5,7 +5,7 @@ ENV := venv
|
||||
.PHONY: default
|
||||
default: test
|
||||
|
||||
# Creates virtualenv
|
||||
# Creates de virtualenv
|
||||
$(ENV):
|
||||
python3 -m venv $(ENV)
|
||||
|
||||
@ -13,87 +13,74 @@ $(ENV):
|
||||
$(ENV)/bin/$(NAME): $(ENV)
|
||||
$(ENV)/bin/pip install -r requirements-dev.txt
|
||||
|
||||
# Install tox into virtualenv for running tests
|
||||
$(ENV)/bin/tox: $(ENV)
|
||||
$(ENV)/bin/pip install tox
|
||||
|
||||
# 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
|
||||
# Install hatch into virtualenv for running tests
|
||||
$(ENV)/bin/hatch: $(ENV)
|
||||
$(ENV)/bin/pip install hatch
|
||||
|
||||
# Installs dev requirements to virtualenv
|
||||
.PHONY: devenv
|
||||
devenv: $(ENV)/bin/$(NAME)
|
||||
|
||||
# Generates a smaller env for running tox, which builds it's own env
|
||||
.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
|
||||
# Runs tests for current python
|
||||
.PHONY: test
|
||||
test: $(ENV)/bin/tox
|
||||
$(ENV)/bin/tox
|
||||
test: $(ENV)/bin/hatch
|
||||
$(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
|
||||
.PHONY: build
|
||||
build: $(ENV)/bin/wheel
|
||||
$(ENV)/bin/python setup.py sdist
|
||||
$(ENV)/bin/python setup.py bdist_wheel
|
||||
build: $(ENV)/bin/hatch
|
||||
$(ENV)/bin/hatch build
|
||||
|
||||
# Verify that the python version matches the git tag so we don't push bad shas
|
||||
.PHONY: verify-tag-version
|
||||
verify-tag-version:
|
||||
$(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
|
||||
upload: verify-tag-version build $(ENV)/bin/twine
|
||||
$(ENV)/bin/twine upload dist/*
|
||||
upload: verify-tag-version build
|
||||
$(ENV)/bin/hatch publish
|
||||
|
||||
# Uses twine to upload to test pypi
|
||||
.PHONY: upload-test
|
||||
upload-test: build $(ENV)/bin/twine
|
||||
$(ENV)/bin/twine check dist/*
|
||||
$(ENV)/bin/twine upload --skip-existing --repository-url https://test.pypi.org/legacy/ dist/*
|
||||
upload-test: build
|
||||
$(ENV)/bin/hatch upload --repo test
|
||||
|
||||
# Cleans all build, runtime, and test artifacts
|
||||
.PHONY: 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 '__pycache__' -delete
|
||||
|
||||
# Cleans dist and env
|
||||
.PHONY: dist-clean
|
||||
dist-clean: clean
|
||||
-$(ENV)/bin/hatch env prune
|
||||
rm -fr ./dist $(ENV)
|
||||
|
||||
# Run linters
|
||||
.PHONY: lint
|
||||
lint: $(ENV)/bin/hatch
|
||||
$(ENV)/bin/hatch run lint:all
|
||||
|
||||
# Install pre-commit hooks
|
||||
.PHONY: install-hooks
|
||||
install-hooks: devenv
|
||||
$(ENV)/bin/pre-commit install -f --install-hooks
|
||||
$(ENV)/bin/hatch run lint:install-hooks
|
||||
|
||||
# Generates test coverage
|
||||
.coverage:
|
||||
$(ENV)/bin/tox
|
||||
.coverage: test
|
||||
|
||||
# Builds coverage html
|
||||
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)
|
||||
.PHONY: open-coverage
|
||||
@ -107,7 +94,7 @@ docs-clean:
|
||||
|
||||
# Builds docs
|
||||
docs/build/html/index.html:
|
||||
$(ENV)/bin/tox -e docs
|
||||
$(ENV)/bin/hatch run docs:build
|
||||
|
||||
# Shorthand for building docs
|
||||
.PHONY: docs
|
||||
|
@ -36,3 +36,26 @@ Homepage = "https://git.iamthefij.com/iamthefij/release-gitter"
|
||||
|
||||
[tool.hatch.build]
|
||||
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 .
|
||||
coverage
|
||||
hatch
|
||||
mypy
|
||||
pre-commit
|
||||
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