@@ -6,12 +6,12 @@ import io.github.typesafegithub.workflows.actions.endbug.AddAndCommit
66import io.github.typesafegithub.workflows.annotations.ExperimentalKotlinLogicStep
77import io.github.typesafegithub.workflows.domain.Concurrency
88import io.github.typesafegithub.workflows.domain.RunnerType
9- import io.github.typesafegithub.workflows.domain.actions.Action
109import io.github.typesafegithub.workflows.domain.actions.Action.Outputs
1110import io.github.typesafegithub.workflows.domain.actions.RegularAction
1211import io.github.typesafegithub.workflows.domain.triggers.Push
1312import io.github.typesafegithub.workflows.dsl.expressions.expr
1413import io.github.typesafegithub.workflows.dsl.workflow
14+ import io.github.typesafegithub.workflows.yaml.CheckoutActionVersionSource
1515import io.github.typesafegithub.workflows.yaml.ConsistencyCheckJobConfig.Disabled
1616import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG
1717import io.github.typesafegithub.workflows.yaml.Preamble.Just
@@ -318,6 +318,122 @@ class IntegrationTest :
318318 """ .trimIndent()
319319 }
320320
321+ test(" actions/checkout's version given explicitly" ) {
322+ // when
323+ workflow(
324+ name = " Test workflow" ,
325+ on = listOf (Push ()),
326+ sourceFile = sourceTempFile,
327+ consistencyCheckJobConfig =
328+ DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG .copy(
329+ checkoutActionVersion = CheckoutActionVersionSource .Given (" v123" ),
330+ ),
331+ ) {
332+ job(
333+ id = " test_job" ,
334+ runsOn = RunnerType .UbuntuLatest ,
335+ ) {
336+ run (
337+ name = " Hello world!" ,
338+ command = " echo 'hello!'" ,
339+ )
340+ }
341+ }
342+
343+ // then
344+ targetTempFile.readText() shouldBe
345+ """
346+ # This file was generated using Kotlin DSL (.github/workflows/some_workflow.main.kts).
347+ # If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
348+ # Generated with https://github.com/typesafegithub/github-workflows-kt
349+
350+ name: 'Test workflow'
351+ on:
352+ push: {}
353+ jobs:
354+ check_yaml_consistency:
355+ name: 'Check YAML consistency'
356+ runs-on: 'ubuntu-latest'
357+ steps:
358+ - id: 'step-0'
359+ name: 'Check out'
360+ uses: 'actions/checkout@v123'
361+ - id: 'step-1'
362+ name: 'Execute script'
363+ run: 'rm ''.github/workflows/some_workflow.yaml'' && ''.github/workflows/some_workflow.main.kts'''
364+ - id: 'step-2'
365+ name: 'Consistency check'
366+ run: 'git diff --exit-code ''.github/workflows/some_workflow.yaml'''
367+ test_job:
368+ runs-on: 'ubuntu-latest'
369+ needs:
370+ - 'check_yaml_consistency'
371+ steps:
372+ - id: 'step-0'
373+ name: 'Hello world!'
374+ run: 'echo ''hello!'''
375+
376+ """ .trimIndent()
377+ }
378+
379+ test(" actions/checkout's version inferred from classpath" ) {
380+ // when
381+ workflow(
382+ name = " Test workflow" ,
383+ on = listOf (Push ()),
384+ sourceFile = sourceTempFile,
385+ consistencyCheckJobConfig =
386+ DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG .copy(
387+ checkoutActionVersion = CheckoutActionVersionSource .InferredFromClasspath
388+ ),
389+ ) {
390+ job(
391+ id = " test_job" ,
392+ runsOn = RunnerType .UbuntuLatest ,
393+ ) {
394+ run (
395+ name = " Hello world!" ,
396+ command = " echo 'hello!'" ,
397+ )
398+ }
399+ }
400+
401+ // then
402+ targetTempFile.readText() shouldBe
403+ """
404+ # This file was generated using Kotlin DSL (.github/workflows/some_workflow.main.kts).
405+ # If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
406+ # Generated with https://github.com/typesafegithub/github-workflows-kt
407+
408+ name: 'Test workflow'
409+ on:
410+ push: {}
411+ jobs:
412+ check_yaml_consistency:
413+ name: 'Check YAML consistency'
414+ runs-on: 'ubuntu-latest'
415+ steps:
416+ - id: 'step-0'
417+ name: 'Check out'
418+ uses: 'actions/checkout@v4'
419+ - id: 'step-1'
420+ name: 'Execute script'
421+ run: 'rm ''.github/workflows/some_workflow.yaml'' && ''.github/workflows/some_workflow.main.kts'''
422+ - id: 'step-2'
423+ name: 'Consistency check'
424+ run: 'git diff --exit-code ''.github/workflows/some_workflow.yaml'''
425+ test_job:
426+ runs-on: 'ubuntu-latest'
427+ needs:
428+ - 'check_yaml_consistency'
429+ steps:
430+ - id: 'step-0'
431+ name: 'Hello world!'
432+ run: 'echo ''hello!'''
433+
434+ """ .trimIndent()
435+ }
436+
321437 test(" with concurrency, default behavior" ) {
322438 // when
323439 workflow(
0 commit comments