Skip to content

Commit e5226c2

Browse files
committed
Add a workflow that verifies all workflow YAMLs for consistency
1 parent 560a7ce commit e5226c2

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env kotlin
2+
3+
/*
4+
* Copyright 2020-2025 Björn Kautler
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
@file:Import("workflow-with-copyright.main.kts")
20+
@file:Repository("https://bindings.krzeminski.it/")
21+
@file:DependsOn("actions:checkout:v4")
22+
23+
import io.github.typesafegithub.workflows.actions.actions.Checkout
24+
import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest
25+
import io.github.typesafegithub.workflows.domain.triggers.PullRequest
26+
import io.github.typesafegithub.workflows.domain.triggers.Push
27+
28+
workflowWithCopyright(
29+
name = "Check all Workflow YAML Consistency",
30+
on = listOf(
31+
Push(),
32+
PullRequest()
33+
),
34+
sourceFile = __FILE__
35+
) {
36+
job(
37+
id = "check_all_workflow_yaml_consistency",
38+
name = "Check all Workflow YAML Consistency",
39+
runsOn = UbuntuLatest
40+
) {
41+
run(
42+
name = "Configure Git",
43+
command = "git config --global core.autocrlf input"
44+
)
45+
uses(
46+
name = "Checkout",
47+
action = Checkout()
48+
)
49+
run(
50+
name = "Regenerate all Workflow YAMLs",
51+
command = """find .github/workflows -mindepth 1 -maxdepth 1 -name '*.main.kts' -exec {} \;"""
52+
)
53+
run(
54+
name = "Check for Modifications",
55+
command = """
56+
git add --intent-to-add .
57+
git diff --exit-code
58+
""".trimIndent()
59+
)
60+
}
61+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2020-2025 Björn Kautler
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This file was generated using Kotlin DSL (.github/workflows/check-all-workflow-yaml-consistency.main.kts).
16+
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
17+
# Generated with https://github.com/typesafegithub/github-workflows-kt
18+
19+
name: 'Check all Workflow YAML Consistency'
20+
on:
21+
push: {}
22+
pull_request: {}
23+
jobs:
24+
check_yaml_consistency:
25+
name: 'Check YAML consistency'
26+
runs-on: 'ubuntu-latest'
27+
steps:
28+
- id: 'step-0'
29+
name: 'Check out'
30+
uses: 'actions/checkout@v4'
31+
- id: 'step-1'
32+
name: 'Execute script'
33+
run: 'rm ''.github/workflows/check-all-workflow-yaml-consistency.yaml'' && ''.github/workflows/check-all-workflow-yaml-consistency.main.kts'''
34+
- id: 'step-2'
35+
name: 'Consistency check'
36+
run: 'git diff --exit-code ''.github/workflows/check-all-workflow-yaml-consistency.yaml'''
37+
check_all_workflow_yaml_consistency:
38+
name: 'Check all Workflow YAML Consistency'
39+
runs-on: 'ubuntu-latest'
40+
needs:
41+
- 'check_yaml_consistency'
42+
steps:
43+
- id: 'step-0'
44+
name: 'Configure Git'
45+
run: 'git config --global core.autocrlf input'
46+
- id: 'step-1'
47+
name: 'Checkout'
48+
uses: 'actions/checkout@v4'
49+
- id: 'step-2'
50+
name: 'Regenerate all Workflow YAMLs'
51+
run: 'find .github/workflows -mindepth 1 -maxdepth 1 -name ''*.main.kts'' -exec {} \;'
52+
- id: 'step-3'
53+
name: 'Check for Modifications'
54+
run: |-
55+
git add --intent-to-add .
56+
git diff --exit-code

0 commit comments

Comments
 (0)