From 83928066172ef34de24ca301d922e127b0025eda Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:14:54 +0200 Subject: [PATCH 01/21] feat: add quality check workflow for code validation --- .gitea/workflows/sq.yml | 109 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .gitea/workflows/sq.yml diff --git a/.gitea/workflows/sq.yml b/.gitea/workflows/sq.yml new file mode 100644 index 0000000..4a441ff --- /dev/null +++ b/.gitea/workflows/sq.yml @@ -0,0 +1,109 @@ +name: "Quality Check" + +on: + - push + - pull_request + +jobs: + oas: + name: "Validate OAS" + runs-on: "ubuntu-latest" + container: + image: "openjdk:21-jdk" + 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: "Validate OAS Spec" + run: gradle validateSwagger + - name: "Stop Gradle" + run: gradle --stop + + linting: + name: "Linting" + runs-on: "ubuntu-latest" + container: + image: "openjdk:21-jdk" + 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: "Generate OAS Boilerplate" + run: gradle generateSwaggerCode + - name: "Linting Main" + run: gradle checkstyleMain + - name: "Linting Test" + run: gradle checkstyleTest + - name: "Stop Gradle" + run: gradle --stop + + static: + name: "Static Analysis" + runs-on: "ubuntu-latest" + container: + image: "openjdk:21-jdk" + 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: "Generate OAS Boilerplate" + run: gradle generateSwaggerCode + - name: "Static Analysis Main" + run: gradle spotbugsMain + - name: "Static Analysis Test" + run: gradle spotbugsTest + - name: "Stop Gradle" + run: gradle --stop + + test: + name: "Testing" + runs-on: "ubuntu-latest" + container: + image: "openjdk:21-jdk" + 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: "Generate OAS Boilerplate" + run: gradle generateSwaggerCode + - name: "Run Tests" + run: gradle test + - name: "Stop Gradle" + run: gradle --stop + -- 2.45.2 From 794d7501d4a2a09069e2983312b1a9f3dcd4d0b3 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:18:29 +0200 Subject: [PATCH 02/21] build(workflows): add Node.js setup to CI workflow --- .gitea/workflows/sq.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitea/workflows/sq.yml b/.gitea/workflows/sq.yml index 4a441ff..5ea4713 100644 --- a/.gitea/workflows/sq.yml +++ b/.gitea/workflows/sq.yml @@ -11,6 +11,9 @@ jobs: container: image: "openjdk:21-jdk" steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 - name: "Checkout" uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -34,6 +37,9 @@ jobs: container: image: "openjdk:21-jdk" steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 - name: "Checkout" uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -61,6 +67,9 @@ jobs: container: image: "openjdk:21-jdk" steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 - name: "Checkout" uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -88,6 +97,9 @@ jobs: container: image: "openjdk:21-jdk" steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 - name: "Checkout" uses: actions/checkout@v3 - uses: actions/cache@v3 -- 2.45.2 From 1be34396406a848b1874a2918cfe84133c52cc01 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:20:31 +0200 Subject: [PATCH 03/21] build: update container image for workflows --- .gitea/workflows/sq.yml | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/.gitea/workflows/sq.yml b/.gitea/workflows/sq.yml index 5ea4713..3ee19a4 100644 --- a/.gitea/workflows/sq.yml +++ b/.gitea/workflows/sq.yml @@ -9,11 +9,8 @@ jobs: name: "Validate OAS" runs-on: "ubuntu-latest" container: - image: "openjdk:21-jdk" + image: "cimg/openjdk:21.0-node" steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - name: "Checkout" uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -35,11 +32,8 @@ jobs: name: "Linting" runs-on: "ubuntu-latest" container: - image: "openjdk:21-jdk" + image: "cimg/openjdk:21.0-node" steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - name: "Checkout" uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -65,11 +59,8 @@ jobs: name: "Static Analysis" runs-on: "ubuntu-latest" container: - image: "openjdk:21-jdk" + image: "cimg/openjdk:21.0-node" steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - name: "Checkout" uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -95,11 +86,8 @@ jobs: name: "Testing" runs-on: "ubuntu-latest" container: - image: "openjdk:21-jdk" + image: "cimg/openjdk:21.0-node" steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - name: "Checkout" uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -118,4 +106,3 @@ jobs: run: gradle test - name: "Stop Gradle" run: gradle --stop - -- 2.45.2 From 9b2fd72341bbaab470e64f0897d4e5f143f236e2 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:25:01 +0200 Subject: [PATCH 04/21] ci: remove push trigger from quality check workflow --- .gitea/workflows/sq.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitea/workflows/sq.yml b/.gitea/workflows/sq.yml index 3ee19a4..3845951 100644 --- a/.gitea/workflows/sq.yml +++ b/.gitea/workflows/sq.yml @@ -1,7 +1,6 @@ name: "Quality Check" on: - - push - pull_request jobs: -- 2.45.2 From a11b9dc4f363c30bb51920bdac4169cf66a77895 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:36:33 +0200 Subject: [PATCH 05/21] ci: add new quality check workflow and remove old one --- .gitea/workflows/qs.yml | 28 +++++++++++ .gitea/workflows/sq.yml | 107 ---------------------------------------- 2 files changed, 28 insertions(+), 107 deletions(-) create mode 100644 .gitea/workflows/qs.yml delete mode 100644 .gitea/workflows/sq.yml diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml new file mode 100644 index 0000000..43fcf81 --- /dev/null +++ b/.gitea/workflows/qs.yml @@ -0,0 +1,28 @@ +name: "Quality Check" + +on: + - pull_request + +jobs: + oas: + name: "Gradle Check" + 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 \ No newline at end of file diff --git a/.gitea/workflows/sq.yml b/.gitea/workflows/sq.yml deleted file mode 100644 index 3845951..0000000 --- a/.gitea/workflows/sq.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: "Quality Check" - -on: - - pull_request - -jobs: - oas: - name: "Validate OAS" - 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: "Validate OAS Spec" - run: gradle validateSwagger - - name: "Stop Gradle" - run: gradle --stop - - linting: - name: "Linting" - 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: "Generate OAS Boilerplate" - run: gradle generateSwaggerCode - - name: "Linting Main" - run: gradle checkstyleMain - - name: "Linting Test" - run: gradle checkstyleTest - - name: "Stop Gradle" - run: gradle --stop - - static: - name: "Static Analysis" - 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: "Generate OAS Boilerplate" - run: gradle generateSwaggerCode - - name: "Static Analysis Main" - run: gradle spotbugsMain - - name: "Static Analysis Test" - run: gradle spotbugsTest - - name: "Stop Gradle" - run: gradle --stop - - test: - name: "Testing" - 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: "Generate OAS Boilerplate" - run: gradle generateSwaggerCode - - name: "Run Tests" - run: gradle test - - name: "Stop Gradle" - run: gradle --stop -- 2.45.2 From f5e3aa43b96bf0f6c43f06f13bba523934e2764f Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:38:09 +0200 Subject: [PATCH 06/21] build: update OpenJDK version in GitHub workflow --- .gitea/workflows/qs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index 43fcf81..703c544 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -8,7 +8,7 @@ jobs: name: "Gradle Check" runs-on: "ubuntu-latest" container: - image: "cimg/openjdk:21.0-node" + image: "cimg/openjdk:22.0-node" steps: - name: "Checkout" uses: actions/checkout@v3 -- 2.45.2 From bfdb1585ecbfa5d6ec49c7650376a95d923bd654 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:40:55 +0200 Subject: [PATCH 07/21] chore: downgrade Java version in build configuration --- .gitea/workflows/qs.yml | 2 +- build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index 703c544..43fcf81 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -8,7 +8,7 @@ jobs: name: "Gradle Check" runs-on: "ubuntu-latest" container: - image: "cimg/openjdk:22.0-node" + image: "cimg/openjdk:21.0-node" steps: - name: "Checkout" uses: actions/checkout@v3 diff --git a/build.gradle.kts b/build.gradle.kts index 74fefa1..e9345bc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ version = "0.0.1-SNAPSHOT" java { toolchain { - languageVersion = JavaLanguageVersion.of(22) + languageVersion = JavaLanguageVersion.of(21) } } -- 2.45.2 From 41d5f5c9b89f9c5664737554301c9d8d879d5fea Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:44:46 +0200 Subject: [PATCH 08/21] build: add H2 database dependency for testing --- build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle.kts b/build.gradle.kts index e9345bc..be64659 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,6 +35,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 { -- 2.45.2 From 0691e708e8e614ba4a1f5a75a0b9cd18b5a7a654 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:48:53 +0200 Subject: [PATCH 09/21] feat(ci): add PostgreSQL service to workflow configuration --- .gitea/workflows/qs.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index 43fcf81..d796d4c 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -9,6 +9,20 @@ jobs: runs-on: "ubuntu-latest" container: image: "cimg/openjdk:21.0-node" + services: + postgres: + image: postgres:15 + env: + POSTGRES_DB: lf8_starter_db + POSTGRES_USER: lf8_starter + POSTGRES_PASSWORD: secret + ports: + - 5432:5432 + options: >- + --health-cmd="pg_isready -U lf8_starter" + --health-interval=10s + --health-timeout=5s + --health-retries=3 steps: - name: "Checkout" uses: actions/checkout@v3 -- 2.45.2 From f655f2089e4100cb05d062a2b92549205527107b Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:49:00 +0200 Subject: [PATCH 10/21] build: remove H2 database from test dependencies --- build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index be64659..e9345bc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,7 +35,6 @@ 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 { -- 2.45.2 From a3348fb77739671fb5b799ed36414258969a5a44 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 09:52:02 +0200 Subject: [PATCH 11/21] build: update postgres image version to 16.4 --- .gitea/workflows/qs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index d796d4c..8efeaa2 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -11,7 +11,7 @@ jobs: image: "cimg/openjdk:21.0-node" services: postgres: - image: postgres:15 + image: postgres:16.4 env: POSTGRES_DB: lf8_starter_db POSTGRES_USER: lf8_starter -- 2.45.2 From 7fc19b5bbe67068b5d6db0e86ceaaf74eb23d91c Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 10:06:45 +0200 Subject: [PATCH 12/21] test: Add H2 database for testing and update config --- .gitea/workflows/qs.yml | 14 -------------- build.gradle.kts | 8 ++++++++ src/main/resources/application-test.properties | 5 +++++ src/test/java/application-test.properties | 0 .../lf8_starter/Lf8StarterApplicationTests.java | 1 + 5 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 src/main/resources/application-test.properties create mode 100644 src/test/java/application-test.properties diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index 8efeaa2..43fcf81 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -9,20 +9,6 @@ jobs: runs-on: "ubuntu-latest" container: image: "cimg/openjdk:21.0-node" - services: - postgres: - image: postgres:16.4 - env: - POSTGRES_DB: lf8_starter_db - POSTGRES_USER: lf8_starter - POSTGRES_PASSWORD: secret - ports: - - 5432:5432 - options: >- - --health-cmd="pg_isready -U lf8_starter" - --health-interval=10s - --health-timeout=5s - --health-retries=3 steps: - name: "Checkout" uses: actions/checkout@v3 diff --git a/build.gradle.kts b/build.gradle.kts index e9345bc..3bc0350 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,6 +7,13 @@ plugins { 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(21) @@ -35,6 +42,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/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/application-test.properties b/src/test/java/application-test.properties new file mode 100644 index 0000000..e69de29 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 { -- 2.45.2 From 37c9a466d553e1dd29dbeeeb3b51386eaa6a550b Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 10:34:06 +0200 Subject: [PATCH 13/21] build: add checkstyle configuration and workflow jobs --- .gitea/workflows/qs.yml | 26 +++++++++++++++++-- build.gradle.kts | 18 +++++++++++++ config/checkstyle/checkstyle-ignore.xml | 9 +++++++ config/checkstyle/checkstyle.xml | 23 ++++++++++++++++ .../config/OpenAPIConfiguration.java | 2 +- .../security/KeycloakLogoutHandler.java | 2 +- .../security/KeycloakSecurityConfig.java | 2 +- 7 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 config/checkstyle/checkstyle-ignore.xml create mode 100644 config/checkstyle/checkstyle.xml diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index 43fcf81..637dd4f 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -4,7 +4,7 @@ on: - pull_request jobs: - oas: + test: name: "Gradle Check" runs-on: "ubuntu-latest" container: @@ -25,4 +25,26 @@ jobs: - name: "Check" run: gradle check - name: "Stop Gradle" - run: gradle --stop \ No newline at end of file + run: gradle --stop + checkstyle: + name: "Gradle Check" + 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 3bc0350..6306cff 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,6 +2,24 @@ plugins { java id("org.springframework.boot") version "3.3.4" id("io.spring.dependency-management") version "1.1.6" + id("checkstyle") +} + +tasks.withType { + reports { + xml.required.set(false) + html.required.set(true) + } +} + +tasks.withType { + reports { + // Disable HTML report + html.required.set(false) + + // Disable XML report + xml.required.set(false) + } } group = "de.szut" 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 +} -- 2.45.2 From c111b33b7d49ce621af8f7774ab3ae9d6b9a046b Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 10:36:03 +0200 Subject: [PATCH 14/21] ci: rename jobs and update Gradle commands in workflow --- .gitea/workflows/qs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index 637dd4f..d1f7746 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -5,7 +5,7 @@ on: jobs: test: - name: "Gradle Check" + name: "Tests" runs-on: "ubuntu-latest" container: image: "cimg/openjdk:21.0-node" @@ -23,11 +23,11 @@ jobs: - name: "Prepare Gradle" run: gradle clean - name: "Check" - run: gradle check + run: gradle testClasses - name: "Stop Gradle" run: gradle --stop checkstyle: - name: "Gradle Check" + name: "Checkstyle Main" runs-on: "ubuntu-latest" container: image: "cimg/openjdk:21.0-node" -- 2.45.2 From 92fcda433b1fc54f55590ef53c71aa4e5996bb1f Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 10:40:41 +0200 Subject: [PATCH 15/21] build: update Gradle setup in CI workflow file --- .gitea/workflows/qs.yml | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index d1f7746..09536ee 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -12,16 +12,8 @@ jobs: 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: Setup Gradle + uses: gradle/gradle-build-action@v2 - name: "Check" run: gradle testClasses - name: "Stop Gradle" @@ -34,16 +26,8 @@ jobs: 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: Setup Gradle + uses: gradle/gradle-build-action@v2 - name: "Check" run: gradle check - name: "Stop Gradle" -- 2.45.2 From 680625fa397ba5c23b79f7e43b480a5ee1570af4 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 10:44:11 +0200 Subject: [PATCH 16/21] ci: remove container image from workflow config --- .gitea/workflows/qs.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index 09536ee..93a6549 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -7,8 +7,6 @@ jobs: test: name: "Tests" runs-on: "ubuntu-latest" - container: - image: "cimg/openjdk:21.0-node" steps: - name: "Checkout" uses: actions/checkout@v3 @@ -21,8 +19,6 @@ jobs: checkstyle: name: "Checkstyle Main" runs-on: "ubuntu-latest" - container: - image: "cimg/openjdk:21.0-node" steps: - name: "Checkout" uses: actions/checkout@v3 -- 2.45.2 From 2a7829f056480f6d3a85e5b6f6a3c66e2fc67cf9 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 10:44:51 +0200 Subject: [PATCH 17/21] ci: add container image for test and checkstyle jobs --- .gitea/workflows/qs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index 93a6549..09536ee 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -7,6 +7,8 @@ jobs: test: name: "Tests" runs-on: "ubuntu-latest" + container: + image: "cimg/openjdk:21.0-node" steps: - name: "Checkout" uses: actions/checkout@v3 @@ -19,6 +21,8 @@ jobs: checkstyle: name: "Checkstyle Main" runs-on: "ubuntu-latest" + container: + image: "cimg/openjdk:21.0-node" steps: - name: "Checkout" uses: actions/checkout@v3 -- 2.45.2 From 13bb137de7afbd575d2525b213bf39280abf2a9d Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 10:46:41 +0200 Subject: [PATCH 18/21] build: add caching for Gradle in workflow configuration --- .gitea/workflows/qs.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index 09536ee..30d3d8a 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -12,6 +12,19 @@ jobs: steps: - name: "Checkout" uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + $HOME/.m2/repository + ~/.m2/repository + ./.gradle + ./app/build + ./build + ./release + key: gradle-${{ runner.os }} + restore-keys: | + gradle-${{ runner.os }} + gradle- - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: "Check" @@ -26,6 +39,19 @@ jobs: steps: - name: "Checkout" uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + $HOME/.m2/repository + ~/.m2/repository + ./.gradle + ./app/build + ./build + ./release + key: gradle-${{ runner.os }} + restore-keys: | + gradle-${{ runner.os }} + gradle- - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: "Check" -- 2.45.2 From 0f85e24fdf89227ac39c2e43da1e2cb9b035458a Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 10:52:46 +0200 Subject: [PATCH 19/21] ci: update Gradle caching in workflow configuration --- .gitea/workflows/qs.yml | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/.gitea/workflows/qs.yml b/.gitea/workflows/qs.yml index 30d3d8a..d1f7746 100644 --- a/.gitea/workflows/qs.yml +++ b/.gitea/workflows/qs.yml @@ -15,18 +15,13 @@ jobs: - uses: actions/cache@v3 with: path: | - $HOME/.m2/repository - ~/.m2/repository - ./.gradle - ./app/build - ./build - ./release - key: gradle-${{ runner.os }} + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: | - gradle-${{ runner.os }} - gradle- - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + ${{ runner.os }}-gradle- + - name: "Prepare Gradle" + run: gradle clean - name: "Check" run: gradle testClasses - name: "Stop Gradle" @@ -42,18 +37,13 @@ jobs: - uses: actions/cache@v3 with: path: | - $HOME/.m2/repository - ~/.m2/repository - ./.gradle - ./app/build - ./build - ./release - key: gradle-${{ runner.os }} + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: | - gradle-${{ runner.os }} - gradle- - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + ${{ runner.os }}-gradle- + - name: "Prepare Gradle" + run: gradle clean - name: "Check" run: gradle check - name: "Stop Gradle" -- 2.45.2 From 3b678bdb8367cf69e40970aa066d855c5cfe5c60 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 10:58:50 +0200 Subject: [PATCH 20/21] build: Remove HTML report generation from Checkstyle --- build.gradle.kts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6306cff..8aa3eba 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,13 +5,6 @@ plugins { id("checkstyle") } -tasks.withType { - reports { - xml.required.set(false) - html.required.set(true) - } -} - tasks.withType { reports { // Disable HTML report -- 2.45.2 From f4ff3e0fa7afccfb4a02c3dab23e6344ea3f7908 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 25 Sep 2024 11:00:01 +0200 Subject: [PATCH 21/21] chore: remove unused application-test.properties file --- src/test/java/application-test.properties | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/test/java/application-test.properties diff --git a/src/test/java/application-test.properties b/src/test/java/application-test.properties deleted file mode 100644 index e69de29..0000000 -- 2.45.2