From 9075d99deb437f91bd4d4332b4dcd42afe4e1b97 Mon Sep 17 00:00:00 2001 From: Brandon Ly Date: Mon, 16 Oct 2023 08:40:40 -0500 Subject: [PATCH 1/3] Break up deploy for feature branch (#927) --- .github/workflows/deploy-feature-branch.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-feature-branch.yml b/.github/workflows/deploy-feature-branch.yml index 3ffc81099..9e7d6d150 100644 --- a/.github/workflows/deploy-feature-branch.yml +++ b/.github/workflows/deploy-feature-branch.yml @@ -26,7 +26,9 @@ 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}} auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-queues + npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-worker + npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-webhooks --outputs-file outputs.json - name: Get Webhook URL uses: actions/github-script@v6 id: webhook From d8c277257a0378a2691abdab18e453063b9f21d5 Mon Sep 17 00:00:00 2001 From: rayangler <27821750+rayangler@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:43:07 -0400 Subject: [PATCH 2/3] DOP-4096: Create new timestamp when inserting pages and metadata (#928) --- modules/persistence/src/services/connector/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/persistence/src/services/connector/index.ts b/modules/persistence/src/services/connector/index.ts index 2b1dfe888..e06c7890f 100644 --- a/modules/persistence/src/services/connector/index.ts +++ b/modules/persistence/src/services/connector/index.ts @@ -47,7 +47,7 @@ export const insert = async (docs: any[], collection: string, buildId: ObjectId, docs.map((d) => ({ ...d, build_id: buildId, - created_at: buildId.getTimestamp(), + created_at: new Date(), })), { ordered: false } ); From 282910405470a23cefb5ada13532a4937392523f Mon Sep 17 00:00:00 2001 From: rayangler <27821750+rayangler@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:48:33 -0400 Subject: [PATCH 3/3] DOP-4044: Get repo branches for non-internal doc in docset (#925) --- .../services/metadata/repos_branches/index.ts | 20 +- modules/persistence/tests/data/docsets.json | 60 +++ .../tests/data/repos_branches.json | 380 +++++++++++++++++- .../associated_products.test.ts.snap | 225 +++++++++++ .../metadata/associated_products.test.ts | 22 + 5 files changed, 701 insertions(+), 6 deletions(-) diff --git a/modules/persistence/src/services/metadata/repos_branches/index.ts b/modules/persistence/src/services/metadata/repos_branches/index.ts index 6ea2cb455..cd43e63bb 100644 --- a/modules/persistence/src/services/metadata/repos_branches/index.ts +++ b/modules/persistence/src/services/metadata/repos_branches/index.ts @@ -22,6 +22,7 @@ export interface ReposBranchesDocument extends WithId { branches: BranchEntry[]; url: EnvKeyedObject; prefix: EnvKeyedObject; + internalOnly: boolean; [key: string]: any; } @@ -82,7 +83,7 @@ export const getAllAssociatedRepoBranchesEntries = async (metadata: Metadata) => try { const db = await pool(); - const aggregationPipeline = getAggregationPipeline({ project: { $in: fetch } }); + const aggregationPipeline = getAggregationPipeline({ project: { $in: fetch }, internalOnly: false }); const cursor = db.collection('docsets').aggregate(aggregationPipeline); const docsets = (await cursor.toArray()) as ReposBranchesDocument[]; docsets.forEach((doc: ReposBranchesDocument) => { @@ -114,7 +115,11 @@ export const getRepoBranchesEntry = async (project: project, branch = ''): Promi // get from DB if not cached try { const db = await pool(); - const matchCondition = { project }; + const matchCondition = { + project, + // We want the repo branches of the single deployable repo for a docset + internalOnly: false, + }; if (branch) { matchCondition['branches'] = { $elemMatch: { gitBranchName: branch } }; } @@ -122,12 +127,19 @@ export const getRepoBranchesEntry = async (project: project, branch = ''): Promi const cursor = db.collection('docsets').aggregate(aggregationPipeline); const res = (await cursor.toArray()) as unknown as ReposBranchesDocument[]; + const returnedEntry = res[0]; + + if (res.length > 1) { + console.warn( + `Expected 1 deployable repo for docset with project "${project}", but found ${res.length} instead. Defaulting to first found: "${returnedEntry.repoName}".` + ); + } // if not already set, set cache value for repo_branches if (!internals[project]) { - internals[project] = res[0]; + internals[project] = returnedEntry; } - return res[0]; + return returnedEntry; } catch (e) { console.error(`Error while getting repo branches entry: ${e}`); throw e; diff --git a/modules/persistence/tests/data/docsets.json b/modules/persistence/tests/data/docsets.json index 0d12420db..c446b78cd 100644 --- a/modules/persistence/tests/data/docsets.json +++ b/modules/persistence/tests/data/docsets.json @@ -59,5 +59,65 @@ "categoryTitle": "Atlas CLI" }, "repos": ["6243aa3f0aae3635a59a1150"] + }, + { + "_id": "6500937d24fcc731b4735cff", + "project": "docs", + "bucket": { + "regression": "docs-mongodb-org-stg", + "dev": "docs-mongodb-org-dev", + "stg": "docs-mongodb-org-stg", + "prd": "docs-mongodb-org-prd", + "dotcomstg": "docs-mongodb-org-dotcomstg", + "dotcomprd": "docs-mongodb-org-dotcomprd" + }, + "directories": { + "snooty_toml": "/docs" + }, + "prefix": { + "stg": "", + "prd": "", + "dotcomstg": "docs-qa", + "dotcomprd": "docs" + }, + "repos": ["5fac1ce373a72fca02ec90c5", "614b9f5b8d181382ca755ade"], + "url": { + "regression": "https://docs-mongodbcom-integration.corp.mongodb.com", + "dev": "https://docs-mongodborg-staging.corp.mongodb.com", + "stg": "https://docs-mongodborg-staging.corp.mongodb.com", + "prd": "https://docs.mongodb.com", + "dotcomprd": "http://mongodb.com/", + "dotcomstg": "https://mongodbcom-cdn.website.staging.corp.mongodb.com/" + } + }, + { + "_id": "6500937d24fcc731b4735d00", + "project": "multiple-deployables", + "bucket": { + "regression": "docs-mongodb-org-stg", + "dev": "docs-mongodb-org-dev", + "stg": "docs-mongodb-org-stg", + "prd": "docs-mongodb-org-prd", + "dotcomstg": "docs-mongodb-org-dotcomstg", + "dotcomprd": "docs-mongodb-org-dotcomprd" + }, + "directories": { + "snooty_toml": "/docs" + }, + "prefix": { + "stg": "", + "prd": "", + "dotcomstg": "docs-qa", + "dotcomprd": "docs" + }, + "repos": ["6526fe0d17c4f50e837e419f", "6526fe0d17c4f50e837e420f"], + "url": { + "regression": "https://docs-mongodbcom-integration.corp.mongodb.com", + "dev": "https://docs-mongodborg-staging.corp.mongodb.com", + "stg": "https://docs-mongodborg-staging.corp.mongodb.com", + "prd": "https://docs.mongodb.com", + "dotcomprd": "http://mongodb.com/", + "dotcomstg": "https://mongodbcom-cdn.website.staging.corp.mongodb.com/" + } } ] diff --git a/modules/persistence/tests/data/repos_branches.json b/modules/persistence/tests/data/repos_branches.json index 47597f6ce..795d2653a 100644 --- a/modules/persistence/tests/data/repos_branches.json +++ b/modules/persistence/tests/data/repos_branches.json @@ -43,7 +43,9 @@ "search": { "categoryName": "atlas", "categoryTitle": "Atlas" - } + }, + "prodDeployable": true, + "internalOnly": false }, { "_id": "6243aa3f0aae3635a59a1150", @@ -142,6 +144,380 @@ "search": { "categoryTitle": "Atlas CLI" }, - "groups": null + "groups": null, + "prodDeployable": true, + "internalOnly": false + }, + { + "_id": "5fac1ce373a72fca02ec90c5", + "repoName": "docs-mongodb-internal", + "branches": [ + { + "name": "v5.0", + "publishOriginalBranchName": true, + "active": true, + "aliases": [ + "stable" + ], + "gitBranchName": "v5.0", + "isStableBranch": false, + "urlAliases": [ + "stable" + ], + "urlSlug": "stable", + "versionSelectorLabel": "v5.0", + "buildsWithSnooty": true, + "id": "634991b6246409bf0cc5116a" + } + ], + "bucket": { + "regression": "docs-mongodb-org-stg", + "dev": "docs-mongodb-org-dev", + "stg": "docs-mongodb-org-stg", + "prd": "docs-mongodb-org-prd", + "dotcomstg": "docs-mongodb-org-dotcomstg", + "dotcomprd": "docs-mongodb-org-dotcomprd" + }, + "url": { + "regression": "https://docs-mongodbcom-integration.corp.mongodb.com", + "dev": "https://docs-mongodborg-staging.corp.mongodb.com", + "stg": "https://docs-mongodborg-staging.corp.mongodb.com", + "prd": "https://docs.mongodb.com", + "dotcomprd": "http://mongodb.com/", + "dotcomstg": "https://mongodbcom-cdn.website.staging.corp.mongodb.com/" + }, + "prefix": { + "stg": "", + "prd": "", + "dotcomstg": "docs-qa", + "dotcomprd": "docs" + }, + "project": "docs", + "internalOnly": true, + "prodDeployable": false, + "directories": { + "snooty_toml": "/docs-mongodb-internal" + } + }, + { + "_id": "614b9f5b8d181382ca755ade", + "repoName": "docs", + "branches": [ + { + "id": "634991b6246409bf0cc51154", + "gitBranchName": "master", + "active": true, + "urlAliases": [ + "v6.1", + "rapid", + "upcoming" + ], + "publishOriginalBranchName": false, + "urlSlug": "upcoming", + "versionSelectorLabel": "6.1 (upcoming)", + "isStableBranch": false, + "buildsWithSnooty": null + }, + { + "id": "634991b6246409bf0cc51149", + "gitBranchName": "v6.0", + "active": true, + "urlAliases": [ + "current", + "stable", + "manual" + ], + "publishOriginalBranchName": true, + "urlSlug": "v6.0", + "versionSelectorLabel": "6.0 (current)", + "isStableBranch": true, + "buildsWithSnooty": true + }, + { + "id": "634991b6246409bf0cc51153", + "gitBranchName": "v5.1", + "active": false, + "urlAliases": null, + "publishOriginalBranchName": null, + "urlSlug": "v5.1", + "versionSelectorLabel": "v5.1", + "isStableBranch": null, + "buildsWithSnooty": true + }, + { + "id": "634991b6246409bf0cc51148", + "gitBranchName": "v5.0", + "active": true, + "urlAliases": [], + "publishOriginalBranchName": true, + "urlSlug": "v5.0", + "versionSelectorLabel": "5.0", + "isStableBranch": false, + "buildsWithSnooty": true + }, + { + "id": "634991b6246409bf0cc51145", + "gitBranchName": "v4.4", + "active": true, + "urlAliases": null, + "publishOriginalBranchName": true, + "urlSlug": "v4.4", + "versionSelectorLabel": "4.4", + "isStableBranch": false, + "buildsWithSnooty": true + }, + { + "id": "634991b6246409bf0cc51146", + "gitBranchName": "v4.2", + "active": false, + "urlAliases": null, + "publishOriginalBranchName": null, + "urlSlug": "v4.2", + "versionSelectorLabel": "4.2", + "isStableBranch": false, + "buildsWithSnooty": false + }, + { + "id": "634991b6246409bf0cc51147", + "gitBranchName": "v4.0", + "active": false, + "urlAliases": null, + "publishOriginalBranchName": null, + "urlSlug": "v4.0", + "versionSelectorLabel": "v4.0", + "isStableBranch": null, + "buildsWithSnooty": false + }, + { + "id": "634991b6246409bf0cc5114a", + "gitBranchName": "3.6", + "active": false, + "urlAliases": null, + "publishOriginalBranchName": null, + "urlSlug": "3.6", + "versionSelectorLabel": "3.6", + "isStableBranch": null, + "buildsWithSnooty": false + }, + { + "id": "634991b6246409bf0cc5114b", + "gitBranchName": "3.4", + "active": false, + "urlAliases": null, + "publishOriginalBranchName": null, + "urlSlug": "3.4", + "versionSelectorLabel": "3.4", + "isStableBranch": null, + "buildsWithSnooty": false + }, + { + "id": "634991b6246409bf0cc5114d", + "gitBranchName": "3.2", + "active": false, + "urlAliases": null, + "publishOriginalBranchName": null, + "urlSlug": "3.2", + "versionSelectorLabel": "3.2", + "isStableBranch": null, + "buildsWithSnooty": false + }, + { + "id": "634991b6246409bf0cc51150", + "gitBranchName": "3.0", + "active": false, + "urlAliases": null, + "publishOriginalBranchName": null, + "urlSlug": "3.0", + "versionSelectorLabel": "3.0", + "isStableBranch": null, + "buildsWithSnooty": false + }, + { + "id": "634991b6246409bf0cc5114f", + "gitBranchName": "2.6", + "active": false, + "urlAliases": null, + "publishOriginalBranchName": null, + "urlSlug": "2.6", + "versionSelectorLabel": "2.6", + "isStableBranch": null, + "buildsWithSnooty": false + }, + { + "id": "634991b6246409bf0cc5114c", + "gitBranchName": "2.4", + "active": false, + "urlAliases": null, + "publishOriginalBranchName": null, + "urlSlug": "2.4", + "versionSelectorLabel": "2.4", + "isStableBranch": null, + "buildsWithSnooty": false + }, + { + "id": "634991b6246409bf0cc5114e", + "gitBranchName": "2.2", + "active": false, + "urlAliases": null, + "publishOriginalBranchName": null, + "urlSlug": "2.2", + "versionSelectorLabel": "2.2", + "isStableBranch": null, + "buildsWithSnooty": false + } + ], + "bucket": { + "regression": "docs-mongodb-org-stg", + "dev": "docs-mongodb-org-dev", + "stg": "docs-mongodb-org-stg", + "prd": "docs-mongodb-org-prd", + "dotcomstg": "docs-mongodb-org-dotcomstg", + "dotcomprd": "docs-mongodb-org-dotcomprd" + }, + "url": { + "regression": "https://docs-mongodbcom-integration.corp.mongodb.com", + "dev": "https://docs-mongodborg-staging.corp.mongodb.com", + "stg": "https://docs-mongodborg-staging.corp.mongodb.com", + "prd": "https://docs.mongodb.com", + "dotcomprd": "http://mongodb.com/", + "dotcomstg": "https://mongodbcom-cdn.website.staging.corp.mongodb.com/" + }, + "prefix": { + "stg": "", + "prd": "", + "dotcomstg": "docs-qa", + "dotcomprd": "docs" + }, + "project": "docs", + "groups": [ + { + "groupLabel": "Major Release", + "includedBranches": [ + "v6.0", + "v5.0", + "v4.4" + ], + "id": "634991b6246409bf0cc51155" + }, + { + "groupLabel": "Rapid Release", + "includedBranches": [ + "master" + ], + "id": "634991b6246409bf0cc51156" + } + ], + "search": { + "categoryName": "manual", + "categoryTitle": "MongoDB Server" + }, + "displayName": "MongoDB Manual", + "internalOnly": false, + "prodDeployable": true, + "directories": { + "snooty_toml": "/docs" + } + }, + { + "_id": "6526fe0d17c4f50e837e419f", + "repoName": "docs-multiple-deployables-1", + "branches": [ + { + "name": "v5.0", + "publishOriginalBranchName": true, + "active": true, + "aliases": [ + "stable" + ], + "gitBranchName": "v5.0", + "isStableBranch": false, + "urlAliases": [ + "stable" + ], + "urlSlug": "stable", + "versionSelectorLabel": "v5.0", + "buildsWithSnooty": true, + "id": "634991b6246409bf0cc5116b" + } + ], + "bucket": { + "regression": "docs-mongodb-org-stg", + "dev": "docs-mongodb-org-dev", + "stg": "docs-mongodb-org-stg", + "prd": "docs-mongodb-org-prd", + "dotcomstg": "docs-mongodb-org-dotcomstg", + "dotcomprd": "docs-mongodb-org-dotcomprd" + }, + "url": { + "regression": "https://docs-mongodbcom-integration.corp.mongodb.com", + "dev": "https://docs-mongodborg-staging.corp.mongodb.com", + "stg": "https://docs-mongodborg-staging.corp.mongodb.com", + "prd": "https://docs.mongodb.com", + "dotcomprd": "http://mongodb.com/", + "dotcomstg": "https://mongodbcom-cdn.website.staging.corp.mongodb.com/" + }, + "prefix": { + "stg": "", + "prd": "", + "dotcomstg": "docs-qa", + "dotcomprd": "docs" + }, + "project": "multiple-deployables", + "internalOnly": false, + "prodDeployable": true, + "directories": { + "snooty_toml": "/docs-multiple-deployables-1" + } + }, + { + "_id": "6526fe0d17c4f50e837e420f", + "repoName": "docs-multiple-deployables-2", + "branches": [ + { + "name": "v5.0", + "publishOriginalBranchName": true, + "active": true, + "aliases": [ + "stable" + ], + "gitBranchName": "v5.0", + "isStableBranch": false, + "urlAliases": [ + "stable" + ], + "urlSlug": "stable", + "versionSelectorLabel": "v5.0", + "buildsWithSnooty": true, + "id": "634991b6246409bf0cc5116c" + } + ], + "bucket": { + "regression": "docs-mongodb-org-stg", + "dev": "docs-mongodb-org-dev", + "stg": "docs-mongodb-org-stg", + "prd": "docs-mongodb-org-prd", + "dotcomstg": "docs-mongodb-org-dotcomstg", + "dotcomprd": "docs-mongodb-org-dotcomprd" + }, + "url": { + "regression": "https://docs-mongodbcom-integration.corp.mongodb.com", + "dev": "https://docs-mongodborg-staging.corp.mongodb.com", + "stg": "https://docs-mongodborg-staging.corp.mongodb.com", + "prd": "https://docs.mongodb.com", + "dotcomprd": "http://mongodb.com/", + "dotcomstg": "https://mongodbcom-cdn.website.staging.corp.mongodb.com/" + }, + "prefix": { + "stg": "", + "prd": "", + "dotcomstg": "docs-qa", + "dotcomprd": "docs" + }, + "project": "multiple-deployables", + "internalOnly": false, + "prodDeployable": true, + "directories": { + "snooty_toml": "/docs-multiple-deployables-2" + } } ] diff --git a/modules/persistence/tests/metadata/__snapshots__/associated_products.test.ts.snap b/modules/persistence/tests/metadata/__snapshots__/associated_products.test.ts.snap index 9c699ee35..b8e829bb4 100644 --- a/modules/persistence/tests/metadata/__snapshots__/associated_products.test.ts.snap +++ b/modules/persistence/tests/metadata/__snapshots__/associated_products.test.ts.snap @@ -103,12 +103,14 @@ Object { "stg": "docs-mongodb-org-stg", }, "groups": null, + "internalOnly": false, "prefix": Object { "dotcomprd": "docs/atlas/cli", "dotcomstg": "docs-qa/atlas/cli", "prd": "atlas/cli", "stg": "atlas/cli", }, + "prodDeployable": true, "project": "atlas-cli", "repoName": "docs-atlas-cli", "search": Object { @@ -2866,12 +2868,14 @@ Object { "stg": "docs-mongodb-org-stg", }, "groups": null, + "internalOnly": false, "prefix": Object { "dotcomprd": "docs/atlas/cli", "dotcomstg": "docs-qa/atlas/cli", "prd": "atlas/cli", "stg": "atlas/cli", }, + "prodDeployable": true, "project": "atlas-cli", "repoName": "docs-atlas-cli", "search": Object { @@ -2888,6 +2892,227 @@ Object { } `; +exports[`associated_products module getRepoBranchesEntry should return the repo branches for the docs deployable repo of the docset 1`] = ` +Object { + "branches": Array [ + Object { + "active": true, + "buildsWithSnooty": null, + "gitBranchName": "master", + "id": "634991b6246409bf0cc51154", + "isStableBranch": false, + "publishOriginalBranchName": false, + "urlAliases": Array [ + "v6.1", + "rapid", + "upcoming", + ], + "urlSlug": "upcoming", + "versionSelectorLabel": "6.1 (upcoming)", + }, + Object { + "active": true, + "buildsWithSnooty": true, + "gitBranchName": "v6.0", + "id": "634991b6246409bf0cc51149", + "isStableBranch": true, + "publishOriginalBranchName": true, + "urlAliases": Array [ + "current", + "stable", + "manual", + ], + "urlSlug": "v6.0", + "versionSelectorLabel": "6.0 (current)", + }, + Object { + "active": false, + "buildsWithSnooty": true, + "gitBranchName": "v5.1", + "id": "634991b6246409bf0cc51153", + "isStableBranch": null, + "publishOriginalBranchName": null, + "urlAliases": null, + "urlSlug": "v5.1", + "versionSelectorLabel": "v5.1", + }, + Object { + "active": true, + "buildsWithSnooty": true, + "gitBranchName": "v5.0", + "id": "634991b6246409bf0cc51148", + "isStableBranch": false, + "publishOriginalBranchName": true, + "urlAliases": Array [], + "urlSlug": "v5.0", + "versionSelectorLabel": "5.0", + }, + Object { + "active": true, + "buildsWithSnooty": true, + "gitBranchName": "v4.4", + "id": "634991b6246409bf0cc51145", + "isStableBranch": false, + "publishOriginalBranchName": true, + "urlAliases": null, + "urlSlug": "v4.4", + "versionSelectorLabel": "4.4", + }, + Object { + "active": false, + "buildsWithSnooty": false, + "gitBranchName": "v4.2", + "id": "634991b6246409bf0cc51146", + "isStableBranch": false, + "publishOriginalBranchName": null, + "urlAliases": null, + "urlSlug": "v4.2", + "versionSelectorLabel": "4.2", + }, + Object { + "active": false, + "buildsWithSnooty": false, + "gitBranchName": "v4.0", + "id": "634991b6246409bf0cc51147", + "isStableBranch": null, + "publishOriginalBranchName": null, + "urlAliases": null, + "urlSlug": "v4.0", + "versionSelectorLabel": "v4.0", + }, + Object { + "active": false, + "buildsWithSnooty": false, + "gitBranchName": "3.6", + "id": "634991b6246409bf0cc5114a", + "isStableBranch": null, + "publishOriginalBranchName": null, + "urlAliases": null, + "urlSlug": "3.6", + "versionSelectorLabel": "3.6", + }, + Object { + "active": false, + "buildsWithSnooty": false, + "gitBranchName": "3.4", + "id": "634991b6246409bf0cc5114b", + "isStableBranch": null, + "publishOriginalBranchName": null, + "urlAliases": null, + "urlSlug": "3.4", + "versionSelectorLabel": "3.4", + }, + Object { + "active": false, + "buildsWithSnooty": false, + "gitBranchName": "3.2", + "id": "634991b6246409bf0cc5114d", + "isStableBranch": null, + "publishOriginalBranchName": null, + "urlAliases": null, + "urlSlug": "3.2", + "versionSelectorLabel": "3.2", + }, + Object { + "active": false, + "buildsWithSnooty": false, + "gitBranchName": "3.0", + "id": "634991b6246409bf0cc51150", + "isStableBranch": null, + "publishOriginalBranchName": null, + "urlAliases": null, + "urlSlug": "3.0", + "versionSelectorLabel": "3.0", + }, + Object { + "active": false, + "buildsWithSnooty": false, + "gitBranchName": "2.6", + "id": "634991b6246409bf0cc5114f", + "isStableBranch": null, + "publishOriginalBranchName": null, + "urlAliases": null, + "urlSlug": "2.6", + "versionSelectorLabel": "2.6", + }, + Object { + "active": false, + "buildsWithSnooty": false, + "gitBranchName": "2.4", + "id": "634991b6246409bf0cc5114c", + "isStableBranch": null, + "publishOriginalBranchName": null, + "urlAliases": null, + "urlSlug": "2.4", + "versionSelectorLabel": "2.4", + }, + Object { + "active": false, + "buildsWithSnooty": false, + "gitBranchName": "2.2", + "id": "634991b6246409bf0cc5114e", + "isStableBranch": null, + "publishOriginalBranchName": null, + "urlAliases": null, + "urlSlug": "2.2", + "versionSelectorLabel": "2.2", + }, + ], + "bucket": Object { + "dev": "docs-mongodb-org-dev", + "dotcomprd": "docs-mongodb-org-dotcomprd", + "dotcomstg": "docs-mongodb-org-dotcomstg", + "prd": "docs-mongodb-org-prd", + "regression": "docs-mongodb-org-stg", + "stg": "docs-mongodb-org-stg", + }, + "directories": Object { + "snooty_toml": "/docs", + }, + "displayName": "MongoDB Manual", + "groups": Array [ + Object { + "groupLabel": "Major Release", + "id": "634991b6246409bf0cc51155", + "includedBranches": Array [ + "v6.0", + "v5.0", + "v4.4", + ], + }, + Object { + "groupLabel": "Rapid Release", + "id": "634991b6246409bf0cc51156", + "includedBranches": Array [ + "master", + ], + }, + ], + "internalOnly": false, + "prefix": Object { + "dotcomprd": "docs", + "dotcomstg": "docs-qa", + "prd": "", + "stg": "", + }, + "prodDeployable": true, + "project": "docs", + "repoName": "docs", + "search": Object { + "categoryName": "manual", + "categoryTitle": "MongoDB Server", + }, + "url": Object { + "dev": "https://docs-mongodborg-staging.corp.mongodb.com", + "dotcomprd": "http://mongodb.com/", + "dotcomstg": "https://mongodbcom-cdn.website.staging.corp.mongodb.com/", + "prd": "https://docs.mongodb.com", + "regression": "https://docs-mongodbcom-integration.corp.mongodb.com", + "stg": "https://docs-mongodborg-staging.corp.mongodb.com", + }, +} +`; + exports[`associated_products module umbrellaMetadataEntry returns the most recent umbrella metadata for specified project in passed metadata 1`] = ` Object { "_id": "63925c18534d9f8b1ee8b062", diff --git a/modules/persistence/tests/metadata/associated_products.test.ts b/modules/persistence/tests/metadata/associated_products.test.ts index 82d2804b8..1275d5629 100644 --- a/modules/persistence/tests/metadata/associated_products.test.ts +++ b/modules/persistence/tests/metadata/associated_products.test.ts @@ -41,6 +41,28 @@ describe('associated_products module', () => { const resBranch = await _getRepoBranchesEntry(project, branch); expect(resBranch).toMatchSnapshot(); }); + + it('should return the repo branches for the docs deployable repo of the docset', async () => { + const res = await _getRepoBranchesEntry('docs'); + expect(res).toMatchSnapshot(); + expect(res.internalOnly).toBeFalsy(); + // Non-deployable repo example should have only 1 branch + expect(res.branches.length).toBeGreaterThan(1); + }); + + it('should leave a warning when more than one deployable repo was found', async () => { + let msg = ''; + const mockedWarn = jest.spyOn(global.console, 'warn').mockImplementationOnce((e) => { + msg = e; + }); + const expectedFirstRepoName = 'docs-multiple-deployables-1'; + const res = await _getRepoBranchesEntry('multiple-deployables'); + expect(console.warn).toBeCalledTimes(1); + expect(msg.includes(expectedFirstRepoName)).toBeTruthy(); + expect(res.internalOnly).toBeFalsy(); + expect(res.repoName).toEqual(expectedFirstRepoName); + mockedWarn.mockReset(); + }); }); describe('getAllAssociatedRepoBranchesEntries', () => {