Skip to content

Commit

Permalink
fix: Add teardown checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyi committed Apr 25, 2024
1 parent 4c74726 commit 4eb1e79
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
6 changes: 6 additions & 0 deletions features/stages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Feature: Stage
Then the "stage@simple_fail" stageBuild status is "FAILURE"
And the "stage@simple_fail:teardown" job is triggered
And the "target" job is not triggered
And the "stage@simple_fail:teardown" build succeeded
And the "stage@simple_fail" stageBuild status is "FAILURE"

Scenario: Downstream builds within a stage are not triggered if upstream build in stage is not successful.
Given an existing pipeline on branch "stageFail2" with the workflow jobs:
Expand All @@ -57,6 +59,8 @@ Feature: Stage
And the "stage@incomplete_fail:teardown" job is triggered
And the "c" job is not triggered
And the "target" job is not triggered
And the "stage@incomplete_fail:teardown" build succeeded
And the "stage@incomplete_fail" stageBuild status is "FAILURE"

Scenario: Downstream builds are triggered if required stage is successful.
Given an existing pipeline on branch "stageSuccess1" with the workflow jobs:
Expand All @@ -78,3 +82,5 @@ Feature: Stage
And the "stage@simple_success:teardown" job is triggered
And the "target" job is triggered
And the "target" build succeeded
And the "stage@simple_success:teardown" build succeeded
And the "stage@simple_success" stageBuild status is "SUCCESS"
3 changes: 1 addition & 2 deletions features/step_definitions/stage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

const Assert = require('chai').assert;
const { Before, Given, When, Then } = require('@cucumber/cucumber');
const request = require('screwdriver-request');
const { Before, Given, Then } = require('@cucumber/cucumber');
const sdapi = require('../support/sdapi');

const TIMEOUT = 240 * 1000;
Expand Down
14 changes: 6 additions & 8 deletions features/step_definitions/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,14 @@ Then(
config.desiredSha = this.sha;
}

return sdapi
.searchForBuild(config)
.then(build => {
this.eventId = build.eventId;
const job = this.jobs.find(j => j.name === jobName);
return sdapi.searchForBuild(config).then(build => {
this.eventId = build.eventId;
const job = this.jobs.find(j => j.name === jobName);

Assert.equal(build.jobId, job.id);
Assert.equal(build.jobId, job.id);

this.buildId = build.id;
});
this.buildId = build.id;
});
}
);

Expand Down

0 comments on commit 4eb1e79

Please sign in to comment.