diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 468b11f..41e68a8 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.4.0 +current_version = 0.0.1 commit = False tag = False @@ -7,10 +7,10 @@ tag = False search = version = "{current_version}" replace = version = "{new_version}" -[bumpversion:file:src/rmfpapi/__init__.py] +[bumpversion:file:src/matrixrmapi/__init__.py] search = __version__ = "{current_version}" replace = __version__ = "{new_version}" -[bumpversion:file:tests/test_rmfpapi.py] +[bumpversion:file:tests/test_matrixrmapi.py] search = __version__ == "{current_version}" replace = __version__ == "{new_version}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 97117b3..f359386 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,4 +42,4 @@ jobs: - uses: pvarki/ci@main with: dockerfile-target: devel_shell - image-tag: rmfpapi:devel_shell + image-tag: matrixrmapi:devel_shell diff --git a/Dockerfile b/Dockerfile index ec383f4..723fa99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -107,7 +107,7 @@ RUN --mount=type=ssh apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* \ && chmod a+x /docker-entrypoint.sh \ && chmod a+x /container-init.sh \ - && WHEELFILE=`echo /tmp/wheelhouse/rmfpapi-*.whl` \ + && WHEELFILE=`echo /tmp/wheelhouse/matrixrmapi-*.whl` \ && pip3 install --find-links=/tmp/wheelhouse/ "$WHEELFILE"[all] \ && rm -rf /tmp/wheelhouse/ \ # Do whatever else you need to diff --git a/README.rst b/README.rst index 9d6d6e4..e6ec3fe 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,6 @@ -======= -rmfpapi -======= +=================== +python-matrix-rmapi +=================== Matrix service RASENMAEHER integration API service. Serves as a reference implementation for a new integration into the deploy app ecosystem. @@ -34,14 +34,14 @@ Creating a development container Build image, create container and start it:: - docker build --ssh default --target devel_shell -t rmfpapi:devel_shell . - docker create --name rmfpapi_devel -p 4625:4625 -v `pwd`":/app" -it `echo $DOCKER_SSHAGENT` rmfpapi:devel_shell - docker start -i rmfpapi_devel + docker build --ssh default --target devel_shell -t matrixrmapi:devel_shell . + docker create --name matrixrmapi_devel -p 4625:4625 -v `pwd`":/app" -it `echo $DOCKER_SSHAGENT` matrixrmapi:devel_shell + docker start -i matrixrmapi_devel In the shell you can start the uvicorn devel server with (binding to 0.0.0.0 is important!):: - uvicorn "rmfpapi.app:get_app" --factory --host 0.0.0.0 --port 4625 --reload --log-level debug + uvicorn "matrixrmapi.app:get_app" --factory --host 0.0.0.0 --port 4625 --reload --log-level debug pre-commit considerations @@ -49,13 +49,13 @@ pre-commit considerations If working in Docker instead of native env you need to run the pre-commit checks in docker too:: - docker exec -i rmfpapi_devel /bin/bash -c "pre-commit install --install-hooks" - docker exec -i rmfpapi_devel /bin/bash -c "pre-commit run --all-files" + docker exec -i matrixrmapi_devel /bin/bash -c "pre-commit install --install-hooks" + docker exec -i matrixrmapi_devel /bin/bash -c "pre-commit run --all-files" You need to have the container running, see above. Or alternatively use the docker run syntax but using the running container is faster:: - docker run --rm -it -v `pwd`":/app" rmfpapi:devel_shell -c "pre-commit run --all-files" + docker run --rm -it -v `pwd`":/app" matrixrmapi:devel_shell -c "pre-commit run --all-files" Test suite ^^^^^^^^^^ @@ -63,8 +63,8 @@ Test suite You can use the devel shell to run py.test when doing development, for CI use the "tox" target in the Dockerfile:: - docker build --ssh default --target tox -t rmfpapi:tox . - docker run --rm -it -v `pwd`":/app" `echo $DOCKER_SSHAGENT` rmfpapi:tox + docker build --ssh default --target tox -t matrixrmapi:tox . + docker run --rm -it -v `pwd`":/app" `echo $DOCKER_SSHAGENT` matrixrmapi:tox Production docker ^^^^^^^^^^^^^^^^^ @@ -72,8 +72,8 @@ Production docker There's a "production" target as well for running the application, remember to change that architecture tag to arm64 if building on ARM:: - docker build --ssh default --target production -t rmfpapi:latest . - docker run -it --name rmfpapi -p 4625:4625 rmfpapi:amd64-latest + docker build --ssh default --target production -t matrixrmapi:latest . + docker run -it --name matrixrmapi -p 4625:4625 matrixrmapi:amd64-latest Development ----------- diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index b87698e..2932050 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -5,7 +5,7 @@ set -e if [ "$#" -eq 0 ]; then # FIXME: can we know the traefik/nginx internal docker ip easily ? - exec gunicorn "rmfpapi.app:get_app()" --bind 0.0.0.0:8001 --forwarded-allow-ips='*' -w 4 -k uvicorn.workers.UvicornWorker + exec gunicorn "matrixrmapi.app:get_app()" --bind 0.0.0.0:8012 --forwarded-allow-ips='*' -w 4 -k uvicorn.workers.UvicornWorker else exec "$@" fi diff --git a/pyproject.toml b/pyproject.toml index 9eae7ad..2dfcb68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,15 @@ [tool.poetry] -name = "rmfpapi" -version = "1.4.0" +name = "matrixrmapi" +version = "0.0.1" description = "Matrix service RASENMAEHER integration API service" authors = ["Eero af Heurlin "] -homepage = "https://github.com/pvarki/python-rasenmaeher-rmfpapi/" -repository = "https://github.com/pvarki/python-rasenmaeher-rmfpapi/" +homepage = "https://github.com/pvarki/python-rasenmaeher-matrixrmapi/" +repository = "https://github.com/pvarki/python-rasenmaeher-matrixrmapi/" license = "MIT" readme = "README.rst" [tool.poetry.scripts] -rmfpapi = "rmfpapi.console:rmfpapi_cli" +matrixrmapi = "matrixrmapi.console:matrixrmapi_cli" @@ -39,7 +39,7 @@ strict=true [tool.pytest.ini_options] junit_family="xunit2" -addopts="--cov=rmfpapi --cov-fail-under=55 --cov-branch" +addopts="--cov=matrixrmapi --cov-fail-under=55 --cov-branch" asyncio_mode="strict" [tool.pylint.format] diff --git a/src/rmfpapi/__init__.py b/src/matrixrmapi/__init__.py similarity index 58% rename from src/rmfpapi/__init__.py rename to src/matrixrmapi/__init__.py index 818940d..65c93ba 100644 --- a/src/rmfpapi/__init__.py +++ b/src/matrixrmapi/__init__.py @@ -1,3 +1,3 @@ """Matrix product RASENMAEHER integration API service""" -__version__ = "1.4.0" # NOTE Use `bump2version --config-file patch` to bump versions correctly +__version__ = "0.0.1" # NOTE Use `bump2version --config-file patch` to bump versions correctly diff --git a/src/rmfpapi/api/__init__.py b/src/matrixrmapi/api/__init__.py similarity index 100% rename from src/rmfpapi/api/__init__.py rename to src/matrixrmapi/api/__init__.py diff --git a/src/rmfpapi/api/admininfo.py b/src/matrixrmapi/api/admininfo.py similarity index 100% rename from src/rmfpapi/api/admininfo.py rename to src/matrixrmapi/api/admininfo.py diff --git a/src/rmfpapi/api/clientinfo.py b/src/matrixrmapi/api/clientinfo.py similarity index 100% rename from src/rmfpapi/api/clientinfo.py rename to src/matrixrmapi/api/clientinfo.py diff --git a/src/rmfpapi/api/description.py b/src/matrixrmapi/api/description.py similarity index 95% rename from src/rmfpapi/api/description.py rename to src/matrixrmapi/api/description.py index 0e60eaf..00c5248 100644 --- a/src/rmfpapi/api/description.py +++ b/src/matrixrmapi/api/description.py @@ -16,6 +16,7 @@ PRODUCT_SHORTNAME = "matrix" + class ProductComponent(BaseModel): # pylint: disable=too-few-public-methods """Project component info""" @@ -60,7 +61,7 @@ async def return_product_description(language: str) -> ProductDescription: shortname=PRODUCT_SHORTNAME, title="Matrix", icon=None, - description="Matrix product", + description="Matrix messaging service", language="en", ) # NOTE: Generally should return just the default language but this is for testing purposes @@ -98,9 +99,9 @@ async def return_product_description_extended(language: str) -> ProductDescripti ) return ProductDescriptionExtended( shortname=PRODUCT_SHORTNAME, - title="Matrix Product", + title="Matrix", icon=None, - description="Matrix product for integrations testing and examples", + description="Matrix messaging service", language=language, docs=docs_url, component=ProductComponent(type="markdown", ref=md_url), diff --git a/src/rmfpapi/api/healthcheck.py b/src/matrixrmapi/api/healthcheck.py similarity index 100% rename from src/rmfpapi/api/healthcheck.py rename to src/matrixrmapi/api/healthcheck.py diff --git a/src/rmfpapi/api/instructions.py b/src/matrixrmapi/api/instructions.py similarity index 100% rename from src/rmfpapi/api/instructions.py rename to src/matrixrmapi/api/instructions.py diff --git a/src/rmfpapi/api/usercrud.py b/src/matrixrmapi/api/usercrud.py similarity index 100% rename from src/rmfpapi/api/usercrud.py rename to src/matrixrmapi/api/usercrud.py diff --git a/src/rmfpapi/api/userinfo.py b/src/matrixrmapi/api/userinfo.py similarity index 100% rename from src/rmfpapi/api/userinfo.py rename to src/matrixrmapi/api/userinfo.py diff --git a/src/rmfpapi/app.py b/src/matrixrmapi/app.py similarity index 97% rename from src/rmfpapi/app.py rename to src/matrixrmapi/app.py index 6e5cca5..f2739af 100644 --- a/src/rmfpapi/app.py +++ b/src/matrixrmapi/app.py @@ -6,7 +6,7 @@ from fastapi.middleware.cors import CORSMiddleware from libpvarki.logging import init_logging -from rmfpapi import __version__ +from matrixrmapi import __version__ from .config import LOG_LEVEL, get_manifest from .api import all_routers, all_routers_v2 diff --git a/src/rmfpapi/config.py b/src/matrixrmapi/config.py similarity index 100% rename from src/rmfpapi/config.py rename to src/matrixrmapi/config.py diff --git a/src/rmfpapi/console.py b/src/matrixrmapi/console.py similarity index 91% rename from src/rmfpapi/console.py rename to src/matrixrmapi/console.py index 7949ddf..b2cfb90 100644 --- a/src/rmfpapi/console.py +++ b/src/matrixrmapi/console.py @@ -8,8 +8,8 @@ from libadvian.logging import init_logging import aiohttp -from rmfpapi import __version__ -from rmfpapi.app import get_app +from matrixrmapi import __version__ +from matrixrmapi.app import get_app LOGGER = logging.getLogger(__name__) @@ -33,7 +33,7 @@ def cli_group(ctx: click.Context, loglevel: int, verbose: int) -> None: @cli_group.command(name="healthcheck") @click.option("--host", default="localhost", help="The host to connect to") -@click.option("--port", default=8001, help="The port to connect to") +@click.option("--port", default=8012, help="The port to connect to") @click.option("--timeout", default=2.0, help="The timeout in seconds") @click.pass_context def do_http_healthcheck(ctx: click.Context, host: str, port: int, timeout: float) -> None: @@ -70,7 +70,7 @@ def dump_openapi(ctx: click.Context) -> None: ctx.exit(0) -def rmfpapi_cli() -> None: - """rmfpapi""" +def matrixrmapi_cli() -> None: + """matrixrmapi""" init_logging(logging.WARNING) cli_group() # pylint: disable=no-value-for-parameter diff --git a/src/rmfpapi/py.typed b/src/matrixrmapi/py.typed similarity index 100% rename from src/rmfpapi/py.typed rename to src/matrixrmapi/py.typed diff --git a/src/rmfpapi/templates/admininfo.html b/src/matrixrmapi/templates/admininfo.html similarity index 100% rename from src/rmfpapi/templates/admininfo.html rename to src/matrixrmapi/templates/admininfo.html diff --git a/src/rmfpapi/templates/clientinfo.html b/src/matrixrmapi/templates/clientinfo.html similarity index 100% rename from src/rmfpapi/templates/clientinfo.html rename to src/matrixrmapi/templates/clientinfo.html diff --git a/tests/conftest.py b/tests/conftest.py index 78e2bb6..64f2852 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,8 +9,8 @@ import pytest from fastapi.testclient import TestClient -from rmfpapi.app import get_app -from rmfpapi.config import get_manifest +from matrixrmapi.app import get_app +from matrixrmapi.config import get_manifest # Default is "ecs" and it's not great for tests os.environ["LOG_CONSOLE_FORMATTER"] = "local" diff --git a/tests/test_fragment.py b/tests/test_fragment.py index dcfef23..9b80e8b 100644 --- a/tests/test_fragment.py +++ b/tests/test_fragment.py @@ -7,7 +7,7 @@ from fastapi.testclient import TestClient import pytest -from rmfpapi.config import get_manifest +from matrixrmapi.config import get_manifest from .conftest import APP LOGGER = logging.getLogger(__name__) diff --git a/tests/test_rmfpapi.py b/tests/test_matrixrmapi.py similarity index 84% rename from tests/test_rmfpapi.py rename to tests/test_matrixrmapi.py index f8fb801..4afd85c 100644 --- a/tests/test_rmfpapi.py +++ b/tests/test_matrixrmapi.py @@ -1,12 +1,12 @@ """Package level tests""" from fastapi.testclient import TestClient -from rmfpapi import __version__ +from matrixrmapi import __version__ def test_version() -> None: """Make sure version matches expected""" - assert __version__ == "1.4.0" + assert __version__ == "0.0.1" def test_healthcheck(mtlsclient: TestClient) -> None: