From 850cd5073432632f63e5f3172121cf320c5400bf Mon Sep 17 00:00:00 2001 From: Seung Park Date: Thu, 7 Sep 2023 14:08:04 -0400 Subject: [PATCH 1/6] add environment flag from param store --- cdk-infra/lib/constructs/worker/worker-env-construct.ts | 4 ++++ config/custom-environment-variables.json | 1 + config/default.json | 1 + infrastructure/ecs-main/ecs_service.yml | 2 ++ infrastructure/ecs-main/serverless.yml | 1 + src/job/jobHandler.ts | 1 + tests/data/data.ts | 2 +- tests/unit/job/productionJobHandler.test.ts | 2 +- tests/utils/jobHandlerTestHelper.ts | 1 + 9 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cdk-infra/lib/constructs/worker/worker-env-construct.ts b/cdk-infra/lib/constructs/worker/worker-env-construct.ts index d9f2fbbdb..f1d27ee07 100644 --- a/cdk-infra/lib/constructs/worker/worker-env-construct.ts +++ b/cdk-infra/lib/constructs/worker/worker-env-construct.ts @@ -36,6 +36,9 @@ export class WorkerEnvConstruct extends Construct { `/docs/worker_pool/preview_webhook/snooty_gatsby_cloud_test/data_source` ); + // front end feature flag for chatbot UI + const gatsbyUseChatbot = StringParameter.valueFromLookup(this, `${ssmPrefix}/flag/use_chatbot`); + const githubBotUsername = StringParameter.valueFromLookup(this, `${ssmPrefix}/github/bot/username`); const npmEmail = StringParameter.valueFromLookup(this, `${ssmPrefix}/npm/email`); @@ -80,6 +83,7 @@ export class WorkerEnvConstruct extends Construct { USE_CUSTOM_BUCKETS: `${getUseCustomBuckets()}`, FEATURE_NAME: `${getFeatureName()}`, GATSBY_TEST_SEARCH_UI: 'false', + GATSBY_SHOW_CHATBOT: gatsbyUseChatbot, }; } } diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json index edd5c2434..011a147c7 100644 --- a/config/custom-environment-variables.json +++ b/config/custom-environment-variables.json @@ -24,6 +24,7 @@ "previewBuildEnabled": "PREVIEW_BUILD_ENABLED", "featureFlagUpdatePages": "FEATURE_FLAG_UPDATE_PAGES", "featureFlagSearchUI": "GATSBY_TEST_SEARCH_UI", + "gatsbyUseChatbot": "GATSBY_SHOW_CHATBOT", "repoBranchesCollection": "REPO_BRANCHES_COL_NAME", "repo_dir": "repos", "jobId": "jobId", diff --git a/config/default.json b/config/default.json index dec339ac1..4f88c8feb 100644 --- a/config/default.json +++ b/config/default.json @@ -32,6 +32,7 @@ "previewBuildEnabled": "false", "featureFlagUpdatePages": "false", "featureFlagSearchUI": "false", + "gatsbyUseChatbot": "false", "parallel": { "enabled": true, "stg": { diff --git a/infrastructure/ecs-main/ecs_service.yml b/infrastructure/ecs-main/ecs_service.yml index 4d8d63f19..f4b09982c 100644 --- a/infrastructure/ecs-main/ecs_service.yml +++ b/infrastructure/ecs-main/ecs_service.yml @@ -62,6 +62,8 @@ Resources: Value: ${self:custom.featureFlagUpdatePages} - Name: GATSBY_TEST_SEARCH_UI Value: ${self:custom.featureFlagSearchUI} + - Name: GATSBY_SHOW_CHATBOT + Value: ${self:custom.gatsbyUseChatbot} - Name: FASTLY_MAIN_TOKEN Value: ${self:custom.fastlyMainToken} - Name: FASTLY_MAIN_SERVICE_ID diff --git a/infrastructure/ecs-main/serverless.yml b/infrastructure/ecs-main/serverless.yml index 0de1eb941..e06ca9a2c 100644 --- a/infrastructure/ecs-main/serverless.yml +++ b/infrastructure/ecs-main/serverless.yml @@ -117,6 +117,7 @@ custom: featureFlagUpdatePages: ${ssm:/env/${self:provider.stage}/docs/worker_pool/flag/update_pages} featureFlagSearchUI: ${ssm:/env/${self:provider.stage}/docs/worker_pool/flag/search_ui} gatsbyTestEmbedVersions: ${ssm:/env/${self:provider.stage}/docs/worker_pool/flag/embedded_versions} + gatsbyUseChatbot: ${ssm:/env/${self:provider.stage}/docs/worker_pool/flag/use_chatbot} fastlyMainToken: ${ssm:/env/${self:provider.stage}/docs/worker_pool/fastly/docs/main/token} fastlyMainServiceId: ${ssm:/env/${self:provider.stage}/docs/worker_pool/fastly/docs/main/service_id} fastlyCloudManagerToken: ${ssm:/env/${self:provider.stage}/docs/worker_pool/fastly/docs/cloudmanager/token} diff --git a/src/job/jobHandler.ts b/src/job/jobHandler.ts index accb96f2d..0fb9d5dc5 100644 --- a/src/job/jobHandler.ts +++ b/src/job/jobHandler.ts @@ -369,6 +369,7 @@ export abstract class JobHandler { GATSBY_BASE_URL: this._config.get('gatsbyBaseUrl'), PREVIEW_BUILD_ENABLED: this._config.get('previewBuildEnabled'), GATSBY_TEST_SEARCH_UI: this._config.get('featureFlagSearchUI'), + GATSBY_SHOW_CHATBOT: this._config.get('gatsbyUseChatbot'), }; for (const [envName, envValue] of Object.entries(snootyFrontEndVars)) { diff --git a/tests/data/data.ts b/tests/data/data.ts index fafca623a..d403e8cad 100644 --- a/tests/data/data.ts +++ b/tests/data/data.ts @@ -175,7 +175,7 @@ export class TestDataProvider { } static getEnvVarsWithPathPrefixWithFlags(job: Job): string { - return `GATSBY_PARSER_USER=TestUser\nGATSBY_PARSER_BRANCH=${job.payload.branchName}\nPATH_PREFIX=${job.payload.pathPrefix}\nGATSBY_BASE_URL=test\nPREVIEW_BUILD_ENABLED=false\nGATSBY_TEST_SEARCH_UI=false\n`; + return `GATSBY_PARSER_USER=TestUser\nGATSBY_PARSER_BRANCH=${job.payload.branchName}\nPATH_PREFIX=${job.payload.pathPrefix}\nGATSBY_BASE_URL=test\nPREVIEW_BUILD_ENABLED=false\nGATSBY_TEST_SEARCH_UI=false\nGATSBY_SHOW_CHATBOT=false\n`; } static getPathPrefixCases(): Array { diff --git a/tests/unit/job/productionJobHandler.test.ts b/tests/unit/job/productionJobHandler.test.ts index 187109286..00e5f4600 100644 --- a/tests/unit/job/productionJobHandler.test.ts +++ b/tests/unit/job/productionJobHandler.test.ts @@ -247,7 +247,7 @@ describe('ProductionJobHandler Tests', () => { expect(jobHandlerTestHelper.fileSystemServices.writeToFile).toBeCalledWith( `repos/${jobHandlerTestHelper.job.payload.repoName}/.env.production`, - `GATSBY_PARSER_USER=TestUser\nGATSBY_PARSER_BRANCH=${jobHandlerTestHelper.job.payload.branchName}\nPATH_PREFIX=/\nGATSBY_BASE_URL=test\nPREVIEW_BUILD_ENABLED=false\nGATSBY_TEST_SEARCH_UI=false\n`, + `GATSBY_PARSER_USER=TestUser\nGATSBY_PARSER_BRANCH=${jobHandlerTestHelper.job.payload.branchName}\nPATH_PREFIX=/\nGATSBY_BASE_URL=test\nPREVIEW_BUILD_ENABLED=false\nGATSBY_TEST_SEARCH_UI=false\nGATSBY_SHOW_CHATBOT=false\n`, { encoding: 'utf8', flag: 'w' } ); }); diff --git a/tests/utils/jobHandlerTestHelper.ts b/tests/utils/jobHandlerTestHelper.ts index ea24e8a1d..9d9e871e9 100644 --- a/tests/utils/jobHandlerTestHelper.ts +++ b/tests/utils/jobHandlerTestHelper.ts @@ -148,6 +148,7 @@ export class JobHandlerTestHelper { this.config.get.calledWith('gatsbyBaseUrl').mockReturnValue('test'); this.config.get.calledWith('previewBuildEnabled').mockReturnValue('false'); this.config.get.calledWith('featureFlagSearchUI').mockReturnValue('false'); + this.config.get.calledWith('gatsbyUseChatbot').mockReturnValue('false'); this.repoConnector.checkCommits .calledWith(this.job) .mockReturnValue(TestDataProvider.getCommitCheckValidResponse(this.job)); From ee2f1baddc4212b788b563d799353a4deec66492 Mon Sep 17 00:00:00 2001 From: Seung Park Date: Thu, 7 Sep 2023 16:09:24 -0400 Subject: [PATCH 2/6] test front end change --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d0f4838e8..9a5f2e4fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN cd ./modules/oas-page-builder \ FROM ubuntu:20.04 ARG WORK_DIRECTORY=/home/docsworker-xlarge ARG SNOOTY_PARSER_VERSION=0.14.6 -ARG SNOOTY_FRONTEND_VERSION=0.14.13 +ARG SNOOTY_FRONTEND_VERSION=DOP-3994 ARG MUT_VERSION=0.10.3 ARG REDOC_CLI_VERSION=1.2.2 ARG NPM_BASE_64_AUTH @@ -77,7 +77,8 @@ WORKDIR ${WORK_DIRECTORY} RUN curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/meta/makefiles/shared.mk -o shared.mk # install snooty frontend and docs-tools -RUN git clone -b v${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \ +# TODO: revert change +RUN git clone -b ${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \ && cd snooty \ && npm ci --legacy-peer-deps --omit=dev \ && git clone --depth 1 https://github.com/mongodb/docs-tools.git \ From 1a9c262590e1ea6ff6e5d801fc0331a81fb4d066 Mon Sep 17 00:00:00 2001 From: Seung Park Date: Thu, 7 Sep 2023 16:33:17 -0400 Subject: [PATCH 3/6] wrong dockerfile --- Dockerfile | 5 ++--- Dockerfile.enhanced | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9a5f2e4fb..d0f4838e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN cd ./modules/oas-page-builder \ FROM ubuntu:20.04 ARG WORK_DIRECTORY=/home/docsworker-xlarge ARG SNOOTY_PARSER_VERSION=0.14.6 -ARG SNOOTY_FRONTEND_VERSION=DOP-3994 +ARG SNOOTY_FRONTEND_VERSION=0.14.13 ARG MUT_VERSION=0.10.3 ARG REDOC_CLI_VERSION=1.2.2 ARG NPM_BASE_64_AUTH @@ -77,8 +77,7 @@ WORKDIR ${WORK_DIRECTORY} RUN curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/meta/makefiles/shared.mk -o shared.mk # install snooty frontend and docs-tools -# TODO: revert change -RUN git clone -b ${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \ +RUN git clone -b v${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \ && cd snooty \ && npm ci --legacy-peer-deps --omit=dev \ && git clone --depth 1 https://github.com/mongodb/docs-tools.git \ diff --git a/Dockerfile.enhanced b/Dockerfile.enhanced index fb530489f..bf584cb90 100644 --- a/Dockerfile.enhanced +++ b/Dockerfile.enhanced @@ -23,7 +23,7 @@ RUN cd ./modules/oas-page-builder \ FROM ubuntu:20.04 ARG WORK_DIRECTORY=/home/docsworker-xlarge ARG SNOOTY_PARSER_VERSION=0.14.6 -ARG SNOOTY_FRONTEND_VERSION=0.14.13 +ARG SNOOTY_FRONTEND_VERSION=DOP-3994 ARG MUT_VERSION=0.10.5 ARG REDOC_CLI_VERSION=1.2.0 ARG NPM_BASE_64_AUTH @@ -77,7 +77,8 @@ WORKDIR ${WORK_DIRECTORY} RUN curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/meta/makefiles/shared.mk -o shared.mk # install snooty frontend and docs-tools -RUN git clone -b v${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \ +# TODO: revert change +RUN git clone -b ${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \ && cd snooty \ && npm ci --legacy-peer-deps --omit=dev \ && git clone --depth 1 https://github.com/mongodb/docs-tools.git \ From dd15ff7954ae3e2d3d210ce19235e0fa2ed11457 Mon Sep 17 00:00:00 2001 From: Seung Park Date: Thu, 7 Sep 2023 16:45:48 -0400 Subject: [PATCH 4/6] user master branch --- Dockerfile.enhanced | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.enhanced b/Dockerfile.enhanced index bf584cb90..c2cb95009 100644 --- a/Dockerfile.enhanced +++ b/Dockerfile.enhanced @@ -23,7 +23,7 @@ RUN cd ./modules/oas-page-builder \ FROM ubuntu:20.04 ARG WORK_DIRECTORY=/home/docsworker-xlarge ARG SNOOTY_PARSER_VERSION=0.14.6 -ARG SNOOTY_FRONTEND_VERSION=DOP-3994 +ARG SNOOTY_FRONTEND_VERSION=master ARG MUT_VERSION=0.10.5 ARG REDOC_CLI_VERSION=1.2.0 ARG NPM_BASE_64_AUTH From d072981ff2128568c2d5710b36d0639489dc58e7 Mon Sep 17 00:00:00 2001 From: Seung Park Date: Thu, 7 Sep 2023 19:31:36 -0400 Subject: [PATCH 5/6] test stack update --- .github/workflows/deploy-feature-branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-feature-branch.yml b/.github/workflows/deploy-feature-branch.yml index 3ffc81099..d9c13b0b8 100644 --- a/.github/workflows/deploy-feature-branch.yml +++ b/.github/workflows/deploy-feature-branch.yml @@ -26,7 +26,7 @@ jobs: npm ci cd cdk-infra/ npm ci - npm run deploy:feature -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} --outputs-file outputs.json + npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} --outputs-file outputs.json - name: Get Webhook URL uses: actions/github-script@v6 id: webhook From a7b7d120a42c685dc9a99debd2d88c3aab1722f0 Mon Sep 17 00:00:00 2001 From: Seung Park Date: Fri, 8 Sep 2023 10:32:12 -0400 Subject: [PATCH 6/6] revert testing --- .github/workflows/deploy-feature-branch.yml | 2 +- Dockerfile.enhanced | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-feature-branch.yml b/.github/workflows/deploy-feature-branch.yml index d9c13b0b8..3ffc81099 100644 --- a/.github/workflows/deploy-feature-branch.yml +++ b/.github/workflows/deploy-feature-branch.yml @@ -26,7 +26,7 @@ jobs: npm ci cd cdk-infra/ npm ci - npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} --outputs-file outputs.json + npm run deploy:feature -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} --outputs-file outputs.json - name: Get Webhook URL uses: actions/github-script@v6 id: webhook diff --git a/Dockerfile.enhanced b/Dockerfile.enhanced index c2cb95009..fb530489f 100644 --- a/Dockerfile.enhanced +++ b/Dockerfile.enhanced @@ -23,7 +23,7 @@ RUN cd ./modules/oas-page-builder \ FROM ubuntu:20.04 ARG WORK_DIRECTORY=/home/docsworker-xlarge ARG SNOOTY_PARSER_VERSION=0.14.6 -ARG SNOOTY_FRONTEND_VERSION=master +ARG SNOOTY_FRONTEND_VERSION=0.14.13 ARG MUT_VERSION=0.10.5 ARG REDOC_CLI_VERSION=1.2.0 ARG NPM_BASE_64_AUTH @@ -77,8 +77,7 @@ WORKDIR ${WORK_DIRECTORY} RUN curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/meta/makefiles/shared.mk -o shared.mk # install snooty frontend and docs-tools -# TODO: revert change -RUN git clone -b ${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \ +RUN git clone -b v${SNOOTY_FRONTEND_VERSION} --depth 1 https://github.com/mongodb/snooty.git \ && cd snooty \ && npm ci --legacy-peer-deps --omit=dev \ && git clone --depth 1 https://github.com/mongodb/docs-tools.git \