-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a workflow that verifies all workflow YAMLs for consistency
- Loading branch information
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
.github/workflows/check-all-workflow-yaml-consistency.main.kts
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,61 @@ | ||
#!/usr/bin/env kotlin | ||
|
||
/* | ||
* Copyright 2020-2025 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
@file:Import("workflow-with-copyright.main.kts") | ||
@file:Repository("https://bindings.krzeminski.it/") | ||
@file:DependsOn("actions:checkout:v4") | ||
|
||
import io.github.typesafegithub.workflows.actions.actions.Checkout | ||
import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest | ||
import io.github.typesafegithub.workflows.domain.triggers.PullRequest | ||
import io.github.typesafegithub.workflows.domain.triggers.Push | ||
|
||
workflowWithCopyright( | ||
name = "Check all Workflow YAML Consistency", | ||
on = listOf( | ||
Push(), | ||
PullRequest() | ||
), | ||
sourceFile = __FILE__ | ||
) { | ||
job( | ||
id = "check_all_workflow_yaml_consistency", | ||
name = "Check all Workflow YAML Consistency", | ||
runsOn = UbuntuLatest | ||
) { | ||
run( | ||
name = "Configure Git", | ||
command = "git config --global core.autocrlf input" | ||
) | ||
uses( | ||
name = "Checkout", | ||
action = Checkout() | ||
) | ||
run( | ||
name = "Regenerate all Workflow YAMLs", | ||
command = """find .github/workflows -mindepth 1 -maxdepth 1 -name '*.main.kts' -exec {} \;""" | ||
) | ||
run( | ||
name = "Check for Modifications", | ||
command = """ | ||
git add --intent-to-add . | ||
git diff --exit-code | ||
""".trimIndent() | ||
) | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
.github/workflows/check-all-workflow-yaml-consistency.yaml
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,56 @@ | ||
# Copyright 2020-2025 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. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# This file was generated using Kotlin DSL (.github/workflows/check-all-workflow-yaml-consistency.main.kts). | ||
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. | ||
# Generated with https://github.com/typesafegithub/github-workflows-kt | ||
|
||
name: 'Check all Workflow YAML Consistency' | ||
on: | ||
push: {} | ||
pull_request: {} | ||
jobs: | ||
check_yaml_consistency: | ||
name: 'Check YAML consistency' | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- id: 'step-0' | ||
name: 'Check out' | ||
uses: 'actions/checkout@v4' | ||
- id: 'step-1' | ||
name: 'Execute script' | ||
run: 'rm ''.github/workflows/check-all-workflow-yaml-consistency.yaml'' && ''.github/workflows/check-all-workflow-yaml-consistency.main.kts''' | ||
- id: 'step-2' | ||
name: 'Consistency check' | ||
run: 'git diff --exit-code ''.github/workflows/check-all-workflow-yaml-consistency.yaml''' | ||
check_all_workflow_yaml_consistency: | ||
name: 'Check all Workflow YAML Consistency' | ||
runs-on: 'ubuntu-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@v4' | ||
- id: 'step-2' | ||
name: 'Regenerate all Workflow YAMLs' | ||
run: 'find .github/workflows -mindepth 1 -maxdepth 1 -name ''*.main.kts'' -exec {} \;' | ||
- id: 'step-3' | ||
name: 'Check for Modifications' | ||
run: |- | ||
git add --intent-to-add . | ||
git diff --exit-code |