From f383c9de83716f5fb61e1f49a0204508f2bbcb2d Mon Sep 17 00:00:00 2001
From: Rambaud Pierrick <12rambau@users.noreply.github.com>
Date: Tue, 17 Sep 2024 08:16:51 +0000
Subject: [PATCH] test: test older version of sqlalchemy

---
 .devcontainer/devcontainer.json |  3 ++-
 .github/workflows/unit.yaml     |  7 ++++++-
 noxfile.py                      | 10 +++++++---
 pyproject.toml                  |  8 ++------
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 56910d3..1a7e7c6 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -5,5 +5,6 @@
     "ghcr.io/devcontainers-contrib/features/nox:2": {},
     "ghcr.io/devcontainers-contrib/features/pre-commit:2": {}
   },
-  "postCreateCommand": "pre-commit install"
+  "postCreateCommand": "sudo apt-get install graphviz graphviz-dev",
+  "postStartCommand": "pre-commit install"
 }
diff --git a/.github/workflows/unit.yaml b/.github/workflows/unit.yaml
index 88addbf..afa0213 100644
--- a/.github/workflows/unit.yaml
+++ b/.github/workflows/unit.yaml
@@ -35,6 +35,11 @@ jobs:
     strategy:
       matrix:
         python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
+        sqlachemy-version: [""]
+        include:
+          # oldest python/sqlalchemy supported
+          python-version: "3.8"
+          sqlalchemy-version: "1.4"
     services:
       eralchemy-db:
         image: postgres:alpine
@@ -66,7 +71,7 @@ jobs:
       - name: Install nox
         run: pip install nox
       - name: Test with pytest
-        run: nox -s ci_test
+        run: nox -s ci_test -- ${{ matrix.sqlalchemy-version }}
       - uses: actions/upload-artifact@v4
         if: ${{ matrix.python-version == '3.10' }}
         with:
diff --git a/noxfile.py b/noxfile.py
index 1bf8126..57a6075 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -25,10 +25,14 @@ def docs(session):
 
 @nox.session(reuse_venv=True)
 def ci_test(session):
-    """Run the tests report coverage in xml format."""
+    """Run the tests report coverage in xml format.
+
+    This is used by the CI and can update the version of sqlalchemy with the posargs.
+    """
     session.install(".[test]")
-    test_files = session.posargs or ["tests"]
-    session.run("pytest", "--color=yes", "--cov", "--cov-report=xml", *test_files)
+    version = f"=={session.posargs[0]}" if session.posargs else ""
+    session.install(f"sqlalchemy{version}")
+    session.run("pytest", "--color=yes", "--cov", "--cov-report=xml", "tests")
 
 
 @nox.session(reuse_venv=True)
diff --git a/pyproject.toml b/pyproject.toml
index ef3f1cc..bdad3cc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -39,15 +39,11 @@ test = [
   "psycopg2 >= 2.9.3",
   "pytest >= 7.4.3",
   "pytest-cov",
-graphviz = ["graphviz >= 0.20.3"]
-pygraphviz = ["pygraphviz >= 1.9"]
-ci = [
-  "flask-sqlalchemy >= 2.5.1",
-  "psycopg2 >= 2.9.3",
-  "pytest >= 7.4.3",
   "pygraphviz >= 1.9",
   "graphviz >= 0.20.3",
 ]
+graphviz = ["graphviz >= 0.20.3"]
+pygraphviz = ["pygraphviz >= 1.9"]
 dev = [
   "nox",
   "pre-commit"
-- 
GitLab