Spaces:
Sleeping

Daniel McKnight commited on
Commit
92ac338
·
unverified ·
1 Parent(s): 44797d1

Add versioning automation (#47)

Browse files

* Cursor-implemented solution to the open issue

* Refactor to remove `setup.py` added just for checking version

* Clean up Cursor-generated tests

* Refactor module patching to prevent changing sys.modules for other tests

* Work with Cursor to refactor version test cases

* Refactor test config patching by Cursor

* Remove extra `setuptools` installation from Release GHA

.github/workflows/propose_release.yml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Propose Stable Release
2
+ on:
3
+ workflow_dispatch:
4
+ inputs:
5
+ release_type:
6
+ type: choice
7
+ description: Release Type
8
+ options:
9
+ - patch
10
+ - minor
11
+ - major
12
+ jobs:
13
+ update_version:
14
+ uses: neongeckocom/.github/.github/workflows/propose_semver_release.yml@master
15
+ with:
16
+ branch: dev
17
+ release_type: ${{ inputs.release_type }}
18
+ update_changelog: True
19
+ version_file: "multi_llm_chatbot_backend/app/version.py"
20
+ pull_changes:
21
+ uses: neongeckocom/.github/.github/workflows/pull_master.yml@master
22
+ needs: update_version
23
+ with:
24
+ pr_reviewer: neonreviewers
25
+ pr_assignee: ${{ github.actor }}
26
+ pr_draft: false
27
+ pr_title: ${{ needs.update_version.outputs.version }}
28
+ pr_body: ${{ needs.update_version.outputs.changelog }}
29
+ destination: main
.github/workflows/publish_release.yml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # On every push to `main` (which happens when a release PR produced by
2
+ # Propose Stable Release is merged), read the current version and create a
3
+ # matching GitHub release. Docker image publishing is intentionally left
4
+ # out for now and can be added separately.
5
+
6
+ name: Publish GitHub Release
7
+ on:
8
+ push:
9
+ branches:
10
+ - main
11
+
12
+ jobs:
13
+ tag_release:
14
+ runs-on: ubuntu-latest
15
+ permissions:
16
+ contents: write
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.11"
23
+ - name: Get Version
24
+ run: |
25
+ VERSION=$(python multi_llm_chatbot_backend/app/version.py)
26
+ echo "VERSION=${VERSION}" >> $GITHUB_ENV
27
+ - uses: ncipollo/release-action@v1
28
+ with:
29
+ token: ${{ secrets.GITHUB_TOKEN }}
30
+ tag: ${{ env.VERSION }}
31
+ generateReleaseNotes: true
.github/workflows/publish_test_build.yml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Bumps the alpha suffix on every push to `dev` (except when the only
2
+ # change is to the version file itself, to prevent a publish loop). A
3
+ # GitHub prerelease is cut for each alpha so artifacts are easy to find.
4
+ # This project is not distributed via PyPI, so `publish_pypi` is disabled.
5
+
6
+ name: Publish Alpha Build
7
+ on:
8
+ push:
9
+ branches:
10
+ - dev
11
+ paths-ignore:
12
+ - 'multi_llm_chatbot_backend/app/version.py'
13
+ - 'CHANGELOG.md'
14
+
15
+ jobs:
16
+ publish_alpha_release:
17
+ uses: neongeckocom/.github/.github/workflows/publish_alpha_release.yml@master
18
+ secrets: inherit
19
+ with:
20
+ version_file: "multi_llm_chatbot_backend/app/version.py"
21
+ setup_py: "multi_llm_chatbot_backend/app/version.py"
22
+ publish_prerelease: true
23
+ publish_pypi: false
24
+ update_changelog: true
CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Changelog
2
+
3
+ All notable changes to CCAI-Demo are tracked here. Entries prior to the
4
+ first release were not formally logged; version history starts with the
5
+ initial pre-release under the automated release pipeline.
multi_llm_chatbot_backend/app/api/old_routes.py CHANGED
@@ -21,6 +21,7 @@ from app.utils.file_export import export_chat_as_file
21
 
22
  from app.utils.chat_summary import generate_summary_from_messages, parse_summary_to_blocks
23
  from app.utils.file_export import prepare_export_response, generate_pdf_file_from_blocks
 
24
 
25
  import hashlib
26
  import logging
@@ -989,7 +990,7 @@ def root():
989
  """Root endpoint - SAME INTERFACE with updated info"""
990
  return {
991
  "message": "Multi-LLM PhD Advisor Backend is up and running",
992
- "version": "1.0.0", # Updated version
993
  "features": [
994
  "Improved Session Management",
995
  "Unified Context Handling",
 
21
 
22
  from app.utils.chat_summary import generate_summary_from_messages, parse_summary_to_blocks
23
  from app.utils.file_export import prepare_export_response, generate_pdf_file_from_blocks
24
+ from app.version import __version__
25
 
26
  import hashlib
27
  import logging
 
990
  """Root endpoint - SAME INTERFACE with updated info"""
991
  return {
992
  "message": "Multi-LLM PhD Advisor Backend is up and running",
993
+ "version": __version__,
994
  "features": [
995
  "Improved Session Management",
996
  "Unified Context Handling",
multi_llm_chatbot_backend/app/api/routes/root.py CHANGED
@@ -1,5 +1,6 @@
1
  from fastapi import APIRouter
2
  from app.config import get_settings
 
3
 
4
  import logging
5
 
@@ -12,7 +13,7 @@ def root():
12
  title = get_settings().app.title
13
  return {
14
  "message": f"{title} Backend is up and running",
15
- "version": "1.0.0",
16
  "features": [
17
  "Configurable Personas",
18
  "Improved Session Management",
 
1
  from fastapi import APIRouter
2
  from app.config import get_settings
3
+ from app.version import __version__
4
 
5
  import logging
6
 
 
13
  title = get_settings().app.title
14
  return {
15
  "message": f"{title} Backend is up and running",
16
+ "version": __version__,
17
  "features": [
18
  "Configurable Personas",
19
  "Improved Session Management",
multi_llm_chatbot_backend/app/config.py CHANGED
@@ -19,6 +19,7 @@ import yaml
19
  from pydantic import BaseModel, validator, Field, model_validator
20
 
21
  from app.utils.avatar_helpers import get_bundled_avatar_path
 
22
 
23
  logger = logging.getLogger(__name__)
24
 
@@ -328,6 +329,7 @@ class AppSettings(BaseModel):
328
  "personas": {
329
  "items": [p.to_frontend_config() for p in self.personas.items],
330
  },
 
331
  }
332
 
333
 
 
19
  from pydantic import BaseModel, validator, Field, model_validator
20
 
21
  from app.utils.avatar_helpers import get_bundled_avatar_path
22
+ from app.version import __version__
23
 
24
  logger = logging.getLogger(__name__)
25
 
 
329
  "personas": {
330
  "items": [p.to_frontend_config() for p in self.personas.items],
331
  },
332
+ "version": __version__,
333
  }
334
 
335
 
multi_llm_chatbot_backend/app/main.py CHANGED
@@ -12,6 +12,7 @@ from contextlib import asynccontextmanager
12
 
13
  # Load configuration FIRST so every module can use it
14
  from app.config import load_settings
 
15
  settings = load_settings()
16
 
17
  # Import the new database functions
@@ -40,7 +41,7 @@ async def lifespan(app: FastAPI):
40
 
41
  app = FastAPI(
42
  title=f"{settings.app.title} Backend",
43
- version="2.0.0",
44
  lifespan=lifespan
45
  )
46
 
@@ -83,7 +84,7 @@ def get_public_config():
83
  def root():
84
  return {
85
  "message": f"{settings.app.title} Backend",
86
- "version": "2.0.0",
87
  "features": [
88
  "User Authentication",
89
  "Persistent Chat Sessions",
 
12
 
13
  # Load configuration FIRST so every module can use it
14
  from app.config import load_settings
15
+ from app.version import __version__
16
  settings = load_settings()
17
 
18
  # Import the new database functions
 
41
 
42
  app = FastAPI(
43
  title=f"{settings.app.title} Backend",
44
+ version=__version__,
45
  lifespan=lifespan
46
  )
47
 
 
84
  def root():
85
  return {
86
  "message": f"{settings.app.title} Backend",
87
+ "version": __version__,
88
  "features": [
89
  "User Authentication",
90
  "Persistent Chat Sessions",
multi_llm_chatbot_backend/app/tests/unit/conftest.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Session-wide stubs for modules that do heavy work at import time.
2
+
3
+ ``app.api.routes.__init__`` eagerly imports every sibling route, and
4
+ ``app.api.routes.provider`` instantiates real LLM clients at module
5
+ load. ``app.core.bootstrap`` and ``app.core.rag_manager`` likewise
6
+ start NLTK, ChromaDB, and the LLM stack the moment they are imported.
7
+
8
+ We install harmless ``MagicMock`` substitutes for those modules once,
9
+ before any test file in this directory is collected, so every test
10
+ gets a consistent, importable view of ``app.api.routes`` without
11
+ having to reproduce the same stubbing recipe in every test module.
12
+
13
+ Tests that want to exercise the real version of a specific route
14
+ module (for example, ``test_version.py`` wanting the real
15
+ ``app.api.routes.root``) can still pop their target out of
16
+ ``sys.modules`` in their own setup -- they no longer have to
17
+ coordinate cleanup with peer test modules.
18
+ """
19
+
20
+ import sys
21
+ from unittest.mock import MagicMock
22
+
23
+ from fastapi import APIRouter
24
+
25
+
26
+ for _name in ("app.core.bootstrap", "app.core.rag_manager"):
27
+ sys.modules.setdefault(_name, MagicMock())
28
+
29
+ _stub_router_module = MagicMock(router=APIRouter())
30
+ for _name in (
31
+ "app.api.routes.chat",
32
+ "app.api.routes.documents",
33
+ "app.api.routes.sessions",
34
+ "app.api.routes.provider",
35
+ "app.api.routes.debug",
36
+ "app.api.routes.phd_canvas",
37
+ ):
38
+ sys.modules.setdefault(_name, _stub_router_module)
multi_llm_chatbot_backend/app/tests/unit/test_account_management.py CHANGED
@@ -1,33 +1,15 @@
1
  import asyncio
2
- import sys
3
  import unittest
4
  from datetime import datetime
5
  from unittest.mock import AsyncMock, MagicMock, patch
6
 
7
  from bson import ObjectId
8
- from fastapi import APIRouter, HTTPException
9
  from pydantic import ValidationError
10
 
11
- # app.api.routes.__init__ eagerly imports and wires routers from every
12
- # sibling route module, several of which spin up the LLM stack, NLTK
13
- # downloads, and ChromaDB at import time. Stub those heavy modules with
14
- # harmless substitutes so the package imports cleanly and auth.py can
15
- # be loaded via normal import machinery.
16
- for _name in ("app.core.bootstrap", "app.core.rag_manager"):
17
- sys.modules.setdefault(_name, MagicMock())
18
-
19
- _stub_router_module = MagicMock(router=APIRouter())
20
- for _name in (
21
- "app.api.routes.chat",
22
- "app.api.routes.documents",
23
- "app.api.routes.sessions",
24
- "app.api.routes.provider",
25
- "app.api.routes.debug",
26
- "app.api.routes.root",
27
- "app.api.routes.phd_canvas",
28
- ):
29
- sys.modules.setdefault(_name, _stub_router_module)
30
-
31
  from app.api.routes.auth import ( # noqa: E402
32
  ChangePasswordRequest,
33
  DeleteAccountRequest,
@@ -38,6 +20,7 @@ from app.api.routes.auth import ( # noqa: E402
38
  )
39
  from app.models.user import User # noqa: E402
40
 
 
41
  FAKE_USER_ID = ObjectId()
42
 
43
 
 
1
  import asyncio
 
2
  import unittest
3
  from datetime import datetime
4
  from unittest.mock import AsyncMock, MagicMock, patch
5
 
6
  from bson import ObjectId
7
+ from fastapi import HTTPException
8
  from pydantic import ValidationError
9
 
10
+ # Heavy modules pulled in transitively by ``app.api.routes.auth`` are
11
+ # stubbed once for the whole test session in ``conftest.py``; the import
12
+ # below relies on those stubs already being in place.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  from app.api.routes.auth import ( # noqa: E402
14
  ChangePasswordRequest,
15
  DeleteAccountRequest,
 
20
  )
21
  from app.models.user import User # noqa: E402
22
 
23
+
24
  FAKE_USER_ID = ObjectId()
25
 
26
 
multi_llm_chatbot_backend/app/tests/unit/test_chat_sessions.py CHANGED
@@ -1,27 +1,14 @@
1
  import asyncio
2
- import sys
3
  import unittest
4
  from datetime import datetime
5
  from unittest.mock import AsyncMock, MagicMock, patch, call
6
 
7
  from bson import ObjectId
8
- from fastapi import APIRouter, HTTPException
9
-
10
- for _name in ("app.core.bootstrap", "app.core.rag_manager"):
11
- sys.modules.setdefault(_name, MagicMock())
12
-
13
- _stub_router_module = MagicMock(router=APIRouter())
14
- for _name in (
15
- "app.api.routes.chat",
16
- "app.api.routes.documents",
17
- "app.api.routes.sessions",
18
- "app.api.routes.provider",
19
- "app.api.routes.debug",
20
- "app.api.routes.root",
21
- "app.api.routes.phd_canvas",
22
- ):
23
- sys.modules.setdefault(_name, _stub_router_module)
24
 
 
 
 
25
  from app.api.routes.chat_sessions import ( # noqa: E402
26
  CreateChatSessionRequest,
27
  UpdateChatSessionRequest,
 
1
  import asyncio
 
2
  import unittest
3
  from datetime import datetime
4
  from unittest.mock import AsyncMock, MagicMock, patch, call
5
 
6
  from bson import ObjectId
7
+ from fastapi import HTTPException
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ # Heavy modules pulled in transitively by ``app.api.routes.chat_sessions``
10
+ # are stubbed once for the whole test session in ``conftest.py``; the
11
+ # import below relies on those stubs already being in place.
12
  from app.api.routes.chat_sessions import ( # noqa: E402
13
  CreateChatSessionRequest,
14
  UpdateChatSessionRequest,
multi_llm_chatbot_backend/app/tests/unit/test_version.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Sanity checks for the centralized ``__version__`` string.
2
+
3
+ Guards against regressions where the release automation assumes it can
4
+ locate and parse ``app/version.py``.
5
+ """
6
+
7
+ import re
8
+ import unittest
9
+
10
+ from app.api.routes.root import root
11
+ from app.version import __version__
12
+
13
+
14
+ VERSION_REGEX = re.compile(r"^\d+\.\d+\.\d+([a-zA-Z0-9.\-+]*)?$")
15
+
16
+
17
+ class TestVersion(unittest.TestCase):
18
+
19
+ def test_version_string_is_importable_and_well_formed(self):
20
+ self.assertIsInstance(__version__, str)
21
+ self.assertTrue(__version__)
22
+ self.assertRegex(
23
+ __version__,
24
+ VERSION_REGEX,
25
+ f"Unexpected version format: {__version__!r}",
26
+ )
27
+
28
+
29
+ class TestRootEndpointVersion(unittest.TestCase):
30
+ """The ``/`` handler should surface the same version we imported
31
+ from ``app.version``.
32
+
33
+ ``app.api.routes.__init__`` eagerly imports every sibling route
34
+ module; the heavy ones are replaced with ``MagicMock`` stubs once,
35
+ session-wide, in ``conftest.py`` so ``root.py`` can be loaded via
36
+ normal import machinery.
37
+ """
38
+
39
+ def test_root_endpoint_exposes_imported_version(self):
40
+ payload = root()
41
+ self.assertEqual(payload["version"], __version__)
multi_llm_chatbot_backend/app/tests/unit/test_voice_status.py CHANGED
@@ -1,34 +1,14 @@
1
  import asyncio
2
- import sys
3
  import unittest
4
  from datetime import datetime
5
  from unittest.mock import AsyncMock, MagicMock, patch
6
 
7
  import httpx
8
  from bson import ObjectId
9
- from fastapi import APIRouter
10
-
11
- # app.api.routes.__init__ eagerly imports and wires routers from every
12
- # sibling route module, several of which spin up the LLM stack, NLTK
13
- # downloads, and ChromaDB at import time. Stub those heavy modules with
14
- # harmless substitutes so app.api.routes.voice can be imported via normal
15
- # import machinery.
16
- for _name in ("app.core.bootstrap", "app.core.rag_manager"):
17
- sys.modules.setdefault(_name, MagicMock())
18
-
19
- _stub_router_module = MagicMock(router=APIRouter())
20
- for _name in (
21
- "app.api.routes.chat",
22
- "app.api.routes.documents",
23
- "app.api.routes.sessions",
24
- "app.api.routes.provider",
25
- "app.api.routes.debug",
26
- "app.api.routes.root",
27
- "app.api.routes.phd_canvas",
28
- "app.api.routes.auth",
29
- ):
30
- sys.modules.setdefault(_name, _stub_router_module)
31
 
 
 
 
32
  from app.api.routes.voice import voice_status # noqa: E402
33
  from app.models.user import User # noqa: E402
34
 
 
1
  import asyncio
 
2
  import unittest
3
  from datetime import datetime
4
  from unittest.mock import AsyncMock, MagicMock, patch
5
 
6
  import httpx
7
  from bson import ObjectId
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ # Heavy modules pulled in transitively by ``app.api.routes.voice`` are
10
+ # stubbed once for the whole test session in ``conftest.py``; the import
11
+ # below relies on those stubs already being in place.
12
  from app.api.routes.voice import voice_status # noqa: E402
13
  from app.models.user import User # noqa: E402
14
 
multi_llm_chatbot_backend/app/version.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ __version__ = "2.0.1a1"
2
+
3
+ if __name__ == "__main__":
4
+ print(__version__)
phd-advisor-frontend/src/components/Sidebar.js CHANGED
@@ -36,6 +36,7 @@ const Sidebar = ({
36
  }) => {
37
  const { config } = useAppConfig();
38
  const canvasLabel = config?.app?.title ? `${config.app.title} Canvas` : 'Canvas';
 
39
  const [chatSessions, setChatSessions] = useState([]);
40
  const [searchTerm, setSearchTerm] = useState('');
41
  const [isLoading, setIsLoading] = useState(true);
@@ -398,6 +399,14 @@ const Sidebar = ({
398
  )}
399
  </div>
400
 
 
 
 
 
 
 
 
 
401
  {/* Footer */}
402
  <div className={`sidebar-footer ${isCollapsed ? 'collapsed' : ''}`}>
403
  <a
@@ -444,4 +453,4 @@ const Sidebar = ({
444
  );
445
  };
446
 
447
- export default Sidebar;
 
36
  }) => {
37
  const { config } = useAppConfig();
38
  const canvasLabel = config?.app?.title ? `${config.app.title} Canvas` : 'Canvas';
39
+ const appVersion = config?.version;
40
  const [chatSessions, setChatSessions] = useState([]);
41
  const [searchTerm, setSearchTerm] = useState('');
42
  const [isLoading, setIsLoading] = useState(true);
 
399
  )}
400
  </div>
401
 
402
+ {appVersion && (
403
+ <div
404
+ className="sidebar-version"
405
+ title={`Version ${appVersion}`}
406
+ >
407
+ {isCollapsed ? `v${appVersion}` : `Version ${appVersion}`}
408
+ </div>
409
+ )}
410
  {/* Footer */}
411
  <div className={`sidebar-footer ${isCollapsed ? 'collapsed' : ''}`}>
412
  <a
 
453
  );
454
  };
455
 
456
+ export default Sidebar;
phd-advisor-frontend/src/styles/Sidebar.css CHANGED
@@ -902,4 +902,24 @@
902
  .mobile-sidebar-overlay.visible {
903
  display: block;
904
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
905
  }
 
902
  .mobile-sidebar-overlay.visible {
903
  display: block;
904
  }
905
+ }
906
+
907
+ .sidebar-version {
908
+ padding: 8px 16px;
909
+ border-top: 1px solid var(--border-light, #e5e7eb);
910
+ font-size: 11px;
911
+ color: var(--text-secondary, #6b7280);
912
+ text-align: center;
913
+ user-select: none;
914
+ flex-shrink: 0;
915
+ }
916
+
917
+ .sidebar.collapsed .sidebar-version {
918
+ padding: 8px 4px;
919
+ font-size: 10px;
920
+ }
921
+
922
+ .dark .sidebar-version {
923
+ border-top-color: var(--border-dark, #374151);
924
+ color: var(--text-secondary-dark, #9ca3af);
925
  }