@@ -12,6 +12,8 @@ import {Before, Given, Then} from '@cucumber/cucumber';
1212import { assert } from 'chai' ;
1313import any from '@travi/any' ;
1414
15+ const ciWorkflowName = 'node-ci' ;
16+
1517Before ( async function ( ) {
1618 this . prTriggerConfig = any . simpleObject ( ) ;
1719
@@ -23,7 +25,7 @@ Given('a CI workflow exists', async function () {
2325
2426 await writeWorkflowFile ( {
2527 projectRoot : this . projectRoot ,
26- name : 'node-ci' ,
28+ name : ciWorkflowName ,
2729 config : {
2830 on : {
2931 push : { branches : this . existingBranches } ,
@@ -35,14 +37,14 @@ Given('a CI workflow exists', async function () {
3537} ) ;
3638
3739Given ( 'a {string} job exists' , async function ( jobName ) {
38- const existingWorkflowContents = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : 'node-ci' } ) ;
40+ const existingWorkflowContents = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : ciWorkflowName } ) ;
3941 const job = any . simpleObject ( ) ;
4042
4143 this . injectedJobs [ jobName ] = job ;
4244
4345 await writeWorkflowFile ( {
4446 projectRoot : this . projectRoot ,
45- name : 'node-ci' ,
47+ name : ciWorkflowName ,
4648 config : {
4749 ...existingWorkflowContents ,
4850 jobs : {
@@ -54,7 +56,7 @@ Given('a {string} job exists', async function (jobName) {
5456} ) ;
5557
5658Then ( 'the ci config remains unchanged' , async function ( ) {
57- const { on : triggers , jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : 'node-ci' } ) ;
59+ const { on : triggers , jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : ciWorkflowName } ) ;
5860
5961 assert . deepEqual ( triggers . push . branches , this . existingBranches ) ;
6062 assert . deepEqual ( triggers . pull_request , this . prTriggerConfig ) ;
@@ -65,7 +67,7 @@ Then('the ci config remains unchanged', async function () {
6567} ) ;
6668
6769Then ( 'dependency caching is enabled' , async function ( ) {
68- const { jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : 'node-ci' } ) ;
70+ const { jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : ciWorkflowName } ) ;
6971
7072 const setupNodeStep = jobs [ this . existingJobName ] . steps . find ( step => 'Setup node' === step . name ) ;
7173 assert . equal ( setupNodeStep . with . cache , 'npm' ) ;
@@ -78,7 +80,7 @@ Then('the verification workflow is created', async function () {
7880 env,
7981 permissions,
8082 jobs
81- } = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : 'node-ci' } ) ;
83+ } = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : ciWorkflowName } ) ;
8284
8385 assert . equal ( name , 'Node.js CI' ) ;
8486 assert . deepEqual (
@@ -102,19 +104,26 @@ Then('the verification workflow is created', async function () {
102104} ) ;
103105
104106Then ( 'the workflow-result job exists' , async function ( ) {
105- const { jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : 'node-ci' } ) ;
107+ const { jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : ciWorkflowName } ) ;
106108
107109 assert . include ( Object . keys ( jobs ) , 'workflow-result' ) ;
108110} ) ;
109111
110112Then ( 'the {string} job is unchanged' , async function ( jobName ) {
111- const { jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : 'node-ci' } ) ;
113+ const { jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : ciWorkflowName } ) ;
112114
113115 assert . deepEqual ( jobs [ jobName ] , this . injectedJobs [ jobName ] ) ;
114116} ) ;
115117
116118Then ( 'the workflow-result job depends on {string}' , async function ( jobName ) {
117- const { jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : 'node-ci' } ) ;
119+ const { jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : ciWorkflowName } ) ;
118120
119121 assert . include ( jobs [ 'workflow-result' ] . needs , jobName ) ;
120122} ) ;
123+
124+ Then ( 'the workflow-result job uses {string} as the runner' , async function ( runner ) {
125+ const { jobs} = await loadWorkflowFile ( { projectRoot : this . projectRoot , name : ciWorkflowName } ) ;
126+ const { 'workflow-result' : resultJob } = jobs ;
127+
128+ assert . equal ( resultJob [ 'runs-on' ] , runner ) ;
129+ } ) ;
0 commit comments