Skip to content

Commit

Permalink
Use Maven-based bindings for GitHub Actions workflows DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Aug 15, 2024
1 parent 2c0326d commit 9c1480a
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 54 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/check-action-typing.main.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env kotlin

/*
* Copyright 2020-2023 Björn Kautler
* Copyright 2020-2024 Björn Kautler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,9 +17,12 @@
*/

@file:Import("workflow-with-copyright.main.kts")
@file:Repository("https://bindings.krzeminski.it/")
@file:DependsOn("actions:checkout:v4")
@file:DependsOn("typesafegithub:github-actions-typing:v1")

import io.github.typesafegithub.workflows.actions.actions.CheckoutV3
import io.github.typesafegithub.workflows.actions.typesafegithub.GithubActionsTypingV1
import io.github.typesafegithub.workflows.actions.actions.Checkout
import io.github.typesafegithub.workflows.actions.typesafegithub.GithubActionsTyping
import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest
import io.github.typesafegithub.workflows.domain.triggers.PullRequest
import io.github.typesafegithub.workflows.domain.triggers.Push
Expand All @@ -43,11 +46,11 @@ workflowWithCopyright(
)
uses(
name = "Checkout",
action = CheckoutV3()
action = Checkout()
)
uses(
name = "Check Action Typing",
action = GithubActionsTypingV1()
action = GithubActionsTyping()
)
}
}
4 changes: 2 additions & 2 deletions .github/workflows/check-action-typing.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Björn Kautler
# Copyright 2020-2024 Björn Kautler
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
run: 'git config --global core.autocrlf input'
- id: 'step-1'
name: 'Checkout'
uses: 'actions/checkout@v3'
uses: 'actions/checkout@v4'
- id: 'step-2'
name: 'Check Action Typing'
uses: 'typesafegithub/github-actions-typing@v1'
20 changes: 12 additions & 8 deletions .github/workflows/check-dependency-versions.main.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env kotlin

/*
* Copyright 2020-2023 Björn Kautler
* Copyright 2020-2024 Björn Kautler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,11 +17,15 @@
*/

@file:Import("workflow-with-copyright.main.kts")
@file:Repository("https://bindings.krzeminski.it/")
@file:DependsOn("actions:checkout:v4")
@file:DependsOn("actions:setup-java:v4")
@file:DependsOn("burrunan:gradle-cache-action:v1")

import io.github.typesafegithub.workflows.actions.actions.CheckoutV3
import io.github.typesafegithub.workflows.actions.actions.SetupJavaV3
import io.github.typesafegithub.workflows.actions.actions.SetupJavaV3.Distribution.Temurin
import io.github.typesafegithub.workflows.actions.burrunan.GradleCacheActionV1
import io.github.typesafegithub.workflows.actions.actions.Checkout
import io.github.typesafegithub.workflows.actions.actions.SetupJava
import io.github.typesafegithub.workflows.actions.actions.SetupJava.Distribution.Temurin
import io.github.typesafegithub.workflows.actions.burrunan.GradleCacheAction
import io.github.typesafegithub.workflows.domain.RunnerType.WindowsLatest
import io.github.typesafegithub.workflows.domain.triggers.Cron
import io.github.typesafegithub.workflows.domain.triggers.Schedule
Expand Down Expand Up @@ -52,18 +56,18 @@ workflowWithCopyright(
)
uses(
name = "Checkout",
action = CheckoutV3()
action = Checkout()
)
uses(
name = "Setup Java 11",
action = SetupJavaV3(
action = SetupJava(
javaVersion = "11",
distribution = Temurin
)
)
uses(
name = "Check Dependency Versions",
action = GradleCacheActionV1(
action = GradleCacheAction(
arguments = listOf("--show-version", "dependencyUpdates"),
debug = false,
concurrent = true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check-dependency-versions.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Björn Kautler
# Copyright 2020-2024 Björn Kautler
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,10 +45,10 @@ jobs:
run: 'git config --global core.autocrlf input'
- id: 'step-1'
name: 'Checkout'
uses: 'actions/checkout@v3'
uses: 'actions/checkout@v4'
- id: 'step-2'
name: 'Setup Java 11'
uses: 'actions/setup-java@v3'
uses: 'actions/setup-java@v4'
with:
java-version: '11'
distribution: 'temurin'
Expand Down
57 changes: 32 additions & 25 deletions .github/workflows/test.main.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env kotlin

/*
* Copyright 2020-2023 Björn Kautler
* Copyright 2020-2024 Björn Kautler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,15 +17,22 @@
*/

@file:Import("workflow-with-copyright.main.kts")
@file:Repository("https://bindings.krzeminski.it/")
@file:DependsOn("actions:cache__restore:v4")
@file:DependsOn("actions:cache__save:v4")
@file:DependsOn("actions:checkout:v4")
@file:DependsOn("actions:setup-java:v4")
@file:DependsOn("burrunan:gradle-cache-action:v1")
@file:DependsOn("Vampire:setup-wsl:v3")

import io.github.typesafegithub.workflows.actions.actions.CacheRestoreV4
import io.github.typesafegithub.workflows.actions.actions.CacheSaveV4
import io.github.typesafegithub.workflows.actions.actions.CheckoutV4
import io.github.typesafegithub.workflows.actions.actions.SetupJavaV4
import io.github.typesafegithub.workflows.actions.actions.SetupJavaV4.Distribution.Temurin
import io.github.typesafegithub.workflows.actions.burrunan.GradleCacheActionV1
import io.github.typesafegithub.workflows.actions.vampire.SetupWslV3
import io.github.typesafegithub.workflows.actions.vampire.SetupWslV3.Distribution
import io.github.typesafegithub.workflows.actions.actions.CacheRestore
import io.github.typesafegithub.workflows.actions.actions.CacheSave
import io.github.typesafegithub.workflows.actions.actions.Checkout
import io.github.typesafegithub.workflows.actions.actions.SetupJava
import io.github.typesafegithub.workflows.actions.actions.SetupJava.Distribution.Temurin
import io.github.typesafegithub.workflows.actions.burrunan.GradleCacheAction
import io.github.typesafegithub.workflows.actions.vampire.SetupWsl
import io.github.typesafegithub.workflows.actions.vampire.SetupWsl.Distribution
import io.github.typesafegithub.workflows.domain.CommandStep
import io.github.typesafegithub.workflows.domain.ActionStep
import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY
Expand Down Expand Up @@ -129,7 +136,7 @@ val wslBash = Shell.Custom("wsl-bash {0}")

val wslSh = Shell.Custom("wsl-sh {0}")

lateinit var executeActionStep: ActionStep<SetupWslV3.Outputs>
lateinit var executeActionStep: ActionStep<SetupWsl.Outputs>

workflowWithCopyright(
name = "Build and Test",
Expand All @@ -145,7 +152,7 @@ workflowWithCopyright(
"build/distributions/"
)

val executeAction = SetupWslV3(
val executeAction = SetupWsl(
distribution = Distribution.Custom(expr("matrix.distribution.user-id"))
)

Expand All @@ -160,18 +167,18 @@ workflowWithCopyright(
)
uses(
name = "Checkout",
action = CheckoutV4()
action = Checkout()
)
uses(
name = "Setup Java 11",
action = SetupJavaV4(
action = SetupJava(
javaVersion = "11",
distribution = Temurin
)
)
uses(
name = "Build",
action = GradleCacheActionV1(
action = GradleCacheAction(
arguments = listOf(
"--show-version",
"build",
Expand All @@ -185,7 +192,7 @@ workflowWithCopyright(
)
uses(
name = "Save built artifacts to cache",
action = CacheSaveV4(
action = CacheSave(
path = builtArtifacts,
key = expr { github.run_id }
)
Expand All @@ -206,7 +213,7 @@ workflowWithCopyright(
) {
uses(
name = "Restore built artifacts from cache",
action = CacheRestoreV4(
action = CacheRestore(
path = builtArtifacts,
key = expr { github.run_id },
failOnCacheMiss = true
Expand Down Expand Up @@ -266,7 +273,7 @@ workflowWithCopyright(
)
) {
executeActionStep = usesSelf(
action = SetupWslV3(
action = SetupWsl(
update = true
)
)
Expand Down Expand Up @@ -686,26 +693,26 @@ workflowWithCopyright(
) {
usesSelf(
name = "Execute action for ${expr("matrix.distributions.distribution1.user-id")}",
action = SetupWslV3(
action = SetupWsl(
distribution = Distribution.Custom(expr("matrix.distributions.distribution1.user-id"))
)
)
usesSelf(
name = "Execute action for ${expr("matrix.distributions.distribution2.user-id")}",
action = SetupWslV3(
action = SetupWsl(
distribution = Distribution.Custom(expr("matrix.distributions.distribution2.user-id"))
)
)
usesSelf(
name = "Execute action for ${expr("matrix.distributions.distribution3.user-id")}",
action = SetupWslV3(
action = SetupWsl(
distribution = Distribution.Custom(expr("matrix.distributions.distribution3.user-id")),
setAsDefault = false
)
)
executeActionStep = usesSelf(
name = "Execute action for ${expr("matrix.distributions.distribution1.user-id")} again",
action = SetupWslV3(
action = SetupWsl(
distribution = Distribution.Custom(expr("matrix.distributions.distribution1.user-id"))
)
)
Expand Down Expand Up @@ -783,7 +790,7 @@ workflowWithCopyright(
)
executeActionStep = usesSelfAfterSuccess(
name = "Execute action for ${expr("matrix.distribution2.user-id")}",
action = SetupWslV3(
action = SetupWsl(
distribution = Distribution.Custom(expr("matrix.distribution2.user-id"))
)
)
Expand Down Expand Up @@ -842,7 +849,7 @@ workflowWithCopyright(
.associateWith {
usesSelf(
name = "Execute action for ${expr("matrix.distributions.distribution$it.user-id")}",
action = SetupWslV3(
action = SetupWsl(
distribution = Distribution.Custom(expr("matrix.distributions.distribution$it.user-id")),
additionalPackages = if (it == 2) listOf("bash") else null,
setAsDefault = if (it >= 3) false else null
Expand Down Expand Up @@ -934,7 +941,7 @@ fun JobBuilder<*>.commonTests() {

fun JobBuilder<*>.usesSelfAfterSuccess(
name: String = "Execute action",
action: SetupWslV3
action: SetupWsl
) = usesSelf(
name = name,
action = action,
Expand All @@ -943,7 +950,7 @@ fun JobBuilder<*>.usesSelfAfterSuccess(

fun JobBuilder<*>.usesSelf(
name: String = "Execute action",
action: SetupWslV3,
action: SetupWsl,
condition: String? = null,
continueOnError: Boolean? = null
) = uses(
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Björn Kautler
# Copyright 2020-2024 Björn Kautler
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/validate-gradle-wrapper.main.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env kotlin

/*
* Copyright 2020-2023 Björn Kautler
* Copyright 2020-2024 Björn Kautler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,9 +17,12 @@
*/

@file:Import("workflow-with-copyright.main.kts")
@file:Repository("https://bindings.krzeminski.it/")
@file:DependsOn("actions:checkout:v4")
@file:DependsOn("gradle:wrapper-validation-action:v1")

import io.github.typesafegithub.workflows.actions.actions.CheckoutV3
import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV1
import io.github.typesafegithub.workflows.actions.actions.Checkout
import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationAction
import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest
import io.github.typesafegithub.workflows.domain.triggers.PullRequest
import io.github.typesafegithub.workflows.domain.triggers.Push
Expand All @@ -43,11 +46,11 @@ workflowWithCopyright(
)
uses(
name = "Checkout",
action = CheckoutV3()
action = Checkout()
)
uses(
name = "Validate Gradle Wrapper",
action = WrapperValidationActionV1()
action = WrapperValidationAction()
)
}
}
4 changes: 2 additions & 2 deletions .github/workflows/validate-gradle-wrapper.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Björn Kautler
# Copyright 2020-2024 Björn Kautler
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
run: 'git config --global core.autocrlf input'
- id: 'step-1'
name: 'Checkout'
uses: 'actions/checkout@v3'
uses: 'actions/checkout@v4'
- id: 'step-2'
name: 'Validate Gradle Wrapper'
uses: 'gradle/wrapper-validation-action@v1'
7 changes: 4 additions & 3 deletions .github/workflows/workflow-with-copyright.main.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 Björn Kautler
* Copyright 2020-2024 Björn Kautler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,8 @@
* limitations under the License.
*/

@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.0.0")
@file:Repository("https://repo.maven.apache.org/maven2/")
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.3.0")

import io.github.typesafegithub.workflows.domain.Concurrency
import io.github.typesafegithub.workflows.domain.triggers.Trigger
Expand All @@ -39,7 +40,7 @@ fun workflowWithCopyright(
concurrency = concurrency,
preamble = WithOriginalAfter(
"""
Copyright 2020-2023 Björn Kautler
Copyright 2020-2024 Björn Kautler
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 9c1480a

Please sign in to comment.