@@ -188,6 +188,21 @@ func TestPinActions(t *testing.T) {
188
188
}
189
189
]` ))
190
190
191
+ httpmock .RegisterResponder ("GET" , "https://api.github.com/repos/github/codeql-action/commits/v3.28.2" ,
192
+ httpmock .NewStringResponder (200 , `d68b2d4edb4189fd2a5366ac14e72027bd4b37dd` ))
193
+
194
+ httpmock .RegisterResponder ("GET" , "https://api.github.com/repos/github/codeql-action/git/matching-refs/tags/v3.28.2." ,
195
+ httpmock .NewStringResponder (200 ,
196
+ `[
197
+ {
198
+ "ref": "refs/tags/v3.28.2",
199
+ "object": {
200
+ "sha": "d68b2d4edb4189fd2a5366ac14e72027bd4b37dd",
201
+ "type": "commit"
202
+ }
203
+ }
204
+ ]` ))
205
+
191
206
// mock ping response
192
207
httpmock .RegisterResponder ("GET" , "https://ghcr.io/v2/" ,
193
208
httpmock .NewStringResponder (200 , `` ))
@@ -263,19 +278,23 @@ func TestPinActions(t *testing.T) {
263
278
})
264
279
265
280
tests := []struct {
266
- fileName string
267
- wantUpdated bool
281
+ fileName string
282
+ wantUpdated bool
283
+ exemptedActions []string
284
+ pinToImmutable bool
268
285
}{
269
- {fileName : "alreadypinned.yml" , wantUpdated : false },
270
- {fileName : "branch.yml" , wantUpdated : true },
271
- {fileName : "localaction.yml" , wantUpdated : true },
272
- {fileName : "multiplejobs.yml" , wantUpdated : true },
273
- {fileName : "basic.yml" , wantUpdated : true },
274
- {fileName : "dockeraction.yml" , wantUpdated : true },
275
- {fileName : "multipleactions.yml" , wantUpdated : true },
276
- {fileName : "actionwithcomment.yml" , wantUpdated : true },
277
- {fileName : "repeatedactionwithcomment.yml" , wantUpdated : true },
278
- {fileName : "immutableaction-1.yml" , wantUpdated : true },
286
+ {fileName : "alreadypinned.yml" , wantUpdated : false , pinToImmutable : true },
287
+ {fileName : "branch.yml" , wantUpdated : true , pinToImmutable : true },
288
+ {fileName : "localaction.yml" , wantUpdated : true , pinToImmutable : true },
289
+ {fileName : "multiplejobs.yml" , wantUpdated : true , pinToImmutable : true },
290
+ {fileName : "basic.yml" , wantUpdated : true , pinToImmutable : true },
291
+ {fileName : "dockeraction.yml" , wantUpdated : true , pinToImmutable : true },
292
+ {fileName : "multipleactions.yml" , wantUpdated : true , pinToImmutable : true },
293
+ {fileName : "actionwithcomment.yml" , wantUpdated : true , pinToImmutable : true },
294
+ {fileName : "repeatedactionwithcomment.yml" , wantUpdated : true , pinToImmutable : true },
295
+ {fileName : "immutableaction-1.yml" , wantUpdated : true , pinToImmutable : true },
296
+ {fileName : "exemptaction.yml" , wantUpdated : true , exemptedActions : []string {"actions/checkout" , "rohith/*" }, pinToImmutable : true },
297
+ {fileName : "donotpintoimmutable.yml" , wantUpdated : true , pinToImmutable : false },
279
298
}
280
299
for _ , tt := range tests {
281
300
input , err := ioutil .ReadFile (path .Join (inputDirectory , tt .fileName ))
@@ -284,7 +303,7 @@ func TestPinActions(t *testing.T) {
284
303
log .Fatal (err )
285
304
}
286
305
287
- output , gotUpdated , err := PinActions (string (input ))
306
+ output , gotUpdated , err := PinActions (string (input ), tt . exemptedActions , tt . pinToImmutable )
288
307
if tt .wantUpdated != gotUpdated {
289
308
t .Errorf ("test failed wantUpdated %v did not match gotUpdated %v" , tt .wantUpdated , gotUpdated )
290
309
}
0 commit comments