@@ -54,6 +54,9 @@ describe("githubInputs", () => {
5454 const sha = "1234abcd-12ab-34cd-56ef-1234567890ab" ;
5555 const pullRequestSha = "181600acb3cfb803f4570d0018928be5d730c00d" ;
5656
57+ const updateInterval = "5" ;
58+ const updateBackOff = "10" ;
59+
5760 it ( "build basic parameters for codeBuild.startBuild" , ( ) => {
5861 // This is how GITHUB injects its input values.
5962 // It would be nice if there was an easy way to test this...
@@ -71,8 +74,12 @@ describe("githubInputs", () => {
7174 expect ( test )
7275 . to . haveOwnProperty ( "buildspecOverride" )
7376 . and . to . equal ( undefined ) ;
74- expect ( test ) . to . haveOwnProperty ( "computeTypeOverride" ) . and . to . equal ( undefined ) ;
75- expect ( test ) . to . haveOwnProperty ( "environmentTypeOverride" ) . and . to . equal ( undefined ) ;
77+ expect ( test )
78+ . to . haveOwnProperty ( "computeTypeOverride" )
79+ . and . to . equal ( undefined ) ;
80+ expect ( test )
81+ . to . haveOwnProperty ( "environmentTypeOverride" )
82+ . and . to . equal ( undefined ) ;
7683 expect ( test ) . to . haveOwnProperty ( "imageOverride" ) . and . to . equal ( undefined ) ;
7784 expect ( test ) . to . haveOwnProperty ( "envPassthrough" ) . and . to . deep . equal ( [ ] ) ;
7885 } ) ;
@@ -123,8 +130,12 @@ describe("githubInputs", () => {
123130 expect ( test )
124131 . to . haveOwnProperty ( "buildspecOverride" )
125132 . and . to . equal ( undefined ) ;
126- expect ( test ) . to . haveOwnProperty ( "computeTypeOverride" ) . and . to . equal ( undefined ) ;
127- expect ( test ) . to . haveOwnProperty ( "environmentTypeOverride" ) . and . to . equal ( undefined ) ;
133+ expect ( test )
134+ . to . haveOwnProperty ( "computeTypeOverride" )
135+ . and . to . equal ( undefined ) ;
136+ expect ( test )
137+ . to . haveOwnProperty ( "environmentTypeOverride" )
138+ . and . to . equal ( undefined ) ;
128139 expect ( test ) . to . haveOwnProperty ( "imageOverride" ) . and . to . equal ( undefined ) ;
129140 expect ( test ) . to . haveOwnProperty ( "envPassthrough" ) . and . to . deep . equal ( [ ] ) ;
130141 } ) ;
@@ -144,6 +155,24 @@ describe("githubInputs", () => {
144155 "No source version could be evaluated."
145156 ) ;
146157 } ) ;
158+ it ( "can handle configuring update call-rate" , ( ) => {
159+ process . env [ `INPUT_PROJECT-NAME` ] = projectName ;
160+ process . env [ `INPUT_UPDATE-INTERVAL` ] = updateInterval ;
161+ process . env [ `INPUT_UPDATE-BACK-OFF` ] = updateBackOff ;
162+ process . env [ `GITHUB_REPOSITORY` ] = repoInfo ;
163+ process . env [ `GITHUB_SHA` ] = sha ;
164+
165+ require ( "@actions/github" ) . context . payload = { } ;
166+
167+ const test = githubInputs ( ) ;
168+
169+ expect ( test )
170+ . to . haveOwnProperty ( "updateInterval" )
171+ . and . to . equal ( updateInterval ) ;
172+ expect ( test )
173+ . to . haveOwnProperty ( "updateBackOff" )
174+ . and . to . equal ( updateBackOff ) ;
175+ } ) ;
147176} ) ;
148177
149178describe ( "inputs2Parameters" , ( ) => {
@@ -179,8 +208,12 @@ describe("inputs2Parameters", () => {
179208 expect ( test )
180209 . to . haveOwnProperty ( "buildspecOverride" )
181210 . and . to . equal ( undefined ) ;
182- expect ( test ) . to . haveOwnProperty ( "computeTypeOverride" ) . and . to . equal ( undefined ) ;
183- expect ( test ) . to . haveOwnProperty ( "environmentTypeOverride" ) . and . to . equal ( undefined ) ;
211+ expect ( test )
212+ . to . haveOwnProperty ( "computeTypeOverride" )
213+ . and . to . equal ( undefined ) ;
214+ expect ( test )
215+ . to . haveOwnProperty ( "environmentTypeOverride" )
216+ . and . to . equal ( undefined ) ;
184217 expect ( test ) . to . haveOwnProperty ( "imageOverride" ) . and . to . equal ( undefined ) ;
185218
186219 // I send everything that starts 'GITHUB_'
@@ -218,7 +251,8 @@ describe("inputs2Parameters", () => {
218251 repo : "repo" ,
219252 computeTypeOverride : "BUILD_GENERAL1_LARGE" ,
220253 environmentTypeOverride : "LINUX_CONTAINER" ,
221- imageOverride : "111122223333.dkr.ecr.us-west-2.amazonaws.com/codebuild-docker-repo"
254+ imageOverride :
255+ "111122223333.dkr.ecr.us-west-2.amazonaws.com/codebuild-docker-repo" ,
222256 } ) ;
223257 expect ( test ) . to . haveOwnProperty ( "projectName" ) . and . to . equal ( projectName ) ;
224258 expect ( test ) . to . haveOwnProperty ( "sourceVersion" ) . and . to . equal ( sha ) ;
@@ -239,7 +273,9 @@ describe("inputs2Parameters", () => {
239273 . and . to . equal ( `LINUX_CONTAINER` ) ;
240274 expect ( test )
241275 . to . haveOwnProperty ( "imageOverride" )
242- . and . to . equal ( `111122223333.dkr.ecr.us-west-2.amazonaws.com/codebuild-docker-repo` ) ;
276+ . and . to . equal (
277+ `111122223333.dkr.ecr.us-west-2.amazonaws.com/codebuild-docker-repo`
278+ ) ;
243279
244280 // I send everything that starts 'GITHUB_'
245281 expect ( test )
@@ -322,6 +358,7 @@ describe("inputs2Parameters", () => {
322358} ) ;
323359
324360describe ( "waitForBuildEndTime" , ( ) => {
361+ const defaultConfig = { updateInterval : 30 , updateBackOff : 15 } ;
325362 it ( "basic usages" , async ( ) => {
326363 let count = 0 ;
327364 const buildID = "buildID" ;
@@ -341,10 +378,14 @@ describe("waitForBuildEndTime", () => {
341378 ( ) => logReplies [ 0 ]
342379 ) ;
343380
344- const test = await waitForBuildEndTime ( sdk , {
345- id : buildID ,
346- logs : { cloudWatchLogsArn } ,
347- } ) ;
381+ const test = await waitForBuildEndTime (
382+ sdk ,
383+ {
384+ id : buildID ,
385+ logs : { cloudWatchLogsArn } ,
386+ } ,
387+ defaultConfig
388+ ) ;
348389
349390 expect ( test ) . to . equal ( buildReplies . pop ( ) . builds [ 0 ] ) ;
350391 expect ( count ) . to . equal ( 2 ) ;
@@ -388,10 +429,15 @@ describe("waitForBuildEndTime", () => {
388429 ( ) => logReplies [ count - 1 ]
389430 ) ;
390431
391- const test = await waitForBuildEndTime ( sdk , {
392- id : buildID ,
393- logs : { cloudWatchLogsArn : nullArn } ,
394- } ) ;
432+ const test = await waitForBuildEndTime (
433+ sdk ,
434+ {
435+ id : buildID ,
436+ logs : { cloudWatchLogsArn : nullArn } ,
437+ } ,
438+ defaultConfig
439+ ) ;
440+
395441 expect ( test ) . to . equal ( buildReplies . pop ( ) . builds [ 0 ] ) ;
396442 expect ( count ) . to . equal ( 4 ) ;
397443 } ) ;
@@ -438,11 +484,12 @@ describe("waitForBuildEndTime", () => {
438484 ) ;
439485
440486 const test = await waitForBuildEndTime (
441- { ...sdk , wait : 1 , backOff : 1 } ,
487+ { ...sdk } ,
442488 {
443489 id : buildID ,
444490 logs : { cloudWatchLogsArn : nullArn } ,
445- }
491+ } ,
492+ { updateInterval : 1 , updateBackOff : 1 }
446493 ) ;
447494
448495 expect ( test . id ) . to . equal ( buildID ) ;
@@ -490,11 +537,12 @@ describe("waitForBuildEndTime", () => {
490537
491538 try {
492539 await waitForBuildEndTime (
493- { ...sdk , wait : 1 , backOff : 1 } ,
540+ { ...sdk } ,
494541 {
495542 id : buildID ,
496543 logs : { cloudWatchLogsArn : nullArn } ,
497- }
544+ } ,
545+ defaultConfig
498546 ) ;
499547 } catch ( err ) {
500548 didFail = true ;
@@ -526,7 +574,7 @@ function help(builds, logs) {
526574 } ,
527575 } ;
528576
529- return { codeBuild, cloudWatchLogs, wait : 10 } ;
577+ return { codeBuild, cloudWatchLogs } ;
530578
531579 function ret ( thing ) {
532580 if ( typeof thing === "function" ) return thing ( ) ;
0 commit comments