Skip to content

Commit

Permalink
build: include '*.yml' files
Browse files Browse the repository at this point in the history
Signed-off-by: Jendrik Johannes <[email protected]>
  • Loading branch information
jjohannes committed Dec 10, 2024
1 parent c67f8de commit 39f829c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins { id("com.diffplug.spotless") }

spotless {
format("actionYaml") {
target(".github/workflows/*.yaml")
target(".github/workflows/*.yaml", ".github/workflows/*.yml")
/*
* Prettier requires NodeJS and NPM installed; however, the NodeJS Gradle plugin and Spotless do not yet
* integrate with each other. Currently there is an open issue report against spotless.
Expand Down
40 changes: 40 additions & 0 deletions src/test/kotlin/org/hiero/gradle/test/QualityGateTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: Apache-2.0
package org.hiero.gradle.test

import org.assertj.core.api.Assertions.assertThat
import org.gradle.testkit.runner.TaskOutcome
import org.hiero.gradle.test.fixtures.GradleProject
import org.junit.jupiter.api.Test

class QualityGateTest {

@Test
fun `qualityGate formats yml and yaml files`() {
val p = GradleProject().withMinimalStructure()
val flow1 = p.file(".github/workflows/flow1.yml", "name: Flow 1 ")
val flow2 = p.file(".github/workflows/flow2.yaml", "name: Flow 2 ")
val txtFile = p.file(".github/workflows/temp.txt", "name: Flow 3 ")

val result = p.qualityGate()

assertThat(flow1)
.hasContent(
"""
# SPDX-License-Identifier: Apache-2.0
name: Flow 1
"""
.trimIndent()
)
assertThat(flow2)
.hasContent(
"""
# SPDX-License-Identifier: Apache-2.0
name: Flow 2
"""
.trimIndent()
)
assertThat(txtFile).hasContent("name: Flow 3 ") // unchanged

assertThat(result.task(":qualityGate")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class GradleProject {

fun failQualityCheck(): BuildResult = runner(listOf("qualityCheck")).buildAndFail()

fun qualityGate(): BuildResult = runner(listOf("qualityGate")).build()

private fun File.writeFormatted(content: String) {
writeText("$expectedHeader$content\n")
}
Expand Down

0 comments on commit 39f829c

Please sign in to comment.