Skip to content

Commit

Permalink
DOP-3723: Use Autobuilder job id as persistence module build id
Browse files Browse the repository at this point in the history
  • Loading branch information
rayangler committed Sep 21, 2023
1 parent d6d3091 commit c8f66ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions modules/persistence/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { upsertAssets } from './src/services/assets';
interface ModuleArgs {
path: string;
githubUser: string;
jobId?: string;
strict: string;
[props: string | number | symbol]: unknown;
}
Expand All @@ -30,14 +31,14 @@ const missingPathMessage = 'No path specified in arguments - please specify a bu
// Load command line args into a parameterized argv
const argv: ModuleArgs = minimist(process.argv.slice(2));

const app = async (path: string, githubUser: string) => {
const app = async (path: string, githubUser: string, jobId?: string) => {
try {
if (!path) throw missingPathMessage;
const user = githubUser || 'docs-builder-bot';
const zip = new AdmZip(path);
// atomic buildId for all artifacts read by this module - fundamental assumption
// that only one build will be used per run of this module.
const buildId = new mongodb.ObjectId();
const buildId = new mongodb.ObjectId(jobId);
const metadata = await metadataFromZip(zip, user);
// initialize db connections to handle shared connections
await snootyDb();
Expand All @@ -55,7 +56,7 @@ const app = async (path: string, githubUser: string) => {
}
};

app(argv['path'], argv['githubUser']).catch(() => {
app(argv['path'], argv['githubUser'], argv['jobId']).catch(() => {
console.error('Persistence Module Failure. Ending build.');
process.exit(1);
});
2 changes: 1 addition & 1 deletion src/job/productionJobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class ProductionJobHandler extends JobHandler {
if (this.currJob?.buildCommands) {
this.currJob.buildCommands[this.currJob.buildCommands.length - 1] = 'make get-build-dependencies';
this.currJob.buildCommands.push('make next-gen-parse');
this.currJob.buildCommands.push('make persistence-module');
this.currJob.buildCommands.push(`make persistence-module JOB_ID=${this.currJob._id}`);
this.currJob.buildCommands.push('make next-gen-html');
this.currJob.buildCommands.push(`make oas-page-build MUT_PREFIX=${this.currJob.payload.mutPrefix}`);
}
Expand Down
4 changes: 3 additions & 1 deletion src/job/stagingJobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export class StagingJobHandler extends JobHandler {
prepStageSpecificNextGenCommands(): void {
if (this.currJob.buildCommands) {
this.currJob.buildCommands[this.currJob.buildCommands.length - 1] = 'make next-gen-parse';
this.currJob.buildCommands.push(`make persistence-module GH_USER=${this.currJob.payload.repoOwner}`);
this.currJob.buildCommands.push(
`make persistence-module GH_USER=${this.currJob.payload.repoOwner} JOB_ID=${this.currJob._id}`
);
this.currJob.buildCommands.push('make next-gen-html');
const project = this.currJob.payload.project === 'cloud-docs' ? this.currJob.payload.project : '';
const branchName = /^[a-zA-Z0-9_\-\./]+$/.test(this.currJob.payload.branchName)
Expand Down

0 comments on commit c8f66ab

Please sign in to comment.