Skip to content

Commit

Permalink
Remove PostgreSQL support since testing is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
smsearcy committed Jun 10, 2024
1 parent cf14afa commit 5309417
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 146 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@ jobs:
- "3.10"
- "3.11"

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: meshmap
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@v4
- name: Set up PDM
Expand All @@ -71,8 +58,6 @@ jobs:
pdm run pytest --cov=meshinfo
env:
MESHMAP_COLLECTOR_DATA_DIR: "."
POSTGRES_HOST: localhost
POSTGRES_PASSWORD: meshmap

docs:
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ so breaking changes are possible but will be highlighted here.
Fixed
Security

0.8.0 - Unreleased
------------------

Removed
^^^^^^^

* **BREAKING CHANGE:** Removed support for PostgreSQL.

0.7.0 - 2024-05-20
------------------

Expand Down
1 change: 0 additions & 1 deletion README.md

This file was deleted.

4 changes: 1 addition & 3 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Example
MESH_INFO_LOG_LEVEL=INFO
MESH_INFO_MAP_TILE_URL="https://tiles.stadiamaps.com/tiles/stamen_terrain/{z}/{x}/{y}{r}.png"
MESH_INFO_MAP_TILE_ATTRIBUTION='&copy; <a href="https://stadiamaps.com/" target="_blank">Stadia Maps</a> <a href="https://stamen.com/" target="_blank">&copy; Stamen Design</a> &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>'
MESH_INFO_DB_URL="postgresql+psycopg2://postgres:password@localhost:5432/postgres"
Options
Expand All @@ -47,8 +46,7 @@ MESH_INFO_COLLECTOR_WORKERS
Default is 50.

MESH_INFO_DB_URL
Override the default SQLite database by pointing to a PostgreSQL server
(or changing the default location).
Change location of the SQLite database.
Default is SQLite database ``mesh-info.db`` in the data directory.

MESH_INFO_ENVIRONMENT
Expand Down
22 changes: 8 additions & 14 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,16 @@ For starters, you will need:

* Python 3.9 or greater, with the "dev" or "devel" libraries
* RRDtool libraries (``librrd-dev`` on Debian/Ubuntu or ``rrdtool-devel`` on Fedora).
* PostgreSQL libraries (``libpq-dev`` on Debian/Ubuntu or ``libpq-devel`` on Fedora).
* Fork/clone the Git repository using your preferred tool.
* `PDM <https://pdm-project.org/en/stable/>`_ to manage the Python environment.
* Fork/clone the Git repository using your preferred tool and ``cd`` to the repository.

Then, setup the Python virtual environment:
Then, setup the Python virtual environment and activate it:

.. code-block:: console
$ cd mesh-info
$ python3 -m venv venv
$ . ./venv/bin/activate
(venv) $ pip install -U pip wheel
(venv) $ pip install -r requirements.txt -e .[dev]
(venv) $ make migrate-db
pdm install
make migrate-db
. ./venv/bin/activate
Create a ``.env`` file in the ``mesh-info`` folder and add:

Expand All @@ -58,7 +55,7 @@ Run the development web server via:

.. code-block:: console
(venv) $ ./dev-web.sh
./dev-web.sh
Connect to the server at http://localhost:8000.

Expand All @@ -73,7 +70,7 @@ make pre-commit
Runs `pre-commit <https://pre-commit.com/>`_ to check/format files.

make lint
Runs `Flake8 <https://flake8.pycqa.org/en/latest/index.html>`_ to do static linting.
Runs `Ruff <https://docs.astral.sh/ruff/>`_ to do static linting.

make mypy
Run `mypy <http://mypy-lang.org/>`_ static type checker.
Expand All @@ -94,9 +91,6 @@ make make-migration
make migrate-db
Apply `Alembic <https://alembic.sqlalchemy.org/>`_ database migrations.

make requirements
Generate requirements files via `pip-tools <https://pypi.org/project/pip-tools/>`_.


Architecture
------------
Expand Down
5 changes: 2 additions & 3 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Installation
============

Mesh Info requires Python 3.9+, RRDtool, and PostgreSQL libraries
(although it defaults to using SQLite).
Mesh Info requires Python 3.9+ and RRDtool libraries.
The following instructions include installing those dependencies.

Installation instructions for Raspberry Pi OS
Expand All @@ -20,7 +19,7 @@ and create ``/var/lib/mesh-info`` for storing the application data.
.. code-block:: console
sudo apt update
sudo apt install -y git libpq-dev librrd-dev python3 python3-dev python3-pip python3-venv rrdtool
sudo apt install -y git librrd-dev python3 python3-dev python3-pip python3-venv rrdtool
sudo useradd meshinfo
sudo mkdir /opt/mesh-info /var/lib/mesh-info
sudo chown meshinfo: /opt/mesh-info /var/lib/mesh-info
Expand Down
78 changes: 1 addition & 77 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ dependencies = [
"gunicorn ~= 22.0",
"pendulum ~= 2.1",
"platformdirs ~= 2.0",
"psycopg2 ~= 2.9",
"pyramid ~= 2.0",
"pyramid-jinja2 ~= 2.10",
"pyramid-retry ~= 2.1",
Expand Down Expand Up @@ -75,7 +74,6 @@ testing = [
"pytest-asyncio>=0.23.7",
"pytest-cov>=5.0.0",
"pytest-mock>=3.14.0",
"pytest-postgresql < 4.0",
"pytest>=8.2.1",
]
dev = [
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pendulum==2.1.2
plaster==1.1.2
plaster-pastedeploy==1.0.1
platformdirs==2.6.2
psycopg2==2.9.9
pygments==2.18.0
pyramid==2.0.2
pyramid-jinja2==2.10.1
Expand Down
33 changes: 3 additions & 30 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,12 @@
import webtest
from pyramid.scripting import prepare
from pyramid.testing import DummyRequest, testConfig
from pytest_postgresql import factories
from sqlalchemy import create_engine

from meshinfo import models
from meshinfo.config import AppConfig, configure
from meshinfo.models.meta import Base

if os.environ.get("CI"):
postgresql_ci = factories.postgresql_noproc(
# needs to match service in .gitlab-ci.yml
host=os.environ.get("POSTGRES_HOST", "postgres"),
user=os.environ.get("POSTGRES_USER", "postgres"),
password=os.environ.get("POSTGRES_PASSWORD", ""),
dbname=os.environ.get("POSTGRES_DB", "postgres"),
)
else:
postgresql_local = factories.postgresql("postgresql_proc")


@pytest.fixture(scope="module")
def data_folder() -> Path:
Expand All @@ -41,25 +29,10 @@ def app_config():
return AppConfig.from_environ(env)


@pytest.fixture(params=("sqlite", "postgres"))
@pytest.fixture
def dbengine(request, tmp_path):
if request.param == "sqlite":
sqlite_file = tmp_path / "testing.sqlite"
db_url = f"sqlite:///{sqlite_file!s}"
elif request.param == "postgres":
if os.environ.get("CI"):
dbinfo = request.getfixturevalue("postgresql_ci")
else:
postgresql = request.getfixturevalue("postgresql_local")
dbinfo = postgresql.info
user = dbinfo.user
password = dbinfo.password
host = dbinfo.host
port = dbinfo.port
dbname = dbinfo.dbname
db_url = f"postgresql+psycopg2://{user}:{password}@{host}:{port}/{dbname}"
else:
raise ValueError(f"Unknown param: {request.param!r}")
sqlite_file = tmp_path / "testing.sqlite"
db_url = f"sqlite:///{sqlite_file!s}"

alembic_cfg = alembic.config.Config("alembic.ini")
engine = create_engine(db_url)
Expand Down

0 comments on commit 5309417

Please sign in to comment.