diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml new file mode 100644 index 0000000..d1f7746 --- /dev/null +++ b/.gitea/workflows/qs.yml @@ -0,0 +1,50 @@ +name: "Quality Check" + +on: + - pull_request + +jobs: + test: + name: "Tests" + runs-on: "ubuntu-latest" + container: + image: "cimg/openjdk:21.0-node" + steps: + - name: "Checkout" + uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: "Prepare Gradle" + run: gradle clean + - name: "Check" + run: gradle testClasses + - name: "Stop Gradle" + run: gradle --stop + checkstyle: + name: "Checkstyle Main" + runs-on: "ubuntu-latest" + container: + image: "cimg/openjdk:21.0-node" + steps: + - name: "Checkout" + uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: "Prepare Gradle" + run: gradle clean + - name: "Check" + run: gradle check + - name: "Stop Gradle" + run: gradle --stop diff --git a/build.gradle.kts b/build.gradle.kts index 74fefa1..8aa3eba 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,14 +2,32 @@ plugins { java id("org.springframework.boot") version "3.3.4" id("io.spring.dependency-management") version "1.1.6" + id("checkstyle") +} + +tasks.withType { + reports { + // Disable HTML report + html.required.set(false) + + // Disable XML report + xml.required.set(false) + } } group = "de.szut" version = "0.0.1-SNAPSHOT" +tasks.test { + useJUnitPlatform() + + // Activate the 'test' profile for Spring during tests + systemProperty("spring.profiles.active", "test") +} + java { toolchain { - languageVersion = JavaLanguageVersion.of(22) + languageVersion = JavaLanguageVersion.of(21) } } @@ -35,6 +53,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-oauth2-client:3.3.4") runtimeOnly("org.postgresql:postgresql") implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0") + testImplementation("com.h2database:h2") } tasks.withType { diff --git a/config/checkstyle/checkstyle-ignore.xml b/config/checkstyle/checkstyle-ignore.xml new file mode 100644 index 0000000..fe3b2fe --- /dev/null +++ b/config/checkstyle/checkstyle-ignore.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000..d8f0701 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/de/szut/lf8_starter/config/OpenAPIConfiguration.java b/src/main/java/de/szut/lf8_starter/config/OpenAPIConfiguration.java index 0501902..1b2282b 100644 --- a/src/main/java/de/szut/lf8_starter/config/OpenAPIConfiguration.java +++ b/src/main/java/de/szut/lf8_starter/config/OpenAPIConfiguration.java @@ -57,4 +57,4 @@ public class OpenAPIConfiguration { } -} \ No newline at end of file +} diff --git a/src/main/java/de/szut/lf8_starter/security/KeycloakLogoutHandler.java b/src/main/java/de/szut/lf8_starter/security/KeycloakLogoutHandler.java index 3cc82f7..8555ef9 100644 --- a/src/main/java/de/szut/lf8_starter/security/KeycloakLogoutHandler.java +++ b/src/main/java/de/szut/lf8_starter/security/KeycloakLogoutHandler.java @@ -46,4 +46,4 @@ public class KeycloakLogoutHandler implements LogoutHandler { } } -} \ No newline at end of file +} diff --git a/src/main/java/de/szut/lf8_starter/security/KeycloakSecurityConfig.java b/src/main/java/de/szut/lf8_starter/security/KeycloakSecurityConfig.java index d47d6ec..ea9e354 100644 --- a/src/main/java/de/szut/lf8_starter/security/KeycloakSecurityConfig.java +++ b/src/main/java/de/szut/lf8_starter/security/KeycloakSecurityConfig.java @@ -94,4 +94,4 @@ class KeycloakSecurityConfig { }); return jwtAuthenticationConverter; } -} \ No newline at end of file +} diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties new file mode 100644 index 0000000..af21e0e --- /dev/null +++ b/src/main/resources/application-test.properties @@ -0,0 +1,5 @@ +spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1 +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect \ No newline at end of file diff --git a/src/test/java/de/szut/lf8_starter/Lf8StarterApplicationTests.java b/src/test/java/de/szut/lf8_starter/Lf8StarterApplicationTests.java index 942f2cb..b5c7f7b 100644 --- a/src/test/java/de/szut/lf8_starter/Lf8StarterApplicationTests.java +++ b/src/test/java/de/szut/lf8_starter/Lf8StarterApplicationTests.java @@ -2,6 +2,7 @@ package de.szut.lf8_starter; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; @SpringBootTest class Lf8StarterApplicationTests {