Skip to content

Commit

Permalink
DOP-3998: allow preprd to use URL for search staging server (#942)
Browse files Browse the repository at this point in the history
* pipe in gatsby marian url from param store

* add env vars to tests

* test with front end

* update branch for front end

* revert gh action change

* revert snooty frontend version
  • Loading branch information
seungpark authored Nov 27, 2023
1 parent 5c0fff6 commit bbc701f
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cdk-infra/lib/constructs/worker/worker-env-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class WorkerEnvConstruct extends Construct {
const repoBranchesCollection = StringParameter.valueFromLookup(this, `${ssmPrefix}/atlas/collections/repo`);
const docsetsCollection = StringParameter.valueFromLookup(this, `${ssmPrefix}/atlas/collections/docsets`);
const jobCollection = StringParameter.valueFromLookup(this, `${ssmPrefix}/atlas/collections/job/queue`);
const gatsbyMarianUrl = StringParameter.valueFromLookup(this, `${ssmPrefix}/frontend/marian_url`);

const dbPassword = secureStrings['MONGO_ATLAS_PASSWORD'];
this.environment = {
Expand Down Expand Up @@ -93,6 +94,7 @@ export class WorkerEnvConstruct extends Construct {
GATSBY_TEST_SEARCH_UI: 'false',
GATSBY_SHOW_CHATBOT: gatsbyUseChatbot,
GATSBY_HIDE_UNIFIED_FOOTER_LOCALE: gatsbyHideUnifiedFooterLocale,
GATSBY_MARIAN_URL: gatsbyMarianUrl,
};
}
}
1 change: 1 addition & 0 deletions config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"featureFlagSearchUI": "GATSBY_TEST_SEARCH_UI",
"gatsbyUseChatbot": "GATSBY_SHOW_CHATBOT",
"gatsbyHideUnifiedFooterLocale": "GATSBY_HIDE_UNIFIED_FOOTER_LOCALE",
"gatsbyManifestURL": "GATSBY_MARIAN_URL",
"repoBranchesCollection": "REPO_BRANCHES_COL_NAME",
"docsetsCollection": "DOCSETS_COL_NAME",
"repo_dir": "repos",
Expand Down
1 change: 1 addition & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"PORT": 3000,
"MAX_STDOUT_BUFFER_SIZE": 16000000,
"GATSBY_PARSER_USER": "docsworker-xlarge",
"gatsbyMarianUrl": "https://docs-search-transport.mongodb.com/",
"gatsbyTestEmbedVersions": false,
"fastlyOpsManagerToken": "FASTLY_OPS_MANAGER_TOKEN",
"fastlyOpsManagerServiceId": "FASTLY_OPS_MANAGER_SERVICE_ID",
Expand Down
2 changes: 2 additions & 0 deletions infrastructure/ecs-main/ecs_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Resources:
Value: ${self:custom.featureFlagSearchUI}
- Name: GATSBY_SHOW_CHATBOT
Value: ${self:custom.gatsbyUseChatbot}
- Name: GATSBY_MARIAN_URL
Value: ${self:custom.gatsbyMarianUrl}
- Name: GATSBY_HIDE_UNIFIED_FOOTER_LOCALE
Value: ${self:custom.gatsbyHideUnifiedFooterLocale}
- Name: FASTLY_MAIN_TOKEN
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 @@ -120,6 +120,7 @@ custom:
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}
gatsbyManifestURL: ${ssm:/env/${self:provider.stage}/docs/worker_pool/frontend/marian_url}
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/commands/src/helpers/dependency-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async function createEnvProdFile(repoDir: string, projectName: string, baseUrl:
GATSBY_MANIFEST_PATH=${repoDir}/bundle.zip
GATSBY_PARSER_USER=${process.env.USER}
GATSBY_BASE_URL=${baseUrl}
GATSBY_MARIAN_URL=${process.env.GATSBY_MARIAN_URL}
PATH_PREFIX=${prefix}`,
'utf8'
);
Expand Down
1 change: 1 addition & 0 deletions src/job/jobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ export abstract class JobHandler {
GATSBY_TEST_SEARCH_UI: this._config.get<string>('featureFlagSearchUI'),
GATSBY_SHOW_CHATBOT: this._config.get<string>('gatsbyUseChatbot'),
GATSBY_HIDE_UNIFIED_FOOTER_LOCALE: this._config.get<string>('gatsbyHideUnifiedFooterLocale'),
GATSBY_MARIAN_URL: this._config.get<string>('gatsbyManifestURL'),
};

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 @@ -176,7 +176,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\nGATSBY_HIDE_UNIFIED_FOOTER_LOCALE=true\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\nGATSBY_MARIAN_URL=test-url\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\nGATSBY_HIDE_UNIFIED_FOOTER_LOCALE=true\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\nGATSBY_MARIAN_URL=test-url\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 @@ -154,6 +154,7 @@ export class JobHandlerTestHelper {
this.config.get.calledWith('featureFlagSearchUI').mockReturnValue('false');
this.config.get.calledWith('gatsbyUseChatbot').mockReturnValue('false');
this.config.get.calledWith('gatsbyHideUnifiedFooterLocale').mockReturnValue('true');
this.config.get.calledWith('gatsbyManifestURL').mockReturnValue('test-url');
this.repoConnector.checkCommits
.calledWith(this.job)
.mockReturnValue(TestDataProvider.getCommitCheckValidResponse(this.job));
Expand Down

0 comments on commit bbc701f

Please sign in to comment.