Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: include '*.yml' files #33

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ConventionPluginTest {
.listFiles()!!
.filter { it.isFile && it.name.endsWith(".gradle.kts") }
.map { it.name.substringBeforeLast(".gradle.kts") }
return pluginList.toTypedArray()
return pluginList.sorted().toTypedArray()
}
}
}
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