From ffb3b45ac29a42fc33046010476b956c4dedbaa5 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Thu, 24 Mar 2022 20:29:01 -0800 Subject: [PATCH] feat: add build id from commit hash (#1095) * fix old ref * capture git commit as build ID * generate new types * display build on Site Settings page * fix extras crash it extras is none --- .github/workflows/backend-docker-nightly.yml | 1 + Dockerfile | 3 +++ frontend/api/admin/admin-about.ts | 12 +----------- frontend/pages/admin/site-settings.vue | 5 +++++ frontend/types/api-types/admin.ts | 1 + frontend/types/components.d.ts | 4 ++-- makefile | 3 ++- mealie/core/settings/settings.py | 2 ++ mealie/db/models/recipe/recipe.py | 4 ++-- mealie/routes/admin/admin_about.py | 1 + mealie/schema/admin/about.py | 1 + 11 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.github/workflows/backend-docker-nightly.yml b/.github/workflows/backend-docker-nightly.yml index d5ef3202..4794a08e 100644 --- a/.github/workflows/backend-docker-nightly.yml +++ b/.github/workflows/backend-docker-nightly.yml @@ -47,6 +47,7 @@ jobs: docker build --push --no-cache \ --tag hkotel/mealie:api-nightly \ --platform linux/amd64,linux/arm64 . + --build-arg COMMIT=$(git rev-parse HEAD) \ # # Build Discord Notification # diff --git a/Dockerfile b/Dockerfile index 72f51b7f..d4e1ab02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -91,6 +91,9 @@ FROM python-base as production ENV PRODUCTION=true ENV TESTING=false +ARG COMMIT +ENV GIT_COMMIT_HASH=$COMMIT + # curl for used by healthcheck RUN apt-get update \ && apt-get install --no-install-recommends -y \ diff --git a/frontend/api/admin/admin-about.ts b/frontend/api/admin/admin-about.ts index 6f5933d9..3c50a2f2 100644 --- a/frontend/api/admin/admin-about.ts +++ b/frontend/api/admin/admin-about.ts @@ -1,4 +1,5 @@ import { BaseAPI } from "../_base"; +import { AdminAboutInfo } from "~/types/api-types/admin"; const prefix = "/api"; @@ -8,17 +9,6 @@ const routes = { check: `${prefix}/admin/about/check`, }; -export interface AdminAboutInfo { - production: boolean; - version: string; - demoStatus: boolean; - apiPort: number; - apiDocs: boolean; - dbType: string; - dbUrl: string; - defaultGroup: string; - versionLatest: string; -} export interface AdminStatistics { totalRecipes: number; diff --git a/frontend/pages/admin/site-settings.vue b/frontend/pages/admin/site-settings.vue index 83e00488..4f485a57 100644 --- a/frontend/pages/admin/site-settings.vue +++ b/frontend/pages/admin/site-settings.vue @@ -238,6 +238,11 @@ export default defineComponent({ icon: $globals.icons.information, value: data.version, }, + { + name: "Build", + icon: $globals.icons.information, + value: data.buildId, + }, { name: i18n.t("about.application-mode"), icon: $globals.icons.devTo, diff --git a/frontend/types/api-types/admin.ts b/frontend/types/api-types/admin.ts index 5f4e7486..0071cacc 100644 --- a/frontend/types/api-types/admin.ts +++ b/frontend/types/api-types/admin.ts @@ -16,6 +16,7 @@ export interface AdminAboutInfo { dbType: string; dbUrl?: string; defaultGroup: string; + buildId: string; } export interface AllBackups { imports: BackupFile[]; diff --git a/frontend/types/components.d.ts b/frontend/types/components.d.ts index 43887f9d..afb5aa3f 100644 --- a/frontend/types/components.d.ts +++ b/frontend/types/components.d.ts @@ -13,9 +13,9 @@ import InputLabelType from "@/components/global/InputLabelType.vue"; import BaseStatCard from "@/components/global/BaseStatCard.vue"; import DevDumpJson from "@/components/global/DevDumpJson.vue"; + import LanguageDialog from "@/components/global/LanguageDialog.vue"; import InputQuantity from "@/components/global/InputQuantity.vue"; import ToggleState from "@/components/global/ToggleState.vue"; - import LanguageDialog from "~/components/global/LanguageDialog.vue"; import AppButtonCopy from "@/components/global/AppButtonCopy.vue"; import CrudTable from "@/components/global/CrudTable.vue"; import InputColor from "@/components/global/InputColor.vue"; @@ -48,9 +48,9 @@ declare module "vue" { InputLabelType: typeof InputLabelType; BaseStatCard: typeof BaseStatCard; DevDumpJson: typeof DevDumpJson; + LanguageDialog: typeof LanguageDialog; InputQuantity: typeof InputQuantity; ToggleState: typeof ToggleState; - LanguageDialog: typeof LanguageDialog; AppButtonCopy: typeof AppButtonCopy; CrudTable: typeof CrudTable; InputColor: typeof InputColor; diff --git a/makefile b/makefile index dd178114..ea1d7df3 100644 --- a/makefile +++ b/makefile @@ -55,7 +55,8 @@ setup-model: ## 🤖 Get the latest NLP CRF++ Model @echo Fetching NLP Model - CRF++ is still Required curl -L0 https://github.com/mealie-recipes/nlp-model/releases/download/v1.0.0/model.crfmodel --output ./mealie/services/parser_services/crfpp/model.crfmodel -clean-data: clean ## ⚠️ Removes All Developer Data for a fresh server start + +clean-data: ## ⚠️ Removes All Developer Data for a fresh server start rm -r ./dev/data/recipes/ rm -r ./dev/data/users/ rm -f ./dev/data/mealie*.db diff --git a/mealie/core/settings/settings.py b/mealie/core/settings/settings.py index 0c1dd7dd..fdee2b76 100644 --- a/mealie/core/settings/settings.py +++ b/mealie/core/settings/settings.py @@ -32,6 +32,8 @@ class AppSettings(BaseSettings): TOKEN_TIME: int = 48 # Time in Hours SECRET: str + GIT_COMMIT_HASH: str = "unknown" + ALLOW_SIGNUP: bool = True @property diff --git a/mealie/db/models/recipe/recipe.py b/mealie/db/models/recipe/recipe.py index 2b2c108d..080d7310 100644 --- a/mealie/db/models/recipe/recipe.py +++ b/mealie/db/models/recipe/recipe.py @@ -31,8 +31,8 @@ def recipe_extras(func): if extras is None: extras = [] - - extras = [{"key": key, "value": value} for key, value in extras.items()] + else: + extras = [{"key": key, "value": value} for key, value in extras.items()] return func(*args, extras=extras, **kwargs) diff --git a/mealie/routes/admin/admin_about.py b/mealie/routes/admin/admin_about.py index 0364af23..6b497156 100644 --- a/mealie/routes/admin/admin_about.py +++ b/mealie/routes/admin/admin_about.py @@ -26,6 +26,7 @@ class AdminAboutController(BaseAdminController): db_url=settings.DB_URL_PUBLIC, default_group=settings.DEFAULT_GROUP, allow_signup=settings.ALLOW_SIGNUP, + build_id=settings.GIT_COMMIT_HASH, ) @router.get("/statistics", response_model=AppStatistics) diff --git a/mealie/schema/admin/about.py b/mealie/schema/admin/about.py index 8c42f576..9cfe37ad 100644 --- a/mealie/schema/admin/about.py +++ b/mealie/schema/admin/about.py @@ -23,6 +23,7 @@ class AdminAboutInfo(AppInfo): db_type: str db_url: str | None default_group: str + build_id: str class CheckAppConfig(CamelModel):