sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #05372
[Merge] ~thorsten-merten/maas-site-manager:MAASENG-1285-monorepo into maas-site-manager:main
Thorsten Merten has proposed merging ~thorsten-merten/maas-site-manager:MAASENG-1285-monorepo into maas-site-manager:main.
Commit message:
chore: move everything to backend dir to prepare mono repo
We will soon merge the frontend and agent into this codebase
to the backend has to make room.
Crossing fingers CI will agree to the cd backend && <run tox> idea
Requested reviews:
MAAS Lander (maas-lander): unittests
MAAS Committers (maas-committers)
For more details, see:
https://code.launchpad.net/~thorsten-merten/maas-site-manager/+git/maas-site-manager/+merge/437893
--
Your team MAAS Committers is requested to review the proposed merge of ~thorsten-merten/maas-site-manager:MAASENG-1285-monorepo into maas-site-manager:main.
diff --git a/Makefile b/Makefile
index c38c841..2e6b244 100644
--- a/Makefile
+++ b/Makefile
@@ -1,27 +1,76 @@
-define PACKAGES
+define BACKEND_PACKAGES
python3-venv \
python3-dev \
tox \
postgresql
endef
-install-dependencies:
- sudo -E DEBIAN_FRONTEND=noninteractive apt -y install $(PACKAGES)
+define FRONTEND_PACKAGES
+yarnpkg
+endef
+
+
+# Dependencies
+
+install-dependencies: install-backend-dependencies install-frontend-dependencies
.PHONY: install-dependencies
+install-backend-dependencies:
+ sudo -E DEBIAN_FRONTEND=noninteractive apt -y install $(BACKEND_PACKAGES)
+.PHONY: install-backend-dependencies
+
+install-frontend-dependencies:
+ sudo -E DEBIAN_FRONTEND=noninteractive apt -y install $(FRONTEND_PACKAGES)
+.PHONY: install-frontend-dependencies
+
-# CI targets
+# Overall CI targets
-ci-dep: install-dependencies
+ci-dep: ci-backend-dep
.PHONY: ci-dep
-ci-build: # nothing to do since everything is run in tox envs
+ci-build: # will run the frontend build targets
.PHONY: ci-build
-ci-lint:
- tox -e lint,check
+ci-lint: ci-backend-lint
.PHONY: ci-lint
-ci-test:
- tox -e test
+ci-test: ci-backend-test
.PHONY: ci-test
+
+
+# Backend CI targets
+
+ci-backend-dep: install-backend-dependencies
+.PHONY: ci-backend-dep
+
+ci-backend-build: # nothing to do since everything is run in tox envs
+.PHONY: ci-backend-build
+
+ci-backend-lint:
+ cd backend && tox -e lint,check
+.PHONY: ci-backend-lint
+
+ci-backend-test:
+ cd backend && tox -e test
+.PHONY: ci-test
+
+
+# Frontend CI targets
+
+ci-frontend-dep: install-frontend-dependencies
+ cd frontend && yarnpkg install
+.PHONY: ci-frontend-dep
+
+ci-frontend-build: # nothing to do since everything is run in tox envs
+ cd frontend && yarnpkg run build
+.PHONY: ci-frontend-build
+
+ci-frontend-lint:
+ # see 1398-setup-frontend-linting: cd frontend && yarnpkg run lint
+.PHONY: ci-frontend-lint
+
+ci-frontend-test:
+ cd frontend && yarnpkg run test -- --silent run
+.PHONY: ci-test
+
diff --git a/README.md b/backend/README.md
similarity index 100%
rename from README.md
rename to backend/README.md
diff --git a/msm/__init__.py b/backend/msm/__init__.py
similarity index 100%
rename from msm/__init__.py
rename to backend/msm/__init__.py
diff --git a/msm/conftest.py b/backend/msm/conftest.py
similarity index 100%
rename from msm/conftest.py
rename to backend/msm/conftest.py
diff --git a/msm/db/__init__.py b/backend/msm/db/__init__.py
similarity index 100%
rename from msm/db/__init__.py
rename to backend/msm/db/__init__.py
diff --git a/msm/db/_session.py b/backend/msm/db/_session.py
similarity index 100%
rename from msm/db/_session.py
rename to backend/msm/db/_session.py
diff --git a/msm/db/_setup.py b/backend/msm/db/_setup.py
similarity index 100%
rename from msm/db/_setup.py
rename to backend/msm/db/_setup.py
diff --git a/msm/db/_tables.py b/backend/msm/db/_tables.py
similarity index 100%
rename from msm/db/_tables.py
rename to backend/msm/db/_tables.py
diff --git a/msm/db/queries.py b/backend/msm/db/queries.py
similarity index 100%
rename from msm/db/queries.py
rename to backend/msm/db/queries.py
diff --git a/msm/testing/__init__.py b/backend/msm/testing/__init__.py
similarity index 100%
rename from msm/testing/__init__.py
rename to backend/msm/testing/__init__.py
diff --git a/msm/testing/app.py b/backend/msm/testing/app.py
similarity index 100%
rename from msm/testing/app.py
rename to backend/msm/testing/app.py
diff --git a/msm/testing/db.py b/backend/msm/testing/db.py
similarity index 100%
rename from msm/testing/db.py
rename to backend/msm/testing/db.py
diff --git a/msm/user_api/__init__.py b/backend/msm/user_api/__init__.py
similarity index 100%
rename from msm/user_api/__init__.py
rename to backend/msm/user_api/__init__.py
diff --git a/msm/user_api/_base.py b/backend/msm/user_api/_base.py
similarity index 100%
rename from msm/user_api/_base.py
rename to backend/msm/user_api/_base.py
diff --git a/backend/msm/user_api/_schema.py b/backend/msm/user_api/_schema.py
new file mode 100644
index 0000000..38a4ad5
--- /dev/null
+++ b/backend/msm/user_api/_schema.py
@@ -0,0 +1,101 @@
+from datetime import (
+ datetime,
+ timedelta,
+)
+from uuid import UUID
+
+from pydantic import BaseModel
+
+
+class CreateSite(BaseModel):
+ """
+ A MAAS installation
+ """
+
+ name: str
+ identifier: str
+ city: str | None
+ latitude: str | None
+ longitude: str | None
+ note: str | None
+ region: str | None
+ street: str | None
+ timezone: str | None
+ url: str
+ # TODO: we will need to add tags
+
+
+class Site(CreateSite):
+ """
+ Site persisted to the database
+ """
+
+ id: int
+
+
+class CreateSiteData(BaseModel):
+ """
+ All SiteData is obligatory
+ """
+
+ site_id: int
+ total_machines: int
+ # TODO: might include more states in future
+ occupied_machines: int # TODO: name might change
+ ready_machines: int
+ error_machines: int
+ last_seen: datetime
+
+
+class SiteData(CreateSiteData):
+ """
+ SiteData persisted to the database
+ """
+
+ id: int
+
+
+class SiteWithData(Site):
+
+ """
+ A site, together with its SiteData
+ """
+
+ id: int
+ site_data: SiteData
+
+
+class CreateToken(BaseModel):
+ """
+ To create a token a value and an expiration
+ time need to be generated
+ """
+
+ site_id: int | None
+ value: UUID
+ expiration: datetime
+
+
+class Token(CreateToken):
+ """
+ A token persisted to the database
+ """
+
+ id: int
+
+
+class CreateTokensRequest(BaseModel):
+ """
+ Request to create one or more tokens, with a certain validity,
+ expressed in seconds.
+ """
+
+ count: int = 1
+ duration: timedelta
+
+
+class CreateTokensResponse(BaseModel):
+ """List of created tokens, along with their duration."""
+
+ expiration: datetime
+ tokens: list[UUID]
diff --git a/msm/user_api/_setup.py b/backend/msm/user_api/_setup.py
similarity index 100%
rename from msm/user_api/_setup.py
rename to backend/msm/user_api/_setup.py
diff --git a/msm/user_api/tests/__init__.py b/backend/msm/user_api/tests/__init__.py
similarity index 100%
rename from msm/user_api/tests/__init__.py
rename to backend/msm/user_api/tests/__init__.py
diff --git a/msm/user_api/tests/test_handlers.py b/backend/msm/user_api/tests/test_handlers.py
similarity index 100%
rename from msm/user_api/tests/test_handlers.py
rename to backend/msm/user_api/tests/test_handlers.py
diff --git a/pyproject.toml b/backend/pyproject.toml
similarity index 100%
rename from pyproject.toml
rename to backend/pyproject.toml
diff --git a/requirements.txt b/backend/requirements.txt
similarity index 100%
rename from requirements.txt
rename to backend/requirements.txt
diff --git a/setup.cfg b/backend/setup.cfg
similarity index 100%
rename from setup.cfg
rename to backend/setup.cfg
diff --git a/setup.py b/backend/setup.py
similarity index 100%
rename from setup.py
rename to backend/setup.py
diff --git a/msm/user_api/_schema.py b/msm/user_api/_schema.py
index 38a4ad5..012ba7a 100644
--- a/msm/user_api/_schema.py
+++ b/msm/user_api/_schema.py
@@ -1,3 +1,4 @@
+<<<<<<< msm/user_api/_schema.py
from datetime import (
datetime,
timedelta,
@@ -99,3 +100,5 @@ class CreateTokensResponse(BaseModel):
expiration: datetime
tokens: list[UUID]
+=======
+>>>>>>> msm/user_api/_schema.py