Skip to content

Commit

Permalink
fix dependency effects (#31)
Browse files Browse the repository at this point in the history
fix dependency effects
  • Loading branch information
joscha authored Oct 28, 2019
2 parents ebbced0 + 5b00939 commit 6bdb76d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/__tests__/__snapshots__/conditional.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ exports[`buildkite-graph Steps Command isEffectOf later steps affect earlier eff
"* <build app>
* [wait]
* <deploy app>
* [wait]
* <release app>
* <run integration tests>"
`;
Expand Down
31 changes: 22 additions & 9 deletions src/__tests__/conditional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,28 +333,41 @@ describe('buildkite-graph', () => {
createTest(
'later steps affect earlier effects',
() => {
const p = new Pipeline('x');
const buildConditional = new MyConditional(
new CommandStep('build app'),
() => new CommandStep('build app'),
false,
);
p.add(buildConditional);

const deployApp = new CommandStep(
'deploy app',
).isEffectOf(buildConditional);
p.add(deployApp);

const releaseApp = new CommandStep(
'release app',
).isEffectOf(deployApp);
p.add(releaseApp);

const tests = new MyConditional(
() =>
new CommandStep(
'run integration tests',
).dependsOn(buildConditional),
new Promise<Step>(resolve =>
setTimeout(
() =>
resolve(
new CommandStep(
'run integration tests',
).dependsOn(buildConditional),
),
100,
),
),
true,
);
p.add(tests);

return new Pipeline('x').add(
buildConditional,
deployApp,
tests,
);
return p;
},
['structure'],
);
Expand Down
10 changes: 2 additions & 8 deletions src/sortedSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,8 @@ export async function sortedSteps(
);
addDependency(dependency);
for (const removedEffectStep of removedEffects) {
if (
removedEffectStep.effectDependencies.has(
potentialDependency,
)
) {
removedEffects.delete(removedEffectStep);
await iterateAndAddEffect(removedEffectStep);
}
removedEffects.delete(removedEffectStep);
await iterateAndAddEffect(removedEffectStep);
}
}
}
Expand Down

0 comments on commit 6bdb76d

Please sign in to comment.