Skip to content

Commit

Permalink
feat(2822): Extend normal job fields to pr job (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
itleigns authored Feb 2, 2024
1 parent c042c83 commit a41de0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 5 additions & 3 deletions lib/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,11 @@ class PipelineModel extends BaseModel {
j => !j.name.startsWith(`PR-${prNum}:`) && jobsToCreate.includes(j.name)
);

// create a map for PR Parent Jobs like: {main: 1, publish: 2}
// create a map for PR Parent Jobs like: {main: {id: 1}, publish: {id: 2}}
const prParentJobIdMap = {};

prFromPipelineJobs.forEach(j => {
prParentJobIdMap[j.name] = j.id;
prParentJobIdMap[j.name] = j;
});

// Create missing PR jobs
Expand All @@ -677,7 +677,9 @@ class PipelineModel extends BaseModel {

// If there is a pr parent
if (prParentJobIdMap[jobName]) {
jobModel.prParentJobId = prParentJobIdMap[jobName];
jobModel.prParentJobId = prParentJobIdMap[jobName].id;
jobModel.templateId = prParentJobIdMap[jobName].templateId;
jobModel.description = prParentJobIdMap[jobName].description;
}

// Create jobs
Expand Down
14 changes: 11 additions & 3 deletions test/lib/pipeline.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ describe('Pipeline Model', () => {
testJob = getJobMocks({
id: 100,
name: 'test',
description: 'test job',
templateId: 5,
archived: false
});

Expand Down Expand Up @@ -1600,7 +1602,9 @@ describe('Pipeline Model', () => {
}
],
pipelineId: testId,
prParentJobId: 100
prParentJobId: 100,
templateId: 5,
description: 'test job'
});
assert.calledWith(
jobFactoryMock.create.secondCall,
Expand Down Expand Up @@ -1714,7 +1718,9 @@ describe('Pipeline Model', () => {
}
],
pipelineId: testId,
prParentJobId: 100
prParentJobId: 100,
templateId: 5,
description: 'test job'
});
assert.calledWith(
jobFactoryMock.create.secondCall,
Expand Down Expand Up @@ -1951,7 +1957,9 @@ describe('Pipeline Model', () => {
permutations: PARSED_YAML.jobs.main,
pipelineId: testId,
name: 'PR-2:main',
prParentJobId: 99998
prParentJobId: 99998,
templateId: undefined,
description: undefined
});
});
});
Expand Down

0 comments on commit a41de0d

Please sign in to comment.