ci: added linting config & pipeline; renamed project to aiovieter
ci/woodpecker/push/lint Pipeline failed Details

dev
Jef Roosens 2022-06-05 17:16:29 +02:00
parent 242d685a6c
commit e9a189b309
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
11 changed files with 67 additions and 19 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.venv/ .venv/
__pycache__/ __pycache__/
main.py main.py
*.egg-info/

View File

@ -0,0 +1,10 @@
branches:
exclude: [ main ]
platform: 'linux/amd64'
pipeline:
lint:
image: 'python:alpine'
commands:
- pip install -e .[lint]
- flake8 aiovieter

View File

@ -1,13 +1,22 @@
PYTHON ?= python3 PYTHON ?= python3
VENV ?= .venv VENV ?= .venv
SRC_DIR = aiovieter
.PHONY: venv .PHONY: venv
venv: $(VENV)/bin/activate venv: $(VENV)/bin/activate
$(VENV)/bin/activate: requirements.txt $(VENV)/bin/activate: setup.py setup.cfg
rm -rf '$(VENV)' rm -rf '$(VENV)'
'$(PYTHON)' -m venv '$(VENV)' '$(PYTHON)' -m venv '$(VENV)'
'$(VENV)'/bin/pip install -r requirements.txt '$(VENV)'/bin/pip install -e .[develop]
.PHONY: shell .PHONY: shell
shell: venv shell: venv
@ '$(VENV)'/bin/python @ '$(VENV)'/bin/python
.PHONY: lint
lint: venv
'$(VENV)/bin/flake8' '$(SRC_DIR)'
.PHONY: format
format: venv
'$(VENV)/bin/black' '$(SRC_DIR)'

View File

@ -1,3 +1,3 @@
from .vieter import Vieter from .vieter import Vieter
__all__ = ('Vieter') __all__ = "Vieter"

View File

@ -0,0 +1,8 @@
class VieterBuildLogs:
def __init__(self, vieter):
self._vieter = vieter
async def list(self, offset: int = 0, limit: int = 25):
params = {"offset": offset, "limit": limit}
return await self._vieter._get("/api/logs", params=params)

View File

@ -0,0 +1,8 @@
class VieterRepos:
def __init__(self, vieter):
self._vieter = vieter
async def list(self, offset: int = 0, limit: int = 25):
params = {"offset": offset, "limit": limit}
return await self._vieter._get("/api/repos", params=params)

View File

@ -1,16 +1,19 @@
import aiohttp import aiohttp
from .repos import VieterRepos from .repos import VieterRepos
from .logs import VieterBuildLogs
class Vieter: class Vieter:
def __init__(self, address: str, api_key: str) -> None: def __init__(self, address: str, api_key: str) -> None:
self._address = address self._address = address
self._api_key = api_key self._api_key = api_key
self._client = aiohttp.ClientSession( self._client = aiohttp.ClientSession(
base_url=address, headers={'X-Api-Key': api_key} base_url=address, headers={"X-Api-Key": api_key}
) )
self.repos = VieterRepos(self) self.repos = VieterRepos(self)
self.logs = VieterBuildLogs(self)
async def close(self): async def close(self):
await self._client.close() await self._client.close()
@ -20,4 +23,4 @@ class Vieter:
return await res.json() return await res.json()
async def _get(self, *args, **kwargs): async def _get(self, *args, **kwargs):
return await self._do_req('GET', *args, **kwargs) return await self._do_req("GET", *args, **kwargs)

View File

@ -1,2 +0,0 @@
aiohttp
aiodns

14
setup.cfg 100644
View File

@ -0,0 +1,14 @@
[options]
install_requires =
aiohttp
[options.extras_require]
# Used inside tox for linting
lint =
black==22.3.0
flake8==4.0.1
flake8-black==0.3.3
# Required for the developer
develop =
%(lint)s
jedi

8
setup.py 100644
View File

@ -0,0 +1,8 @@
from setuptools import setup
setup(
name="aiovieter",
version="0.1.0",
author="Jef Roosens",
description="Wrapper around the Vieter API.",
packages=["aiovieter"],
)

View File

@ -1,11 +0,0 @@
class VieterRepos:
def __init__(self, vieter):
self._vieter = vieter
async def list(self, offset: int = 0, limit: int = 25):
params = {
'offset': offset,
'limit': limit
}
return await self._vieter._get('/api/repos', params=params)