From f2fee24acf2d731d81029ab04944f752eeb4d16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Fri, 13 Sep 2024 00:23:47 +0200 Subject: [PATCH] PMT-3: Add CI with Linting --- .gitea/workflows/qs.yml | 19 +++++++++++++++++++ build.gradle.kts | 13 ++++++++++++- src/main/resources/checkstyle.xml | 19 +++++++++++++++++++ .../java/de/hmmh/pmt/IntegrationTest.java | 2 +- .../hmmh/pmt/PostgresContextInitializer.java | 2 +- 5 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 .gitea/workflows/qs.yml create mode 100644 src/main/resources/checkstyle.xml diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml new file mode 100644 index 0000000..9f7c92c --- /dev/null +++ b/.gitea/workflows/qs.yml @@ -0,0 +1,19 @@ +name: "Quality Check" + +on: + - push + - pull_request + +jobs: + linting: + name: "Linting Check" + runs-on: "ubuntu-latest" + container: + image: "git.euph.dev/actions/runner-java-21:latest" + steps: + - name: "Checkout" + uses: "https://git.euph.dev/actions/checkout@v3" + - name: "Checkstyle Linting Main" + run: gradle checkstyleMain + - name: "Checkstyle Linting Test" + run: gradle checkstyleTest \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 0789034..831d22a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,11 +6,17 @@ repositories { plugins { java + checkstyle id("org.springframework.boot") version "3.3.3" id("io.spring.dependency-management") version "1.1.6" id("org.hidetake.swagger.generator") version "2.19.2" } +checkstyle { + toolVersion = "10.12.4" + configFile = file("src/main/resources/checkstyle.xml") +} + group = "de.hmmh" version = "0.0.1-SNAPSHOT" @@ -73,9 +79,14 @@ tasks { named("compileJava").configure { dependsOn(swaggerSources.getByName("pmt").code) } + withType { + reports { + xml.required.set(true) + html.required.set(false) + } + } } - sourceSets { main { java.srcDir("${swaggerSources.getByName("pmt").code.outputDir}/src/main/java") diff --git a/src/main/resources/checkstyle.xml b/src/main/resources/checkstyle.xml new file mode 100644 index 0000000..ac18ae8 --- /dev/null +++ b/src/main/resources/checkstyle.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + diff --git a/src/test/java/de/hmmh/pmt/IntegrationTest.java b/src/test/java/de/hmmh/pmt/IntegrationTest.java index 3683a7b..6df5bcc 100644 --- a/src/test/java/de/hmmh/pmt/IntegrationTest.java +++ b/src/test/java/de/hmmh/pmt/IntegrationTest.java @@ -23,4 +23,4 @@ public abstract class IntegrationTest { void setUp() { //repository.deleteAll(); } -} \ No newline at end of file +} diff --git a/src/test/java/de/hmmh/pmt/PostgresContextInitializer.java b/src/test/java/de/hmmh/pmt/PostgresContextInitializer.java index 4a4163e..97e42a9 100644 --- a/src/test/java/de/hmmh/pmt/PostgresContextInitializer.java +++ b/src/test/java/de/hmmh/pmt/PostgresContextInitializer.java @@ -25,4 +25,4 @@ public class PostgresContextInitializer implements ApplicationContextInitializer "spring.datasource.password=" + postgres.getPassword() ).applyTo(configurableApplicationContext.getEnvironment()); } -} \ No newline at end of file +}