-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.main.kts
More file actions
executable file
·108 lines (103 loc) · 4.36 KB
/
Copy pathbuild.main.kts
File metadata and controls
executable file
·108 lines (103 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env kotlin
@file:Repository("https://repo1.maven.org/maven2/")
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:4.0.0")
@file:Repository("https://bindings.krzeminski.it")
@file:DependsOn("actions:checkout:v7")
@file:DependsOn("actions:setup-java:v5")
@file:DependsOn("gradle:gradle-build-action:v3")
@file:DependsOn("typesafegithub:github-actions-typing:v2")
import io.github.typesafegithub.workflows.actions.actions.Checkout
import io.github.typesafegithub.workflows.actions.actions.SetupJava
import io.github.typesafegithub.workflows.actions.gradle.GradleBuildAction
import io.github.typesafegithub.workflows.actions.typesafegithub.GithubActionsTyping
import io.github.typesafegithub.workflows.domain.RunnerType
import io.github.typesafegithub.workflows.domain.triggers.PullRequest
import io.github.typesafegithub.workflows.domain.triggers.Push
import io.github.typesafegithub.workflows.dsl.workflow
import io.github.typesafegithub.workflows.yaml.CheckoutActionVersionSource
import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG
workflow(
name = "Build",
on = listOf(
Push(branches = listOf("main")),
PullRequest(),
),
consistencyCheckJobConfig = DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG.copy(
checkoutActionVersion = CheckoutActionVersionSource.InferFromClasspath(),
),
sourceFile = __FILE__,
) {
job(
id = "build",
runsOn = RunnerType.UbuntuLatest,
) {
uses(
name = "Checkout github-actions-typing",
action = Checkout(
path = "github-actions-typing"
)
)
uses(
name = "Checkout github-actions-typing-catalog",
action = Checkout(
repository = "typesafegithub/github-actions-typing-catalog",
path = "github-actions-typing-catalog"
)
)
uses(
action = GradleBuildAction(
buildRootDirectory = "github-actions-typing",
arguments = "build"
)
)
}
job(
id = "validate-types",
runsOn = RunnerType.UbuntuLatest,
) {
uses(action = Checkout())
uses(action = GithubActionsTyping(
ignoredActionFiles = listOf(
"src/jvmTest/resources/test-repos/repo-with-top-level-and-nested-action-and-valid-typings/some/directory/action.yaml",
"src/jvmTest/resources/test-repos/repo-with-top-level-and-nested-action-and-valid-typings/action.yml",
"src/jvmTest/resources/test-repos/repo-with-top-level-and-nested-action-and-invalid-typings/some/directory/action.yaml",
"src/jvmTest/resources/test-repos/repo-with-top-level-and-nested-action-and-invalid-typings/action.yml",
"src/jvmTest/resources/test-repos/repo-with-no-top-level-and-just-nested-action-with-invalid-typings/some/directory/action.yaml",
"src/jvmTest/resources/test-repos/repo-with-only-top-level-action-and-invalid-typings/action.yml",
"src/jvmTest/resources/test-repos/repo-with-no-top-level-and-just-nested-action-with-valid-typings/some/directory/action.yaml",
"src/jvmTest/resources/test-repos/repo-with-only-top-level-action-and-no-typings/action.yml",
"src/jvmTest/resources/test-repos/repo-with-only-top-level-action-and-valid-typings/action.yml",
),
))
}
job(
id = "workflows_consistency_check",
name = "Run consistency check on all GitHub workflows",
runsOn = RunnerType.UbuntuLatest,
) {
uses(action = Checkout())
uses(
name = "Set up Java in proper version",
action = SetupJava(
javaVersion = "17",
distribution = SetupJava.Distribution.Zulu,
cache = SetupJava.BuildPlatform.Gradle,
),
)
run(command = "cd .github/workflows")
run(
name = "Regenerate all workflow YAMLs",
command = """
find -name "*.main.kts" -print0 | while read -d ${'$'}'\0' file
do
echo "Regenerating ${'$'}file..."
(${'$'}file)
done
""".trimIndent(),
)
run(
name = "Check if some file is different after regeneration",
command = "git diff --exit-code .",
)
}
}