Skip to content

Commit

Permalink
Add a workflow that verifies all workflow YAMLs for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Jan 3, 2025
1 parent 560a7ce commit e5226c2
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/check-all-workflow-yaml-consistency.main.kts
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 .github/workflows/check-all-workflow-yaml-consistency.yaml
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

0 comments on commit e5226c2

Please sign in to comment.