diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 4d2719f8c..6aea90ae8 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -2,6 +2,14 @@ This README describes the various workflows defined for the docs-worker-pool repository. +## Releases + +The release process occurs whenever someone releases a specific tag (note: it does not run upon creation of a tag, only release). Three separate workflows are run upon release: + +1. `deploy-prd-ecs.yml` - Builds and deploys the old Autobuilder to prd +2. `deploy-prd-enhanced-webhooks.yml` - Builds and deploys webhooks (GitHub and Slack handlers) for the enhanced Autobuilder +3. `deploy-prd-enhanced-worker.yml` - Builds and deploys the Autobuilder worker to prd + ## Feature Branch Deploys The feature branch deploy process occurs whenever a developer opens a pull request. It consists of three separate workflows: diff --git a/.github/workflows/deploy-prd-ecs.yml b/.github/workflows/deploy-prd-ecs.yml index c6e96b9a2..68c751c87 100644 --- a/.github/workflows/deploy-prd-ecs.yml +++ b/.github/workflows/deploy-prd-ecs.yml @@ -1,7 +1,6 @@ on: - push: - tags: - - 'v*' + release: + types: [released] concurrency: group: environment-prd-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/deploy-prd-enhanced-webhooks.yml b/.github/workflows/deploy-prd-enhanced-webhooks.yml index 6b0086fac..fc45d7d0c 100644 --- a/.github/workflows/deploy-prd-enhanced-webhooks.yml +++ b/.github/workflows/deploy-prd-enhanced-webhooks.yml @@ -1,8 +1,6 @@ on: - push: - tags: - - 'v*' - + release: + types: [released] concurrency: group: environment-prd-enhanced-webhooks-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/deploy-prd-enhanced-worker.yml b/.github/workflows/deploy-prd-enhanced-worker.yml index 90676eb1c..10eb08325 100644 --- a/.github/workflows/deploy-prd-enhanced-worker.yml +++ b/.github/workflows/deploy-prd-enhanced-worker.yml @@ -1,8 +1,6 @@ on: - push: - tags: - - 'v*' - + release: + types: [released] concurrency: group: environment-prd-enhanced-worker-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/test-persistence.yml b/.github/workflows/test-persistence.yml index 60bed8856..2b64fd2e3 100644 --- a/.github/workflows/test-persistence.yml +++ b/.github/workflows/test-persistence.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v1 with: - node-version: '14.x' + node-version: '18.x' - name: Install dependencies run: npm install --dev - name: Lint diff --git a/Dockerfile b/Dockerfile index 3ab6ef118..7c079ca92 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.15.2 -ARG SNOOTY_FRONTEND_VERSION=0.15.3 +ARG SNOOTY_FRONTEND_VERSION=0.15.6 ARG MUT_VERSION=0.10.7 ARG REDOC_CLI_VERSION=1.2.3 ARG NPM_BASE_64_AUTH diff --git a/Dockerfile.enhanced b/Dockerfile.enhanced index e83419604..505c84034 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.15.2 -ARG SNOOTY_FRONTEND_VERSION=0.15.3 +ARG SNOOTY_FRONTEND_VERSION=0.15.6 ARG MUT_VERSION=0.10.7 ARG REDOC_CLI_VERSION=1.2.3 ARG NPM_BASE_64_AUTH @@ -117,4 +117,4 @@ ENV OAS_MODULE_PATH=${WORK_DIRECTORY}/modules/oas-page-builder/index.js RUN mkdir repos && chmod 755 repos EXPOSE 3000 -CMD ["node", "enhanced/enhancedApp.js"] +CMD ["node", "--enable-source-maps", "enhanced/enhancedApp.js"] diff --git a/Dockerfile.local b/Dockerfile.local index 25587a67e..f3b2bd7a8 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -2,7 +2,7 @@ FROM arm64v8/ubuntu:20.04 as initial ARG NPM_BASE_64_AUTH ARG NPM_EMAIL ARG SNOOTY_PARSER_VERSION=0.15.2 -ARG SNOOTY_FRONTEND_VERSION=0.15.3 +ARG SNOOTY_FRONTEND_VERSION=0.15.6 ARG MUT_VERSION=0.10.7 ARG REDOC_CLI_VERSION=1.2.3 ARG NPM_BASE_64_AUTH diff --git a/README.md b/README.md index ca199904b..6e5224e91 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,8 @@ docs-worker-pool contains various triggers for release to higher environments. C - Create release tags. We currently follow [semver](https://semver.org/) standards. - If you don't have push access, open an issue or otherwise contact a contributor with administrator privileges. -- Verify that the deploy-production-ec2 workflow executed successfully for both job runs across both production instances. +- Create a release associated with the tag using the GitHub UI or by running `gh release create`. +- Verify that the deploy-production-ec2 workflow executed successfully for both job runs across both production instances. The workflow should only run when a release is published. ### Serverless Development diff --git a/api/controllers/v2/github.ts b/api/controllers/v2/github.ts index e562d2a2f..a761e742b 100644 --- a/api/controllers/v2/github.ts +++ b/api/controllers/v2/github.ts @@ -138,6 +138,7 @@ export const TriggerBuild = async (event: APIGatewayEvent): Promise 1) continue; diff --git a/api/handlers/slack.ts b/api/handlers/slack.ts index a13df5e4c..4b8d534cd 100644 --- a/api/handlers/slack.ts +++ b/api/handlers/slack.ts @@ -24,14 +24,17 @@ export async function buildEntitledBranchList(entitlement: any, repoBranchesRepo const [repoOwner, repoName, directoryPath] = repo.split('/'); const branches = await repoBranchesRepository.getRepoBranches(repoName, directoryPath); for (const branch of branches) { - let buildWithSnooty = true; - if ('buildsWithSnooty' in branch) { - buildWithSnooty = branch['buildsWithSnooty']; - } + const buildWithSnooty = branch['buildsWithSnooty']; if (buildWithSnooty) { - entitledBranches.push( - `${repoOwner}/${repoName}${directoryPath ? '/' + directoryPath : ''}/${branch['gitBranchName']}` - ); + const active = branch['active']; + const repoPath = `${repoOwner}/${repoName}${directoryPath ? '/' + directoryPath : ''}/${ + branch['gitBranchName'] + }`; + if (!active) { + entitledBranches.push(`(!inactive) ${repoPath}`); + } else { + entitledBranches.push(repoPath); + } } } } diff --git a/infrastructure/ecs-main/buckets.yml b/infrastructure/ecs-main/buckets.yml index 24fd72f7d..f4f7dfcea 100644 --- a/infrastructure/ecs-main/buckets.yml +++ b/infrastructure/ecs-main/buckets.yml @@ -78,6 +78,12 @@ Resources: Protocol: "https" HostName: ${self:custom.site.host.${self:provider.stage}} ReplaceKeyPrefixWith: ${self:custom.site.prefix.${self:provider.stage}}/atlas/cli/v1.1 + - RoutingRuleCondition: + KeyPrefixEquals: ${self:custom.site.prefix.${self:provider.stage}}/php-library/master + RedirectRule: + Protocol: "https" + HostName: ${self:custom.site.host.${self:provider.stage}} + ReplaceKeyPrefixWith: ${self:custom.site.prefix.${self:provider.stage}}/php-library/upcoming DocAtlasBucket: Type: "AWS::S3::Bucket" Properties: diff --git a/modules/persistence/.nvmrc b/modules/persistence/.nvmrc index 9f4189900..12ea1eebc 100644 --- a/modules/persistence/.nvmrc +++ b/modules/persistence/.nvmrc @@ -1 +1 @@ -v14.17.6 \ No newline at end of file +v18.12.0 \ No newline at end of file diff --git a/modules/persistence/src/services/metadata/ToC/index.ts b/modules/persistence/src/services/metadata/ToC/index.ts index 9f9e0fe61..580fb0beb 100644 --- a/modules/persistence/src/services/metadata/ToC/index.ts +++ b/modules/persistence/src/services/metadata/ToC/index.ts @@ -1,4 +1,3 @@ -import { AssociatedProduct, hasAssociations } from '../associated_products'; import { Metadata } from '..'; import { convertSlugToUrl } from './utils/convertSlugToUrl'; @@ -93,15 +92,19 @@ const mergeTocTreeOrder = (metadata: Metadata, node, insertions: TocOrderInserti // contains an associated_products entry export const traverseAndMerge = ( metadata: Metadata, - associated_products: AssociatedProduct[], + umbrellaMetadata: Metadata, umbrellaToCs: ToCCopies, tocInsertions: ToCInsertions, tocOrderInsertions: TocOrderInsertions ) => { const { project } = metadata; + const associatedProducts = umbrellaMetadata.associated_products || []; - const toctree = hasAssociations(metadata) ? umbrellaToCs.original : umbrellaToCs.urlified; - const toBeInserted = new Set(associated_products.map((p) => p.name)); + const associatedProductNames = associatedProducts.map((p) => p.name); + const toctree = structuredClone( + metadata.project === umbrellaMetadata.project ? umbrellaToCs.original : umbrellaToCs.urlified + ); + const toBeInserted = new Set(associatedProductNames); let queue = [toctree]; while (queue?.length && toBeInserted.size) { let next = queue.shift(); diff --git a/modules/persistence/src/services/metadata/associated_products/index.ts b/modules/persistence/src/services/metadata/associated_products/index.ts index 9ac5abf4e..c640da419 100644 --- a/modules/persistence/src/services/metadata/associated_products/index.ts +++ b/modules/persistence/src/services/metadata/associated_products/index.ts @@ -26,12 +26,6 @@ interface AggregatedMetadata { most_recent: Metadata; } -type EnvKeyedObject = { - prd: any; - preprd: any; - dotcomstg: any; - dotcomprd: any; -}; // TODO: move the branch/repobranch interfaces into their own file, or into a seperate abstraction? export interface BranchEntry { name: string; @@ -69,8 +63,8 @@ const umbrellaMetadataEntry = async (project: string): Promise => { return null as unknown as Metadata; } - const repoDoc = await getRepoBranchesEntry(project); - const branchNames = repoDoc.branches.map((branchEntry) => branchEntry.gitBranchName); + const umbrellaRepos = await getRepoBranchesEntry(umbrella.project); + const branchNames = umbrellaRepos.branches.map((branchEntry) => branchEntry.gitBranchName); const entry = await snooty .collection('metadata') .find({ @@ -198,7 +192,7 @@ export const mergeAssociatedToCs = async (metadata: Metadata) => { const mergedMetadataEntries = [umbrellaMetadata, ...associatedMetadataEntries].map((metadataEntry) => { const mergedMetadataEntry = traverseAndMerge( metadataEntry, - umbrellaMetadata.associated_products || [], + umbrellaMetadata, umbrellaToCs, tocInsertions, tocOrderInsertions diff --git a/modules/persistence/src/services/metadata/repos_branches/index.ts b/modules/persistence/src/services/metadata/repos_branches/index.ts index cfdd37016..ab1af6c20 100644 --- a/modules/persistence/src/services/metadata/repos_branches/index.ts +++ b/modules/persistence/src/services/metadata/repos_branches/index.ts @@ -65,6 +65,11 @@ const getAggregationPipeline = (matchCondition: any) => { repo: 0, }, }, + { + $sort: { + prodDeployable: -1, + }, + }, ]; }; diff --git a/modules/persistence/tests/metadata/ToC.test.ts b/modules/persistence/tests/metadata/ToC.test.ts index 684282a97..ff8ed23ee 100644 --- a/modules/persistence/tests/metadata/ToC.test.ts +++ b/modules/persistence/tests/metadata/ToC.test.ts @@ -122,7 +122,7 @@ describe('ToC module', () => { expect( traverseAndMerge( umbrellaMetadata as unknown as Metadata, - umbrellaMetadata.associated_products || [], + umbrellaMetadata, umbrellaToCs, tocInsertions, tocOrderInsertions @@ -135,7 +135,7 @@ describe('ToC module', () => { expect( traverseAndMerge( metadata[0] as unknown as Metadata, - umbrellaMetadata.associated_products || [], + umbrellaMetadata, umbrellaToCs, tocInsertions, tocOrderInsertions diff --git a/modules/persistence/tests/setupAfterEnv.ts b/modules/persistence/tests/setupAfterEnv.ts index 061a85eaf..2b73fc367 100644 --- a/modules/persistence/tests/setupAfterEnv.ts +++ b/modules/persistence/tests/setupAfterEnv.ts @@ -1,4 +1,5 @@ beforeAll(() => { // Disable console.time from crowding test output console.time = jest.fn(); + global.structuredClone = (val) => JSON.parse(JSON.stringify(val)); }); diff --git a/src/commands/index.ts b/src/commands/index.ts index 77b25f7a6..7c32ac6ac 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -1,4 +1,4 @@ -import { prepareBuildAndGetDependencies } from './src/helpers/dependency-helpers'; +import { prepareBuild } from './src/helpers/dependency-helpers'; import { nextGenDeploy } from './src/shared/next-gen-deploy'; import { nextGenHtml } from './src/shared/next-gen-html'; import { nextGenParse } from './src/shared/next-gen-parse'; @@ -6,12 +6,4 @@ import { nextGenStage } from './src/shared/next-gen-stage'; import { oasPageBuild } from './src/shared/oas-page-build'; import { persistenceModule } from './src/shared/persistence-module'; -export { - nextGenParse, - nextGenHtml, - nextGenStage, - persistenceModule, - oasPageBuild, - nextGenDeploy, - prepareBuildAndGetDependencies, -}; +export { nextGenParse, nextGenHtml, nextGenStage, persistenceModule, oasPageBuild, nextGenDeploy, prepareBuild }; diff --git a/src/commands/src/helpers/dependency-helpers.ts b/src/commands/src/helpers/dependency-helpers.ts index 17da25acd..3e2f20ae6 100644 --- a/src/commands/src/helpers/dependency-helpers.ts +++ b/src/commands/src/helpers/dependency-helpers.ts @@ -43,16 +43,25 @@ async function createEnvProdFile({ } } -export async function downloadBuildDependencies(buildDependencies: BuildDependencies, repoName: string) { +export async function downloadBuildDependencies( + buildDependencies: BuildDependencies, + repoName: string, + directory?: string +) { const commands: string[] = []; await Promise.all( buildDependencies.map(async (dependencyInfo) => { - const repoDir = getRepoDir(repoName); + const repoDir = getRepoDir(repoName, directory); const targetDir = dependencyInfo.targetDir ?? repoDir; + let options = {}; + if (targetDir != repoDir) { + options = { cwd: repoDir }; + } try { await executeCliCommand({ command: 'mkdir', args: ['-p', targetDir], + options: options, }); } catch (error) { console.error( @@ -63,11 +72,13 @@ export async function downloadBuildDependencies(buildDependencies: BuildDependen } commands.push(`mkdir -p ${targetDir}`); await Promise.all( - dependencyInfo.dependencies.map((dep) => { + dependencyInfo.dependencies.map(async (dep) => { + commands.push(`curl -SfL ${dep.url} -o ${targetDir}/${dep.filename}`); try { - executeCliCommand({ + return await executeCliCommand({ command: 'curl', - args: ['-SfL', dep.url, '-o', `${targetDir}/${dep.filename}`], + args: ['--max-time', '10', '-SfL', dep.url, '-o', `${targetDir}/${dep.filename}`], + options: options, }); } catch (error) { console.error( @@ -75,7 +86,6 @@ export async function downloadBuildDependencies(buildDependencies: BuildDependen dependencyInfo ); } - commands.push(`curl -SfL ${dep.url} -o ${targetDir}/${dep.filename}`); }) ); }) @@ -83,16 +93,8 @@ export async function downloadBuildDependencies(buildDependencies: BuildDependen return commands; } -export async function prepareBuildAndGetDependencies( - repoName: string, - projectName: string, - baseUrl: string, - buildDependencies: BuildDependencies, - directory?: string -) { +export async function prepareBuild(repoName: string, projectName: string, baseUrl: string, directory?: string) { const repoDir = getRepoDir(repoName, directory); - await downloadBuildDependencies(buildDependencies, repoName); - console.log('Downloaded Build dependencies'); // doing these in parallel const commandPromises = [ diff --git a/src/commands/src/helpers/index.ts b/src/commands/src/helpers/index.ts index dd22ad760..ba79ca626 100644 --- a/src/commands/src/helpers/index.ts +++ b/src/commands/src/helpers/index.ts @@ -14,9 +14,11 @@ const EPIPE_SYSCALL = 'write'; export class ExecuteCommandError extends Error { data: unknown; - constructor(message: string, data: unknown) { + exitCode: number | null; + constructor(message: string, exitCode: number | null, data?: unknown) { super(message); this.data = data; + this.exitCode = exitCode; } } @@ -80,7 +82,7 @@ export async function executeAndPipeCommands( return; } - reject(new ExecuteCommandError('The first command stdin (cmdTo) failed', err)); + reject(new ExecuteCommandError('The first command stdin (cmdTo) failed', err.errno, err)); hasRejected = true; }); @@ -89,7 +91,7 @@ export async function executeAndPipeCommands( }); cmdFrom.on('error', (err) => { - reject(new ExecuteCommandError('The first command (cmdTo) failed', err)); + reject(new ExecuteCommandError('The first command (cmdTo) failed', 1, err)); hasRejected = true; }); @@ -105,7 +107,7 @@ export async function executeAndPipeCommands( }); cmdTo.on('error', (err) => { - reject(new ExecuteCommandError('The second command failed', err)); + reject(new ExecuteCommandError('The second command failed', 1, err)); }); cmdTo.on('exit', (exitCode) => { @@ -127,7 +129,13 @@ export async function executeAndPipeCommands( console.error('error', errorText.join('')); } - reject(new ExecuteCommandError('The command failed', { exitCode, outputText, errorText })); + reject( + new ExecuteCommandError('The command failed', exitCode, { + exitCode, + outputText: outputText.join(''), + errorText: errorText.join(''), + }) + ); return; } @@ -177,7 +185,7 @@ export async function executeCliCommand({ executedCommand.on('error', (err) => { console.log(`ERROR in executeCliCommand.\nCommand: ${command} ${args.join(' ')}\nError: ${err}`); - reject(new ExecuteCommandError('The command failed', err)); + reject(new ExecuteCommandError('The command failed', 1, err)); }); executedCommand.on('close', (exitCode) => { @@ -204,7 +212,11 @@ export async function executeCliCommand({ Options provided: ${JSON.stringify(options, null, 4)}\n Stdout: ${outputText.join('')} \n Error: ${errorText.join('')}`, - exitCode + exitCode, + { + outputText: outputText.join(''), + errorText: errorText.join(''), + } ) ); return; diff --git a/src/commands/src/shared/next-gen-parse.ts b/src/commands/src/shared/next-gen-parse.ts index 12467d04c..70bba49d7 100644 --- a/src/commands/src/shared/next-gen-parse.ts +++ b/src/commands/src/shared/next-gen-parse.ts @@ -1,7 +1,7 @@ import path from 'path'; import { Job } from '../../../entities/job'; import { getDirectory } from '../../../job/jobHandler'; -import { CliCommandResponse, executeCliCommand } from '../helpers'; +import { CliCommandResponse, ExecuteCommandError, executeCliCommand } from '../helpers'; const RSTSPEC_FLAG = '--rstspec=https://raw.githubusercontent.com/mongodb/snooty-parser/latest/snooty/rstspec.toml'; interface NextGenParseParams { @@ -37,6 +37,9 @@ export async function nextGenParse({ job, patchId, isProd }: NextGenParseParams) }); return result; } catch (error) { + if (error instanceof ExecuteCommandError && error.exitCode !== 1) { + return error.data as CliCommandResponse; + } throw new Error(`next-gen-parse failed. \n ${error}`); } } diff --git a/src/job/jobHandler.ts b/src/job/jobHandler.ts index 947a5692d..73a50a1c3 100644 --- a/src/job/jobHandler.ts +++ b/src/job/jobHandler.ts @@ -14,13 +14,7 @@ import { IJobValidator } from './jobValidator'; import { RepoEntitlementsRepository } from '../repositories/repoEntitlementsRepository'; import { DocsetsRepository } from '../repositories/docsetsRepository'; import { MONOREPO_NAME } from '../monorepo/utils/monorepo-constants'; -import { - nextGenHtml, - nextGenParse, - oasPageBuild, - persistenceModule, - prepareBuildAndGetDependencies, -} from '../commands'; +import { nextGenHtml, nextGenParse, oasPageBuild, persistenceModule, prepareBuild } from '../commands'; import { downloadBuildDependencies } from '../commands/src/helpers/dependency-helpers'; import { CliCommandResponse } from '../commands/src/helpers'; require('fs'); @@ -213,17 +207,14 @@ export abstract class JobHandler { } @throwIfJobInterupted() - private async getBuildDependencies() { - const buildDependencies = await this._repoBranchesRepo.getBuildDependencies(this.currJob.payload.repoName); - if (!buildDependencies) return []; - return buildDependencies; - } - - @throwIfJobInterupted() - private async getAndBuildDependencies() { - const buildDependencies = await this.getBuildDependencies(); - const commands = await downloadBuildDependencies(buildDependencies, this.currJob.payload.repoName); - this._logger.save(this._currJob._id, commands.join('\n')); + private async getAndDownloadBuildDependencies() { + const repoName = this.currJob.payload.repoName; + const directory = this.currJob.payload.repoName === MONOREPO_NAME ? this.currJob.payload.directory : undefined; + const buildDependencies = await this._repoBranchesRepo.getBuildDependencies(repoName, directory); + if (!buildDependencies) return; + await this._logger.save(this._currJob._id, 'Identified Build dependencies'); + const commands = await downloadBuildDependencies(buildDependencies, this.currJob.payload.repoName, directory); + await this._logger.save(this._currJob._id, `${commands.join('\n')}`); } @throwIfJobInterupted() @@ -550,7 +541,7 @@ export abstract class JobHandler { this._logger.save(this._currJob._id, 'Checked Commit'); await this.pullRepo(); this._logger.save(this._currJob._id, 'Pulled Repo'); - await this.getAndBuildDependencies(); + await this.getAndDownloadBuildDependencies(); this._logger.save(this._currJob._id, 'Downloaded Build dependencies'); this.prepBuildCommands(); this._logger.save(this._currJob._id, 'Prepared Build commands'); @@ -581,8 +572,8 @@ export abstract class JobHandler { await this.setEnvironmentVariables(); this.logger.save(job._id, 'Prepared Environment variables'); - const buildDependencies = await this.getBuildDependencies(); - this._logger.save(this._currJob._id, 'Identified Build dependencies'); + await this.getAndDownloadBuildDependencies(); + this._logger.save(this._currJob._id, 'Downloaded Build dependencies'); const docset = await this._docsetsRepo.getRepo(this._currJob.payload.repoName, this._currJob.payload.directory); let env = this._config.get('env'); @@ -591,16 +582,9 @@ export abstract class JobHandler { } const baseUrl = docset?.url?.[env] || 'https://mongodbcom-cdn.website.staging.corp.mongodb.com'; - const { patchId } = await prepareBuildAndGetDependencies( - job.payload.repoName, - job.payload.project, - baseUrl, - buildDependencies, - job.payload.directory - ); + const { patchId } = await prepareBuild(job.payload.repoName, job.payload.project, baseUrl, job.payload.directory); // Set patchId on payload for use in nextGenStage this._currJob.payload.patchId = patchId; - this._logger.save(this._currJob._id, 'Downloaded Build dependencies'); let buildStepOutput: CliCommandResponse; diff --git a/src/repositories/repoBranchesRepository.ts b/src/repositories/repoBranchesRepository.ts index cf8cb1cd4..f2764c3ef 100644 --- a/src/repositories/repoBranchesRepository.ts +++ b/src/repositories/repoBranchesRepository.ts @@ -9,8 +9,9 @@ export class RepoBranchesRepository extends BaseRepository { super(config, logger, 'RepoBranchesRepository', db.collection(config.get('repoBranchesCollection'))); } - async getBuildDependencies(repoName: string): Promise { + async getBuildDependencies(repoName: string, directoryName?: string): Promise { const query = { repoName: repoName }; + if (directoryName) query['directories.snooty_toml'] = `/${directoryName}`; const repo = await this.findOne( query, `Mongo Timeout Error: Timedout while retrieving build dependencies for ${repoName}` diff --git a/src/services/slack.ts b/src/services/slack.ts index 3b6cb53ed..4cc0d39f2 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -176,13 +176,18 @@ export class SlackConnector implements ISlackConnector { private _buildDropdown(branches: Array, triggerId: string): any { let reposToShow: Array = []; branches.forEach((fullPath) => { - const fullBranchPath = fullPath; + const displayBranchPath = fullPath; + let valueBranchPath = fullPath; + const isInactive = fullPath.startsWith('(!inactive)'); + if (isInactive == true) { + valueBranchPath = fullPath.slice(12); + } const opt = { text: { type: 'plain_text', - text: fullBranchPath, + text: displayBranchPath, }, - value: fullBranchPath, + value: valueBranchPath, }; reposToShow.push(opt); });