diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..a6e1dd1 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,31 @@ +name: devranta build +run-name: devranta async devRant api client build and test +on: [push] + +jobs: + Build: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Pull repo + run: git pull + - name: List files in the repository + run: | + ls ${{ gitea.workspace }} + - name: Build new package + run: make build + - name: Install package + run: make install + - name: Run application + run: make run + - name: Test application + run: make test + - name: Push new packages + run: | + git add . + git config --global user.email "bot@molodetz.nl" + git config --global user.name "bot" + git commit -a -m "New build." + git push + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0b724bb --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +PYTHON=./.venv/bin/python +PIP=./.venv/bin/pip +BIN=./.venv/bin +APP=form + +all: ensure_env format install build test + +ensure_env: + -@python3 -m venv .venv + +install: + $(PIP) install -e . + +format: + $(PIP) install shed + . $(ENV) && shed + +build: + $(PIP) install build + $(PYTHON) -m build . + +test: + $(PYTHON) -m unittest $(APP).tests + +run: + $(BIN)/$(APP).serve + + + + + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..07de284 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..0ac5f31 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,24 @@ +[metadata] +name = form +version = 1.0.0 +description = REST Form builder and validator. +author = retoor +author_email = retoor@molodetz.nl +license = MIT +long_description = file: README.md +long_description_content_type = text/markdown + +[options] +packages = find: +package_dir = + = src +python_requires = >=3.7 +install_requires = + requests + app @ retoor.molodetz.nl/retoor/app +[options.packages.find] +where = src + +[options.entry_points] +console_scripts = + form = form.__main__:main diff --git a/src/form/__init__.py b/src/form/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/form/__main__.py b/src/form/__main__.py new file mode 100644 index 0000000..03bd23c --- /dev/null +++ b/src/form/__main__.py @@ -0,0 +1,14 @@ +from form.app import Application +from app.app import argument_parser + + + +def main(): + args = argument_parser.parse_args() + app = Application(db_file="sqlite:///form.db",web_db=args.web_db)) + app.run(host=args.host,port=args.port) + +if __name__ == '__main__': + main() + + diff --git a/src/form/app.py b/src/form/app.py new file mode 100644 index 0000000..2a36e10 --- /dev/null +++ b/src/form/app.py @@ -0,0 +1,26 @@ +from app.app import Application as BaseApplication +import uuid +import asyncio + + +class Application(BaseApplication): + + def __init__(self, *args, **kwargs): + + self.forms_created + self.forms_validate_success = 0 + self.forms_validate_failure = 0 + self.forms_validate_pending = 0 + + super().__init__(*args, **kwargs): + + self.router.add_get("/", self.index_handler) + + + async def index_handler(self): + return web.json_response(dict( + message="Nothing to see here", + error="404" + ),status_code=404) + + diff --git a/src/form/tests.py b/src/form/tests.py new file mode 100644 index 0000000..cbf81ef --- /dev/null +++ b/src/form/tests.py @@ -0,0 +1,18 @@ +import asyncio +import unittest + + +class AppTestCase(unittest.IsolatedAsyncioTestCase): + + async def asyncSetup(self): + print("Async setup") + + async def test_init(self): + self.assertTrue(True) + + + + +if __name__ == '__main__': + unittest.main() +