Skip to content

Commit

Permalink
chore: rework dev setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola committed Jun 22, 2023
1 parent a8d386e commit 4ebc9c1
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 198 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
extend-ignore =
E501
extend-exclude =
docs
2 changes: 1 addition & 1 deletion .github/workflows/bot_stale.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Close stale issues"
name: Close stale issues

on:
schedule:
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/code_style.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install dependencies
run: pip install pre-commit

- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure
6 changes: 3 additions & 3 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Release please

on:
push:
branches:
- main
name: release-please
branches: [main]

jobs:
release-please:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
python-version: 3.x

- name: Install dependencies
run: |
pip install --upgrade pip
pip install --upgrade build twine
run: pip install build twine

- name: Build
run: python3 -m build
Expand Down
26 changes: 14 additions & 12 deletions .github/workflows/unit_test.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
name: Unit Tests
name: Test

on: [push, pull_request]
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/test.txt
pip install tox tox-gh-actions
sudo apt install build-essential
- name: Test with tox
run: pip install tox tox-gh-actions

- name: Run tox
run: tox
env:
PLATFORM: ${{ matrix.platform }}
61 changes: 28 additions & 33 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
stages:
- test

.tests_template: &tests_template
before_script:
- pip install tox
- apk add build-base git
stage: test
script: tox
default:
tags:
- hc-bladerunner

python37:
<<: *tests_template
image: python:3.7-alpine
script: tox -e py37
stages:
- test

python38:
<<: *tests_template
image: python:3.8-alpine
script: tox -e py38
pre-commit:
stage: test

python39:
<<: *tests_template
image: python:3.9-alpine
script: tox -e py39
image: python:3.11-slim
before_script:
- pip install pre-commit
script:
- pre-commit run --all-files --show-diff-on-failure

python310:
<<: *tests_template
image: python:3.10-alpine
script: tox -e py310
test:
stage: test

python311:
<<: *tests_template
image: python:3.11-alpine
script: tox -e py311
parallel:
matrix:
- python_version: 3.7
tox_env: py37
- python_version: 3.8
tox_env: py38
- python_version: 3.9
tox_env: py39
- python_version: 3.10
tox_env: py310
- python_version: 3.11
tox_env: py311

test-style:
<<: *tests_template
image: python:3.9-alpine
image: python:${python_version}-slim
before_script:
- pip install tox
script:
- tox -e pre-commit
- tox -e ${tox_env}
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ repos:
rev: 5.12.0
hooks:
- id: isort
args: [--profile=black]

- repo: https://github.com/psf/black
rev: 23.3.0
Expand Down
94 changes: 16 additions & 78 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,85 +1,23 @@
.PHONY: clean clean-test clean-pyc clean-build docs help
.DEFAULT_GOAL := help
SHELL := bash
.PHONY: test coverage docs clean

define BROWSER_PYSCRIPT
import os, webbrowser, sys
venv:
python3 -m venv venv
venv/bin/pip install -e .[docs,test]

try:
from urllib import pathname2url
except:
from urllib.request import pathname2url
test: venv
venv/bin/pytest -v

webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT
coverage: venv
venv/bin/coverage run -m pytest -v
venv/bin/coverage report --show-missing
venv/bin/coverage html
xdg-open htmlcov/index.html

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

BROWSER := python -c "$$BROWSER_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 -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache

lint: ## check code with pre-commit
tox -e pre-commit

test: ## run tests quickly with the default Python
py.test

test-all: ## run tests on every Python version with tox
tox

coverage: ## check code coverage quickly with the default Python
coverage run --source hcloud -m pytest
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
docs:
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html

servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .

release: dist ## package and upload a release
twine upload dist/*

dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
xdg-open docs/_build/html/index.html

install: clean ## install the package to the active Python's site-packages
python setup.py install
clean:
git clean -xdf
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# hcloud documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[tool.isort]
profile = "black"
combine_as_imports = true

[tool.coverage.run]
source = ["hcloud"]

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
1 change: 0 additions & 1 deletion requirements/base.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements/test.txt

This file was deleted.

19 changes: 0 additions & 19 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 4ebc9c1

Please sign in to comment.