Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[bumpversion]
current_version = 1.4.0
current_version = 0.0.1
commit = False
tag = False

[bumpversion:file:pyproject.toml]
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}"
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
- uses: pvarki/ci@main
with:
dockerfile-target: devel_shell
image-tag: rmfpapi:devel_shell
image-tag: matrixrmapi:devel_shell
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -34,46 +34,46 @@ 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
^^^^^^^^^^^^^^^^^^^^^^^^^

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
^^^^^^^^^^

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
^^^^^^^^^^^^^^^^^

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
-----------
Expand Down
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <eero.afheurlin@iki.fi>"]
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"



Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/rmfpapi/__init__.py → src/matrixrmapi/__init__.py
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

PRODUCT_SHORTNAME = "matrix"


class ProductComponent(BaseModel): # pylint: disable=too-few-public-methods
"""Project component info"""

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/rmfpapi/app.py → src/matrixrmapi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/rmfpapi/console.py → src/matrixrmapi/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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:
Expand Down Expand Up @@ -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
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rmfpapi.py → tests/test_matrixrmapi.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down