-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
439 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/usr/bin/env kotlin | ||
|
||
@file:DependsOn("it.krzeminski:github-actions-kotlin-dsl:0.40.0") | ||
|
||
import it.krzeminski.githubactions.actions.actions.CacheRestoreV3 | ||
import it.krzeminski.githubactions.actions.actions.CacheSaveV3 | ||
import it.krzeminski.githubactions.actions.actions.CheckoutV3 | ||
import it.krzeminski.githubactions.actions.actions.SetupJavaV3 | ||
import it.krzeminski.githubactions.actions.actions.SetupJavaV3.Distribution.Temurin | ||
import it.krzeminski.githubactions.actions.burrunan.GradleCacheActionV1 | ||
import it.krzeminski.githubactions.actions.vampire.SetupWslV2 | ||
import it.krzeminski.githubactions.actions.vampire.SetupWslV2.Distribution | ||
import it.krzeminski.githubactions.domain.RunnerType.WindowsLatest | ||
import it.krzeminski.githubactions.domain.Shell | ||
import it.krzeminski.githubactions.domain.actions.CustomAction | ||
import it.krzeminski.githubactions.domain.triggers.Push | ||
import it.krzeminski.githubactions.dsl.expressions.expr | ||
import it.krzeminski.githubactions.dsl.workflow | ||
import it.krzeminski.githubactions.yaml.writeToFile | ||
|
||
workflow( | ||
name = "Debug", | ||
on = listOf(Push()), | ||
sourceFile = __FILE__.toPath() | ||
) { | ||
val builtArtifacts = listOf( | ||
"action.yml", | ||
"build/distributions/" | ||
) | ||
|
||
val build = job( | ||
id = "build", | ||
name = "Build", | ||
runsOn = WindowsLatest | ||
) { | ||
run( | ||
name = "Configure Git", | ||
command = "git config --global core.autocrlf input" | ||
) | ||
uses( | ||
name = "Checkout", | ||
action = CheckoutV3() | ||
) | ||
uses( | ||
name = "Setup Java 11", | ||
action = SetupJavaV3( | ||
javaVersion = "11", | ||
distribution = Temurin | ||
) | ||
) | ||
uses( | ||
name = "Build", | ||
action = GradleCacheActionV1( | ||
arguments = listOf( | ||
"--show-version", | ||
"build", | ||
"--info", | ||
"--stacktrace", | ||
"--scan" | ||
), | ||
debug = false, | ||
concurrent = true | ||
) | ||
) | ||
uses( | ||
name = "Save built artifacts to cache", | ||
action = CacheSaveV3( | ||
path = builtArtifacts, | ||
key = expr { github.run_id } | ||
) | ||
) | ||
} | ||
|
||
job( | ||
id = "test", | ||
name = "Test", | ||
needs = listOf(build), | ||
runsOn = WindowsLatest | ||
) { | ||
uses( | ||
name = "Restore built artifacts from cache", | ||
action = CacheRestoreV3( | ||
path = builtArtifacts, | ||
key = expr { github.run_id }, | ||
failOnCacheMiss = true | ||
) | ||
) | ||
uses( | ||
name = "Execute action", | ||
action = SetupWslV2( | ||
// distribution = Distribution.Alpine | ||
distribution = Distribution.Custom("openSUSE-Tumbleweed") | ||
), | ||
_customArguments = mapOf( | ||
"uses" to "./" | ||
) | ||
) | ||
uses( | ||
name = "Setup tmate session", | ||
action = CustomAction( | ||
actionOwner = "mxschmitt", | ||
actionName = "action-tmate", | ||
actionVersion = "v3", | ||
inputs = emptyMap() | ||
) | ||
) | ||
run( | ||
name = "Test - action should fail if an invalid distribution is given", | ||
shell = Shell.Custom("wsl-bash {0}"), | ||
command = "true" | ||
) | ||
} | ||
}.writeToFile() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# This file was generated using Kotlin DSL (.github/workflows/foo.main.kts). | ||
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. | ||
# Generated with https://github.com/krzema12/github-workflows-kt | ||
|
||
name: Debug | ||
on: | ||
push: {} | ||
jobs: | ||
check_yaml_consistency: | ||
name: Check YAML consistency | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: step-0 | ||
name: Check out | ||
uses: actions/checkout@v3 | ||
- id: step-1 | ||
name: Execute script | ||
run: rm '.github/workflows/foo.yaml' && '.github/workflows/foo.main.kts' | ||
- id: step-2 | ||
name: Consistency check | ||
run: git diff --exit-code '.github/workflows/foo.yaml' | ||
build: | ||
name: Build | ||
runs-on: windows-latest | ||
needs: | ||
- check_yaml_consistency | ||
steps: | ||
- id: step-0 | ||
name: Configure Git | ||
run: git config --global core.autocrlf input | ||
- id: step-1 | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- id: step-2 | ||
name: Setup Java 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 11 | ||
distribution: temurin | ||
- id: step-3 | ||
name: Build | ||
uses: burrunan/gradle-cache-action@v1 | ||
with: | ||
debug: false | ||
concurrent: true | ||
arguments: |- | ||
--show-version | ||
build | ||
--info | ||
--stacktrace | ||
--scan | ||
- id: step-4 | ||
name: Save built artifacts to cache | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: |- | ||
action.yml | ||
build/distributions/ | ||
key: ${{ github.run_id }} | ||
test: | ||
name: Test | ||
runs-on: windows-latest | ||
needs: | ||
- build | ||
- check_yaml_consistency | ||
steps: | ||
- id: step-0 | ||
name: Restore built artifacts from cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: |- | ||
action.yml | ||
build/distributions/ | ||
key: ${{ github.run_id }} | ||
fail-on-cache-miss: true | ||
- id: step-1 | ||
name: Execute action | ||
uses: ./ | ||
with: | ||
distribution: openSUSE-Tumbleweed | ||
- id: step-2 | ||
name: Setup tmate session | ||
uses: mxschmitt/action-tmate@v3 | ||
- id: step-3 | ||
name: Test - action should fail if an invalid distribution is given | ||
shell: wsl-bash {0} | ||
run: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.