diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index cfed82f..bacdbae 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -28,9 +28,9 @@ jobs: working-directory: examples run: ./bld download - - name: Run tests [examples] + - name: Run Detekt [examples] working-directory: examples - run: ./bld compile test + run: ./bld compile test-ci - name: Download dependencies run: ./bld download diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index a4511d5..9a9a49c 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -101,4 +101,13 @@ public class ExampleBuild extends Project { .input("src/test/kotlin") .execute(); } + + @BuildCommand(value = "test-ci", summary = "Run detek with a test baseline") + public void testCi() throws ExitStatusException, IOException, InterruptedException { + // Run detek with the test basline (for CI testing) + new DetektOperation() + .fromProject(this) + .baseline("src/test/resources/detekt-baseline.xml") + .execute(); + } } diff --git a/examples/src/test/resources/detekt-baseline.xml b/examples/src/test/resources/detekt-baseline.xml new file mode 100644 index 0000000..1bf5c16 --- /dev/null +++ b/examples/src/test/resources/detekt-baseline.xml @@ -0,0 +1,12 @@ + + + + + EmptyIfBlock:Example.kt$Example.Companion${ } + MagicNumber:Example.kt$Example$5 + NewLineAtEndOfFile:ExampleTest.kt$com.example.ExampleTest.kt + ThrowingExceptionsWithoutMessageOrCause:Example.kt$Example.Companion$IllegalStateException() + UseCheckOrError:Example.kt$Example.Companion$throw IllegalStateException() + VariableNaming:Example.kt$Example$// https://detekt.dev/docs/rules/naming#variablenaming val Message: String get() = "Hello World!" + + diff --git a/src/test/java/rife/bld/extension/DetektOperationTest.java b/src/test/java/rife/bld/extension/DetektOperationTest.java index 16e6345..04db107 100644 --- a/src/test/java/rife/bld/extension/DetektOperationTest.java +++ b/src/test/java/rife/bld/extension/DetektOperationTest.java @@ -244,7 +244,7 @@ class DetektOperationTest { void testExampleBaseline() throws IOException, ExitStatusException, InterruptedException { var tmpDir = Files.createTempDirectory("bld-detekt-").toFile(); - var baseline = new File(tmpDir, "detekt-baseline.xml"); + var baseline = new File(tmpDir, "examples/src/test/resources/detekt-baseline.xml"); var op = new DetektOperation() .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",