Skip to content

Commit

Permalink
🚩 DOP-4060 adds new featrue flag to the docs-worker-pool (#919)
Browse files Browse the repository at this point in the history
* 🚩 DOP-4060 adds new featrue flag to the docs-worker-pool

* 🚩 DOP-4060 adds new featrue flag to the docs-worker-pool

* 👌 DOP-4060 updated the way we are handling env vars based on feedback

---------

Co-authored-by: Caesar Bell <[email protected]>
  • Loading branch information
caesarbell and Caesar Bell authored Oct 3, 2023
1 parent f8c9955 commit 12fbb16
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cdk-infra/lib/constructs/worker/worker-env-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class WorkerEnvConstruct extends Construct {
`/docs/worker_pool/preview_webhook/snooty_gatsby_cloud_test/data_source`
);

// font-end feature flag for unified footer locale selector
const gatsbyHideUnifiedFooterLocale = StringParameter.valueFromLookup(this, `${ssmPrefix}/flag/hide_locale`);

// front end feature flag for chatbot UI
const gatsbyUseChatbot = StringParameter.valueFromLookup(this, `${ssmPrefix}/flag/use_chatbot`);

Expand Down Expand Up @@ -86,6 +89,7 @@ export class WorkerEnvConstruct extends Construct {
FEATURE_NAME: `${getFeatureName()}`,
GATSBY_TEST_SEARCH_UI: 'false',
GATSBY_SHOW_CHATBOT: gatsbyUseChatbot,
GATSBY_HIDE_UNIFIED_FOOTER_LOCALE: gatsbyHideUnifiedFooterLocale,
};
}
}
2 changes: 2 additions & 0 deletions infrastructure/ecs-main/ecs_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Resources:
Value: ${self:custom.featureFlagSearchUI}
- Name: GATSBY_SHOW_CHATBOT
Value: ${self:custom.gatsbyUseChatbot}
- Name: GATSBY_HIDE_UNIFIED_FOOTER_LOCALE
Value: ${self:custom.gatsbyHideUnifiedFooterLocale}
- Name: FASTLY_MAIN_TOKEN
Value: ${self:custom.fastlyMainToken}
- Name: FASTLY_MAIN_SERVICE_ID
Expand Down
1 change: 1 addition & 0 deletions infrastructure/ecs-main/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ custom:
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}
gatsbyHideUnifiedFooterLocale: ${ssm:/env/${self:provider.stage}/docs/worker_pool/flag/hide_locale}
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}
Expand Down
1 change: 1 addition & 0 deletions src/job/jobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export abstract class JobHandler {
PREVIEW_BUILD_ENABLED: this._config.get<string>('previewBuildEnabled'),
GATSBY_TEST_SEARCH_UI: this._config.get<string>('featureFlagSearchUI'),
GATSBY_SHOW_CHATBOT: this._config.get<string>('gatsbyUseChatbot'),
GATSBY_HIDE_UNIFIED_FOOTER_LOCALE: process.env.GATSBY_HIDE_UNIFIED_FOOTER_LOCALE || 'true',
};

for (const [envName, envValue] of Object.entries(snootyFrontEndVars)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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\nGATSBY_SHOW_CHATBOT=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\nGATSBY_HIDE_UNIFIED_FOOTER_LOCALE=true\n`;
}

static getPathPrefixCases(): Array<any> {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/job/productionJobHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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\nGATSBY_SHOW_CHATBOT=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\nGATSBY_HIDE_UNIFIED_FOOTER_LOCALE=true\n`,
{ encoding: 'utf8', flag: 'w' }
);
});
Expand Down
1 change: 1 addition & 0 deletions tests/utils/jobHandlerTestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export class JobHandlerTestHelper {
this.config.get.calledWith('previewBuildEnabled').mockReturnValue('false');
this.config.get.calledWith('featureFlagSearchUI').mockReturnValue('false');
this.config.get.calledWith('gatsbyUseChatbot').mockReturnValue('false');
this.config.get.calledWith('gatsbyHideUnifiedFooterLocale').mockReturnValue('true');
this.repoConnector.checkCommits
.calledWith(this.job)
.mockReturnValue(TestDataProvider.getCommitCheckValidResponse(this.job));
Expand Down

0 comments on commit 12fbb16

Please sign in to comment.