Skip to content

Commit c842ebb

Browse files
committed
feat(verification): removed the alpha branch from the list of triggers 4 the verification workflow
since the release workflow is triggered directly for that branch rather than being gated by verification passing first
1 parent 66b205f commit c842ebb

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

src/semantic-release/ci-providers/github-workflows/lifter-test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ suite('github-workflows lifter for semantic-release', () => {
2929

3030
const commonVerificationWorkflowContents = any.string();
3131
fs.readFile.withArgs(`${workflowsDirectory}/node-ci.yml`, 'utf-8').resolves(commonVerificationWorkflowContents);
32-
jsYaml.load.withArgs(commonVerificationWorkflowContents).returns({jobs: {}});
32+
jsYaml.load.withArgs(commonVerificationWorkflowContents).returns({on: {push: {branches: []}}, jobs: {}});
3333
});
3434

3535
teardown(() => sandbox.restore());
@@ -56,14 +56,21 @@ suite('github-workflows lifter for semantic-release', () => {
5656
const jobs = any.simpleObject();
5757
const legacyReleaseJob = any.simpleObject();
5858
const updatedVerificationWorkflowContents = any.string();
59+
const branchTriggers = any.listOf(any.word);
60+
const moreBranchTriggers = any.listOf(any.word);
5961
core.fileExists.resolves(true);
6062
fs.readFile.withArgs(`${workflowsDirectory}/node-ci.yml`, 'utf-8').resolves(verificationWorkflowContents);
6163
jsYaml.load
6264
.withArgs(verificationWorkflowContents)
63-
.returns({...parsedVerificationWorkflowContents, jobs: {...jobs, release: legacyReleaseJob}});
65+
.returns({
66+
...parsedVerificationWorkflowContents,
67+
on: {push: {branches: [...branchTriggers, 'alpha', ...moreBranchTriggers]}},
68+
jobs: {...jobs, release: legacyReleaseJob}
69+
});
6470
jsYaml.dump
6571
.withArgs({
6672
...parsedVerificationWorkflowContents,
73+
on: {push: {branches: [...branchTriggers, ...moreBranchTriggers]}},
6774
jobs: {
6875
...jobs,
6976
'trigger-release': {

src/semantic-release/ci-providers/github-workflows/lifter.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {promises as fs} from 'fs';
2-
import {load, dump} from 'js-yaml';
2+
import {dump, load} from 'js-yaml';
33
import {fileExists} from '@form8ion/core';
44

55
import scaffoldReleaseWorkflow from './scaffolder';
@@ -12,6 +12,11 @@ export default async function ({projectRoot, vcs: {name: vcsProjectName, owner:
1212
}
1313

1414
const parsedVerificationWorkflowDetails = load(await fs.readFile(pathToVerificationWorkflow, 'utf-8'));
15+
16+
parsedVerificationWorkflowDetails.on.push.branches = parsedVerificationWorkflowDetails.on.push.branches.filter(
17+
branch => 'alpha' !== branch
18+
);
19+
1520
const {release, ...otherJobs} = parsedVerificationWorkflowDetails.jobs;
1621
parsedVerificationWorkflowDetails.jobs = {
1722
...otherJobs,

test/integration/features/step_definitions/common-steps.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ When('the project is lifted', async function () {
3636
workflows: {
3737
...this.verificationWorkflow && {
3838
'node-ci.yml': dump({
39+
on: {
40+
push: {
41+
branches: [
42+
'master',
43+
...this.alphaBranchTrigger ? ['alpha'] : [],
44+
...this.betaBranchTrigger ? ['beta'] : [],
45+
'dependency-updater/**'
46+
]
47+
}
48+
},
3949
jobs: {
4050
...this.nodeCiWithReleaseJob && {
4151
release: {}

test/integration/features/step_definitions/github-workflows-steps.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Given('legacy releases are configured in a GitHub workflow', async function () {
99
this.githubWorkflows = true;
1010
this.verificationWorkflow = true;
1111
this.nodeCiWithReleaseJob = true;
12+
this.alphaBranchTrigger = true;
13+
this.betaBranchTrigger = true;
1214
});
1315

1416
Given('modern releases are configured in a GitHub workflow', async function () {
@@ -43,6 +45,8 @@ Then('the verification workflow triggers the release workflow', async function (
4345
'utf-8'
4446
));
4547

48+
assert.deepEqual(verificationWorkflowDefinition.on.push.branches, ['master', 'beta', 'dependency-updater/**']);
49+
4650
const verificationWorkflowJobs = verificationWorkflowDefinition.jobs;
4751
const triggerReleaseJob = verificationWorkflowJobs['trigger-release'];
4852

0 commit comments

Comments
 (0)