Browse Source

Test on Python 3.7, 3.9, and 3.10. Replace Makefile with make.py (#4)

Co-authored-by: /dev/null <dev@null>
Reviewed-on: https://git.sporestack.com/SporeStack/sporestack-python/pulls/4

Woodpecker might be a little buggy. More than three jobs at once seems to cause strange problems.
Co-authored-by: spore <spore@noreply.localhost>
Co-committed-by: spore <spore@noreply.localhost>
master
spore 4 days ago
parent
commit
49f469a7b3
  1. 3
      .flake8
  2. 36
      .woodpecker.yml
  3. 21
      Makefile
  4. 6
      Pipfile
  5. 43
      Pipfile.lock
  6. 2
      README.md
  7. 84
      make.py

3
.flake8

@ -1,2 +1,5 @@
[flake8]
max-line-length = 88
noqa-require-code = True
exclude = .git,__pycache__,build,dist
max-complexity = 15

36
.woodpecker.yml

@ -1,8 +1,36 @@
pipeline:
test:
image: python:3.8
python-3.7:
group: test
image: python:3.7-slim
commands:
- pip install pipenv
- pipenv install --dev --deploy
- pipenv run make test
- pipenv run make build-dist
- pipenv run python make.py test-pytest # We only test with pytest on 3.7
- pipenv run python make.py build-dist
# python-3.8:
# group: test
# image: python:3.8-slim
# commands:
# - pip install pipenv
# - pipenv install --dev --deploy
# - pipenv run python make.py test
# - pipenv run python make.py build-dist
python-3.9:
group: test
image: python:3.9-slim
commands:
- pip install pipenv
- pipenv install --dev --deploy
- pipenv run python make.py test
- pipenv run python make.py build-dist
python-3.10:
group: test
image: python:3.10-slim
commands:
- pip install pipenv
- pipenv install --dev --deploy
- pipenv run python make.py test
- pipenv run python make.py build-dist

21
Makefile

@ -1,21 +0,0 @@
format:
python3 -m black .
python3 -m isort .
test:
python3 -m black --check .
python3 -m isort --check .
python3 -m flake8 .
python3 -m mypy --strict .
python3 -m pytest --cov=sporestack --cov-fail-under=49 --cov-report=term --durations=3 --cache-clear
build-dist:
# This should result in a reproducible wheel.
rm dist/* || true
python3 -m build --sdist --no-isolation
asaman -o dist -d dist
python3 -m twine check --strict dist/*
publish: build-dist
# The sdist isn't reproducible, but the wheel is.
python3 -m twine upload dist/*

6
Pipfile

@ -8,13 +8,13 @@ sporestack = {editable = true, path = "."}
[dev-packages]
# Have to do == because it's a pre-release.
black = "==21.10b0"
black = "==21.11b1"
flake8 = "~=4.0"
flake8-noqa = "~=1.2"
pep8-naming = "~=0.12.1"
mypy = "~=0.910"
pytest = "~=6.2"
pytest-cov = "~=2.11"
pytest-cov = "~=3.0"
isort = "~=5.8"
types-requests = "~=2.25"
@ -24,3 +24,5 @@ asaman = "~=0.1.6"
wheel = "~=0.37.0"
# Publishing
twine = "~=3.4"
typer = "~=0.4.0"

43
Pipfile.lock

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "312468a9937e6726d47437bf8efbc7d1036aad78021b88660668e0bc195d57ca"
"sha256": "2686e2110aafc6fade889d774c89c60270dd7ab62eeb1771d7ac77f52cc52804"
},
"pipfile-spec": 6,
"requires": {},
@ -148,11 +148,11 @@
},
"black": {
"hashes": [
"sha256:6eb7448da9143ee65b856a5f3676b7dda98ad9abe0f87fce8c59291f15e82a5b",
"sha256:a9952229092e325fe5f3dae56d81f639b23f7131eb840781947e4b2886030f33"
"sha256:802c6c30b637b28645b7fde282ed2569c0cd777dbe493a41b6a03c1d903f99ac",
"sha256:a042adbb18b3262faad5aff4e834ff186bb893f95ba3a8013f09de1e5569def2"
],
"index": "pypi",
"version": "==21.10b0"
"version": "==21.11b1"
},
"bleach": {
"hashes": [
@ -202,6 +202,9 @@
"version": "==0.4.4"
},
"coverage": {
"extras": [
"toml"
],
"hashes": [
"sha256:046647b96969fda1ae0605f61288635209dd69dcd27ba3ec0bf5148bc157f954",
"sha256:06d009e8a29483cbc0520665bc46035ffe9ae0e7484a49f9782c2a716e37d0a0",
@ -256,11 +259,11 @@
},
"docutils": {
"hashes": [
"sha256:a31688b2ea858517fa54293e5d5df06fbb875fb1f7e4c64529271b77781ca8fc",
"sha256:c1d5dab2b11d16397406a282e53953fe495a46d69ae329f55aa98a5c4e3c5fbb"
"sha256:23010f129180089fbcd3bc08cfefccb3b890b0050e1ca00c867036e9d161b98c",
"sha256:679987caf361a7539d76e584cbeddc311e3aee937877c87346f31debc63e9d06"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==0.18"
"version": "==0.18.1"
},
"flake8": {
"hashes": [
@ -398,10 +401,10 @@
},
"pkginfo": {
"hashes": [
"sha256:37ecd857b47e5f55949c41ed061eb51a0bee97a87c969219d144c0e023982779",
"sha256:e7432f81d08adec7297633191bbf0bd47faf13cd8724c3a13250e51d542635bd"
"sha256:65175ffa2c807220673a41c371573ac9a1ea1b19ffd5eef916278f428319934f",
"sha256:bb55a6c017d50f2faea5153abc7b05a750e7ea7ae2cbb7fb3ad6f1dcf8d40988"
],
"version": "==1.7.1"
"version": "==1.8.1"
},
"platformdirs": {
"hashes": [
@ -469,11 +472,11 @@
},
"pytest-cov": {
"hashes": [
"sha256:261bb9e47e65bd099c89c3edf92972865210c36813f80ede5277dceb77a4a62a",
"sha256:261ceeb8c227b726249b376b8526b600f38667ee314f910353fa318caa01f4d7"
"sha256:578d5d15ac4a25e5f961c938b85a05b09fdaae9deef3bb6de9a6e766622ca7a6",
"sha256:e7f0f5b1617d2210a2cabc266dfe2f4c75a8d32fb89eafb7ad9d06f6d076d470"
],
"index": "pypi",
"version": "==2.12.1"
"version": "==3.0.0"
},
"readme-renderer": {
"hashes": [
@ -563,11 +566,11 @@
},
"setuptools": {
"hashes": [
"sha256:94ee891f4759150cded601a6beb6b08400413aefd0267b692f3f8c6e0bb238e7",
"sha256:fb537610c2dfe77b5896e3ee53dd53fbdd9adc48076c8f28cee3a30fb59a5038"
"sha256:157d21de9d055ab9e8ea3186d91e7f4f865e11f42deafa952d90842671fc2576",
"sha256:4adde3d1e1c89bde1c643c64d89cdd94cbfd8c75252ee459d4500bccb9c7d05d"
],
"markers": "python_version >= '3.6'",
"version": "==59.1.1"
"version": "==59.2.0"
},
"six": {
"hashes": [
@ -609,6 +612,14 @@
"index": "pypi",
"version": "==3.6.0"
},
"typer": {
"hashes": [
"sha256:63c3aeab0549750ffe40da79a1b524f60e08a2cbc3126c520ebf2eeaf507f5dd",
"sha256:d81169725140423d072df464cad1ff25ee154ef381aaf5b8225352ea187ca338"
],
"markers": "python_version >= '3.6'",
"version": "==0.4.0"
},
"types-requests": {
"hashes": [
"sha256:809b5dcd3c408ac39d11d593835b6aff32420b3e7ddb79c7f3e823330f040466",

2
README.md

@ -2,7 +2,7 @@
## Requirements
* Python 3.7+
* Python 3.7+, preferably 3.8+
## Installation

84
make.py

@ -0,0 +1,84 @@
import shutil
import subprocess
from pathlib import Path
from typing import List
import typer
app = typer.Typer()
def run(command: List[str]) -> None:
typer.echo(f"Running command: {' '.join(command)}", err=True)
try:
subprocess.run(command).check_returncode()
except subprocess.CalledProcessError:
# Hide traceback, it's not useful.
raise typer.Exit(code=1) from None
@app.command()
def format() -> None:
"""
Format the code as needed.
"""
run(["black", "."])
run(["isort", "."])
@app.command()
def test() -> None:
_test_formatting()
_test_common()
@app.command()
def format_test() -> None:
format()
_test_common()
def _test_formatting() -> None:
run(["black", "--check", "."])
run(["isort", "--check", "."])
def _test_common() -> None:
run(["flake8", "."])
run(["mypy", "--strict", "."])
test_pytest()
@app.command()
def test_pytest() -> None:
run(
[
"pytest",
"--cov=sporestack",
"--cov-fail-under=49",
"--cov-report=term",
"--durations=3",
"--cache-clear",
]
)
@app.command()
def build_dist() -> None:
dist = Path("dist")
if dist.exists():
shutil.rmtree(dist)
run(["python", "-m", "build", "--sdist", "--no-isolation"])
run(["asaman", "-o", str(dist), "-d", str(dist)])
run(["twine", "check", "--strict", f"{dist}/*"])
@app.command()
def publish() -> None:
dist = Path("dist")
build_dist()
run(["twine", "upload", f"{dist}/*"])
if __name__ == "__main__":
app()
Loading…
Cancel
Save