From f16a70baf423d8408fb12ca284500f90db39e875 Mon Sep 17 00:00:00 2001 From: Sofia Sazonova Date: Fri, 19 Jan 2024 13:08:04 +0000 Subject: [PATCH 1/4] Add SSM param to store version info. Add version.json file to the repo-root --- deploy/stacks/deploy_config.py | 16 ++++++++++++---- deploy/stacks/param_store_stack.py | 10 ++++++++++ deploy/stacks/pipeline.py | 1 + version.json | 4 ++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 version.json diff --git a/deploy/stacks/deploy_config.py b/deploy/stacks/deploy_config.py index 4d87d754a..48bcf07a7 100644 --- a/deploy/stacks/deploy_config.py +++ b/deploy/stacks/deploy_config.py @@ -12,6 +12,10 @@ class _DeployConfig: def __init__(self): self._config = self._read_config_file() + self._version = self._read_version_file() + + def get_dataall_version(self) -> str: + return json.dumps(self._version) def get_property(self, key: str, default=None) -> Any: """ @@ -52,20 +56,24 @@ def set_property(self, key: str, value: Any) -> None: @classmethod def _read_config_file(cls) -> Dict[str, Any]: - with open(cls._path_to_file()) as config_file: + with open(cls._path_to_file("config.json")) as config_file: return json.load(config_file) + @classmethod + def _read_version_file(cls) -> Dict[str, Any]: + with open(cls._path_to_file("version.json")) as version_file: + return json.load(version_file) + @staticmethod - def _path_to_file() -> str: + def _path_to_file(filename) -> str: """Tries to get a property. If not defined it tries to resolve the config from the current file's directory""" path = os.getenv("config_location") if path: return path - return os.path.join(Path(__file__).parents[2], "config.json") + return os.path.join(Path(__file__).parents[2], filename) def __repr__(self): return str(self._config) deploy_config = _DeployConfig() - diff --git a/deploy/stacks/param_store_stack.py b/deploy/stacks/param_store_stack.py index 7be190538..fa6505338 100644 --- a/deploy/stacks/param_store_stack.py +++ b/deploy/stacks/param_store_stack.py @@ -1,3 +1,4 @@ +import json import random import string @@ -8,6 +9,7 @@ ) from .pyNestedStack import pyNestedClass +from .deploy_config import deploy_config class ParamStoreStack(pyNestedClass): @@ -122,6 +124,14 @@ def __init__( description=f"Stores dataall external id for environment {envname}", ) + aws_ssm.StringParameter( + self, + f'dataall_{envname}_version', + parameter_name=f'/dataall/{envname}/version', + string_value=str(json.dumps(deploy_config.get_dataall_version())), + description='Deployed data all version' + ) + def _get_external_id_value(envname, account_id, region): """ For first deployments and upgrades from <=V1.5.6 to >=v1.6 - returns False and a new ssm parameter created, diff --git a/deploy/stacks/pipeline.py b/deploy/stacks/pipeline.py index 51d9703db..b770213a3 100644 --- a/deploy/stacks/pipeline.py +++ b/deploy/stacks/pipeline.py @@ -558,6 +558,7 @@ def set_quality_gate_stage(self): 'mkdir -p source_build', 'mv backend ./source_build/', 'mv config.json ./source_build/', + 'mv version.json ./source_build/', 'cd source_build/ && zip -r ../source_build/source_build.zip *', f'aws s3api put-object --bucket {self.pipeline_bucket.bucket_name} --key source_build.zip --body source_build.zip', ], diff --git a/version.json b/version.json new file mode 100644 index 000000000..d3ae31d28 --- /dev/null +++ b/version.json @@ -0,0 +1,4 @@ +{ + "version": "2.2.0", + "release-date": "14.12.2023" +} \ No newline at end of file From 6c2fa69a18653d8a4baf67162eca801e40bd7ad6 Mon Sep 17 00:00:00 2001 From: Sofia Sazonova Date: Fri, 19 Jan 2024 17:14:07 +0000 Subject: [PATCH 2/4] Copy version.json to frontend folder --- deploy/stacks/pipeline.py | 1 + frontend/docker/dev/Dockerfile | 2 ++ frontend/docker/prod/Dockerfile | 2 ++ frontend/package.json | 7 ++++--- frontend/src/design/components/Logo.js | 3 ++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/deploy/stacks/pipeline.py b/deploy/stacks/pipeline.py index b770213a3..7d5ce6aff 100644 --- a/deploy/stacks/pipeline.py +++ b/deploy/stacks/pipeline.py @@ -508,6 +508,7 @@ def set_quality_gate_stage(self): f'aws codeartifact login --tool npm --repository {self.codeartifact.codeartifact_npm_repo_name} --domain {self.codeartifact.codeartifact_domain_name} --domain-owner {self.codeartifact.domain.attr_owner}', 'npm install', 'npm run copy-config', + 'npm run copy-version', 'npm run lint -- --quiet', ], role=self.baseline_codebuild_role.without_policy_updates(), diff --git a/frontend/docker/dev/Dockerfile b/frontend/docker/dev/Dockerfile index 960233341..f746b0e16 100644 --- a/frontend/docker/dev/Dockerfile +++ b/frontend/docker/dev/Dockerfile @@ -22,6 +22,8 @@ COPY --chown=${CONTAINER_USER}:root ./frontend . # Copy config.json to docker root, because app scripts read it from ".." COPY --chown=${CONTAINER_USER}:root ./config.json / +# Copy vesion.json to docker root, because app scripts read it from ".." +COPY --chown=${CONTAINER_USER}:root ./version.json / # Disable linting before starting the server ENV DISABLE_ESLINT_PLUGIN=true diff --git a/frontend/docker/prod/Dockerfile b/frontend/docker/prod/Dockerfile index 8fa71ebd2..35098667b 100644 --- a/frontend/docker/prod/Dockerfile +++ b/frontend/docker/prod/Dockerfile @@ -55,6 +55,8 @@ RUN . ~/.nvm/nvm.sh && npm install -g npm@9 yarn COPY --chown=${CONTAINER_USER}:root ./frontend/package.json ./frontend/yarn.lock ./ COPY --chown=${CONTAINER_USER}:root ./config.json / +# Copy vesion.json to docker root, because app scripts read it from ".." +COPY --chown=${CONTAINER_USER}:root ./version.json / RUN . ~/.nvm/nvm.sh && yarn install diff --git a/frontend/package.json b/frontend/package.json index 095983d2f..bd736be08 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,9 +7,10 @@ "start": "react-scripts start", "build": "react-scripts build", "copy-config": "mkdir -p ./src/generated; cp ../config.json ./src/generated/", - "postinstall": "yarn copy-config", - "prestart": "yarn copy-config", - "prebuild": "yarn copy-config", + "copy-version": "mkdir -p ./src/generated; cp ../version.json ./src/generated/", + "postinstall": "yarn copy-config; yarn copy-version", + "prestart": "yarn copy-config; yarn copy-version", + "prebuild": "yarn copy-config; yarn copy-version", "test": "react-scripts test", "eject": "react-scripts eject", "lint": "eslint --ext js src", diff --git a/frontend/src/design/components/Logo.js b/frontend/src/design/components/Logo.js index e72082b97..4fc50d7ed 100644 --- a/frontend/src/design/components/Logo.js +++ b/frontend/src/design/components/Logo.js @@ -1,4 +1,5 @@ import { Box, CardMedia, Grid, Typography } from '@mui/material'; +import version from '../../generated/version.json'; export const Logo = () => ( <> @@ -17,7 +18,7 @@ export const Logo = () => ( -  data.all +  data.all {version.version} From 8bc075f93d9adae806b48858ccad64c24a7bfeaf Mon Sep 17 00:00:00 2001 From: Sofia Sazonova Date: Mon, 22 Jan 2024 15:40:24 +0000 Subject: [PATCH 3/4] Version now is displayed in tooltip, not as part of logo --- frontend/src/design/components/Logo.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/design/components/Logo.js b/frontend/src/design/components/Logo.js index 4fc50d7ed..8d967f8da 100644 --- a/frontend/src/design/components/Logo.js +++ b/frontend/src/design/components/Logo.js @@ -1,4 +1,4 @@ -import { Box, CardMedia, Grid, Typography } from '@mui/material'; +import { Box, CardMedia, Grid, Tooltip, Typography } from '@mui/material'; import version from '../../generated/version.json'; export const Logo = () => ( @@ -17,9 +17,11 @@ export const Logo = () => ( - -  data.all {version.version} - + + +  data.all + + From 7ea58cb4c1b1af261bf35408e208efcd9bdc8f42 Mon Sep 17 00:00:00 2001 From: Sofia Sazonova Date: Tue, 23 Jan 2024 16:15:56 +0000 Subject: [PATCH 4/4] Additional copy of version.json to S3 removed --- deploy/stacks/pipeline.py | 1 - 1 file changed, 1 deletion(-) diff --git a/deploy/stacks/pipeline.py b/deploy/stacks/pipeline.py index 7d5ce6aff..9af4de40e 100644 --- a/deploy/stacks/pipeline.py +++ b/deploy/stacks/pipeline.py @@ -559,7 +559,6 @@ def set_quality_gate_stage(self): 'mkdir -p source_build', 'mv backend ./source_build/', 'mv config.json ./source_build/', - 'mv version.json ./source_build/', 'cd source_build/ && zip -r ../source_build/source_build.zip *', f'aws s3api put-object --bucket {self.pipeline_bucket.bucket_name} --key source_build.zip --body source_build.zip', ],