From 7a72adc0f455a64302bb001de7d8d419a6d804a0 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Wed, 6 Nov 2024 11:47:52 +0100 Subject: [PATCH 01/11] add spring boot health check --- compose.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compose.yaml b/compose.yaml index f3c0c89c..b90c26bb 100644 --- a/compose.yaml +++ b/compose.yaml @@ -14,6 +14,12 @@ services: - postgres networks: - app-network + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"] + interval: 30s + timeout: 10s + retries: 5 + start_period: 30s postgres: image: 'postgres:16' From cbe5e313261593b7b7c6d9650b7cf0b94ddede9d Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Wed, 6 Nov 2024 12:03:17 +0100 Subject: [PATCH 02/11] try different health check --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index b90c26bb..e9421cae 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,7 +15,7 @@ services: networks: - app-network healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"] + test: "wget -qO-http://localhost:8080/actuator/health || exit 1" interval: 30s timeout: 10s retries: 5 From cdee611080e3835b875ff2f25280b82e3fd21e78 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Wed, 6 Nov 2024 12:13:41 +0100 Subject: [PATCH 03/11] fix healthcheck typo --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index e9421cae..59845642 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,7 +15,7 @@ services: networks: - app-network healthcheck: - test: "wget -qO-http://localhost:8080/actuator/health || exit 1" + test: "wget -qO- http://localhost:8080/actuator/health || exit 1" interval: 30s timeout: 10s retries: 5 From 7f81348ff210d7b47e7e9f65af879e67a8130b46 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Wed, 6 Nov 2024 12:20:45 +0100 Subject: [PATCH 04/11] fix healthcheck again --- compose.yaml | 2 +- server/application-server/nixpacks.toml | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index 59845642..b90c26bb 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,7 +15,7 @@ services: networks: - app-network healthcheck: - test: "wget -qO- http://localhost:8080/actuator/health || exit 1" + test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"] interval: 30s timeout: 10s retries: 5 diff --git a/server/application-server/nixpacks.toml b/server/application-server/nixpacks.toml index ec431c13..910bba1c 100644 --- a/server/application-server/nixpacks.toml +++ b/server/application-server/nixpacks.toml @@ -1,5 +1,12 @@ [variables] NIXPACKS_JDK_VERSION = '21' +[packages] +curl = "curl" + [phases.build] -cmds = ['chmod +x ./mvnw && ./mvnw -DskipTests clean package'] \ No newline at end of file +cmds = [ + "chmod +x ./mvnw", + "./mvnw -DskipTests clean package", + "nix-env -iA nixpkgs.curl" +] \ No newline at end of file From 43f3e0fbed1ee3bce14d2a52ac5a099c08b57533 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Wed, 6 Nov 2024 12:25:22 +0100 Subject: [PATCH 05/11] use wget for healthcheck --- compose.yaml | 2 +- server/application-server/nixpacks.toml | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/compose.yaml b/compose.yaml index b90c26bb..59845642 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,7 +15,7 @@ services: networks: - app-network healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"] + test: "wget -qO- http://localhost:8080/actuator/health || exit 1" interval: 30s timeout: 10s retries: 5 diff --git a/server/application-server/nixpacks.toml b/server/application-server/nixpacks.toml index 910bba1c..c7cd6ac8 100644 --- a/server/application-server/nixpacks.toml +++ b/server/application-server/nixpacks.toml @@ -1,12 +1,8 @@ [variables] NIXPACKS_JDK_VERSION = '21' -[packages] -curl = "curl" +[phases.setup] +aptPkgs = ["...", "wget"] [phases.build] -cmds = [ - "chmod +x ./mvnw", - "./mvnw -DskipTests clean package", - "nix-env -iA nixpkgs.curl" -] \ No newline at end of file +cmds = ["chmod +x ./mvnw", "./mvnw -DskipTests clean package"] \ No newline at end of file From d8c2c6dfbeecd56164372a7efc1ae86e9c6819f4 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Wed, 6 Nov 2024 12:34:26 +0100 Subject: [PATCH 06/11] exclude postgres from health check for now --- compose.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compose.yaml b/compose.yaml index 59845642..57433934 100644 --- a/compose.yaml +++ b/compose.yaml @@ -35,6 +35,8 @@ services: - postgres volumes: - 'postgresql-data:/var/lib/postgresql/data' + # Exclude from Coolify health check + exclude_from_hc: true networks: app-network: From 4f1efc50513b620e64657a2528b3a7fcd1b05108 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Wed, 6 Nov 2024 12:38:17 +0100 Subject: [PATCH 07/11] change postgres healthcheck --- compose.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index 57433934..40481df5 100644 --- a/compose.yaml +++ b/compose.yaml @@ -35,8 +35,11 @@ services: - postgres volumes: - 'postgresql-data:/var/lib/postgresql/data' - # Exclude from Coolify health check - exclude_from_hc: true + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 networks: app-network: From 1a1adb56ba67f52ce6d5ce388b11acefcb7a8a5f Mon Sep 17 00:00:00 2001 From: Armin Stanitzok <21990230+GODrums@users.noreply.github.com> Date: Wed, 6 Nov 2024 20:28:17 +0100 Subject: [PATCH 08/11] `PR Template`: Add Testing Instructions to template (#135) Co-authored-by: Felix T.J. Dietrich --- .github/PULL_REQUEST_TEMPLATE.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b9bb2757..ca422db3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,6 +5,9 @@ ### Description +### Testing Instructions + + ### Screenshots (if applicable) From 37ef71529b1dd0168fa0ebdbc77c50880577a137 Mon Sep 17 00:00:00 2001 From: Armin Stanitzok <21990230+GODrums@users.noreply.github.com> Date: Wed, 6 Nov 2024 20:33:11 +0100 Subject: [PATCH 09/11] `Application-Server`: Java Code Formatting with Prettier (#136) Co-authored-by: Felix T.J. Dietrich --- .github/workflows/application-server-qa.yml | 28 ++++ .vscode/settings.json | 18 ++- package-lock.json | 137 ++++++++++++++++++++ package.json | 9 +- project.code-workspace | 58 +++++---- server/application-server/.prettierrc.yaml | 4 + webapp/package-lock.json | 1 - webapp/package.json | 1 - 8 files changed, 216 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/application-server-qa.yml create mode 100644 server/application-server/.prettierrc.yaml diff --git a/.github/workflows/application-server-qa.yml b/.github/workflows/application-server-qa.yml new file mode 100644 index 00000000..75f39038 --- /dev/null +++ b/.github/workflows/application-server-qa.yml @@ -0,0 +1,28 @@ +name: Application-Server QA + +on: + pull_request: + paths: + - "server/application-server/**" + - "!server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/**" + push: + paths: + - "server/application-server/**" + - "!server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice/**" + branches: [develop] + +jobs: + quality: + name: Code Quality Checks + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + - name: Install dependencies + run: npm ci + - name: Run Prettier + run: npm run prettier:java:check \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 6b5d8ec4..4a4b55f0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,18 +1,24 @@ { "java.compile.nullAnalysis.mode": "automatic", "java.configuration.updateBuildConfiguration": "interactive", + "java.completion.importOrder": ["#"], + "[java]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, "tailwindCSS.experimental.classRegex": [ - "cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]", - "cn\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]" + "cva\\(([^)]*)\\)", + "[\"'`]([^\"'`]*).*?[\"'`]", + "cn\\(([^)]*)\\)", + "[\"'`]([^\"'`]*).*?[\"'`]" ], "editor.codeActionsOnSave": { "source.fixAll": "explicit" }, "[python]": { - "editor.defaultFormatter": "ms-python.autopep8" - }, - "python.testing.pytestArgs": ["."], - "python.testing.pytestEnabled": true, + "editor.defaultFormatter": "ms-python.autopep8" + }, + "python.testing.pytestArgs": ["."], + "python.testing.pytestEnabled": true, "python.terminal.activateEnvironment": true, "python.terminal.activateEnvInCurrentTerminal": true, "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python" diff --git a/package-lock.json b/package-lock.json index 23ea9a38..acfd59fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,8 @@ ], "devDependencies": { "@openapitools/openapi-generator-cli": "2.13.5", + "prettier": "3.3.3", + "prettier-plugin-java": "2.6.5", "rimraf": "6.0.1", "shx": "0.3.4" } @@ -27,6 +29,50 @@ "node": ">=6.9.0" } }, + "node_modules/@chevrotain/cst-dts-gen": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/cst-dts-gen/-/cst-dts-gen-11.0.3.tgz", + "integrity": "sha512-BvIKpRLeS/8UbfxXxgC33xOumsacaeCKAjAeLyOn7Pcp95HiRbrpl14S+9vaZLolnbssPIUuiUd8IvgkRyt6NQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@chevrotain/gast": "11.0.3", + "@chevrotain/types": "11.0.3", + "lodash-es": "4.17.21" + } + }, + "node_modules/@chevrotain/gast": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/gast/-/gast-11.0.3.tgz", + "integrity": "sha512-+qNfcoNk70PyS/uxmj3li5NiECO+2YKZZQMbmjTqRI3Qchu8Hig/Q9vgkHpI3alNjr7M+a2St5pw5w5F6NL5/Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@chevrotain/types": "11.0.3", + "lodash-es": "4.17.21" + } + }, + "node_modules/@chevrotain/regexp-to-ast": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/regexp-to-ast/-/regexp-to-ast-11.0.3.tgz", + "integrity": "sha512-1fMHaBZxLFvWI067AVbGJav1eRY7N8DDvYCTwGBiE/ytKBgP8azTdgyrKyWZ9Mfh09eHWb5PgTSO8wi7U824RA==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@chevrotain/types": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/types/-/types-11.0.3.tgz", + "integrity": "sha512-gsiM3G8b58kZC2HaWR50gu6Y1440cHiJ+i3JUvcp/35JchYejb2+5MVeJK0iKThYpAa/P2PYFV4hoi44HD+aHQ==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@chevrotain/utils": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/utils/-/utils-11.0.3.tgz", + "integrity": "sha512-YslZMgtJUyuMbZ+aKvfF3x1f5liK4mWNxghFRv7jqRR9C3R3fAOGTTKvxXDa2Y1s9zSbcpuO0cAxDYsc9SrXoQ==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -463,6 +509,34 @@ "dev": true, "license": "MIT" }, + "node_modules/chevrotain": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-11.0.3.tgz", + "integrity": "sha512-ci2iJH6LeIkvP9eJW6gpueU8cnZhv85ELY8w8WiFtNjMHA5ad6pQLaJo9mEly/9qUyCpvqX8/POVUTf18/HFdw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@chevrotain/cst-dts-gen": "11.0.3", + "@chevrotain/gast": "11.0.3", + "@chevrotain/regexp-to-ast": "11.0.3", + "@chevrotain/types": "11.0.3", + "@chevrotain/utils": "11.0.3", + "lodash-es": "4.17.21" + } + }, + "node_modules/chevrotain-allstar": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/chevrotain-allstar/-/chevrotain-allstar-0.3.1.tgz", + "integrity": "sha512-b7g+y9A0v4mxCW1qUhf3BSVPg+/NvGErk/dOkrDaHA0nQIQGAtrOjlX//9OQtRlSCy+x9rfB5N8yC71lH1nvMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash-es": "^4.17.21" + }, + "peerDependencies": { + "chevrotain": "^11.0.0" + } + }, "node_modules/cli-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", @@ -1179,6 +1253,18 @@ "@pkgjs/parseargs": "^0.11.0" } }, + "node_modules/java-parser": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/java-parser/-/java-parser-2.3.2.tgz", + "integrity": "sha512-/O42UbEHy3VVJw8W0ruHkQjW75oWvQx4QisoUDRIGir6q3/IZ4JslDMPMYEqp7LU56PYJkH5uXdQiBaCXt/Opw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "chevrotain": "11.0.3", + "chevrotain-allstar": "0.3.1", + "lodash": "4.17.21" + } + }, "node_modules/jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", @@ -1199,6 +1285,13 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "dev": true, + "license": "MIT" + }, "node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", @@ -1445,6 +1538,50 @@ "dev": true, "license": "MIT" }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-java": { + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/prettier-plugin-java/-/prettier-plugin-java-2.6.5.tgz", + "integrity": "sha512-2RkPNXyYpP5dRhr04pz45n+e5LXwYWTh1JXrztiCkZTGGokIGYrfwUuGa8csnDoGbP6CDPgVm8zZSIm/9I0SRQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "java-parser": "2.3.2", + "lodash": "4.17.21", + "prettier": "3.2.5" + } + }, + "node_modules/prettier-plugin-java/node_modules/prettier": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", diff --git a/package.json b/package.json index 086fe497..55a64d59 100644 --- a/package.json +++ b/package.json @@ -7,21 +7,22 @@ "generate:api:application-server:clean": "rimraf webapp/src/app/core/modules/openapi", "generate:api:intelligence-service:clean": "rimraf server/application-server/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice", "generate:api:clean": "npm run generate:api:intelligence-service:clean && npm run generate:api:application-server:clean", - "generate:api:application-server-specs": "cd server/application-server && mvn verify -DskipTests=true -Dapp.profiles=specs", "generate:api:intelligence-service-specs": "python -m server.intelligence-service.app.generate_openapi_yaml", "generate:api:specs": "npm run generate:api:application-server-specs && npm run generate:api:intelligence-service-specs", - "generate:api:application-server-client": "npx openapi-generator-cli generate -i server/application-server/openapi.yaml -g typescript-angular -o webapp/src/app/core/modules/openapi --additional-properties fileNaming=kebab-case,withInterfaces=true --generate-alias-as-model", "generate:api:intelligence-service-client": "npx openapi-generator-cli generate -i server/intelligence-service/openapi.yaml -g java --library resttemplate --api-package de.tum.in.www1.hephaestus.intelligenceservice.api --model-package de.tum.in.www1.hephaestus.intelligenceservice.model --invoker-package de.tum.in.www1.hephaestus.intelligenceservice --additional-properties useJakartaEe=true,performBeanValidation=true,generateClientAsBean=true,hideGenerationTimestamp=true --package-name de.tum.in.www1.hephaestus.intelligenceservice -o tmp/java-client && shx cp -r tmp/java-client/src/main/java/de/tum/in/www1/hephaestus/intelligenceservice server/application-server/src/main/java/de/tum/in/www1/hephaestus && rimraf tmp", "generate:api:clients": "npm run generate:api:intelligence-service-client && npm run generate:api:application-server-client", - "generate:api:application-server": "npm run generate:api:application-server-specs && npm run generate:api:application-server:clean && npm run generate:api:application-server-client", "generate:api:intelligence-service": "npm run generate:api:intelligence-service:clean && npm run generate:api:intelligence-service-specs && npm run generate:api:intelligence-service-client", - "generate:api": "npm run generate:api:intelligence-service && npm run generate:api:application-server" + "generate:api": "npm run generate:api:intelligence-service && npm run generate:api:application-server", + "prettier:java:check": "prettier --check server/application-server/src/**/*.java", + "prettier:java:write": "prettier --write server/application-server/src/**/*.java" }, "devDependencies": { "@openapitools/openapi-generator-cli": "2.13.5", + "prettier": "3.3.3", + "prettier-plugin-java": "2.6.5", "rimraf": "6.0.1", "shx": "0.3.4" } diff --git a/project.code-workspace b/project.code-workspace index b66b1603..fab36e0b 100644 --- a/project.code-workspace +++ b/project.code-workspace @@ -1,30 +1,32 @@ { - "folders": [ - { - "name": "Hephaestus", - "path": "./" - }, - { - "name": "webapp", - "path": "./webapp" - }, - { - "name": "server/application-server", - "path": "./server/application-server" - }, - { - "name": "server/intelligence-service", - "path": "./server/intelligence-service" - }, - { - "name": "server/webhook-ingest", - "path": "./server/webhook-ingest" - }, - ], - "settings": { - "java.compile.nullAnalysis.mode": "automatic", - "python.terminal.activateEnvironment": true, - "python.terminal.activateEnvInCurrentTerminal": true, - "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python" - } + "folders": [ + { + "name": "Hephaestus", + "path": "./", + }, + { + "name": "webapp", + "path": "./webapp", + }, + { + "name": "server/application-server", + "path": "./server/application-server", + }, + { + "name": "server/intelligence-service", + "path": "./server/intelligence-service", + }, + { + "name": "server/webhook-ingest", + "path": "./server/webhook-ingest", + }, + ], + "settings": { + "java.compile.nullAnalysis.mode": "automatic", + "python.terminal.activateEnvironment": true, + "python.terminal.activateEnvInCurrentTerminal": true, + "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", + "java.configuration.updateBuildConfiguration": "interactive", + "java.completion.importOrder": ["#"], + }, } diff --git a/server/application-server/.prettierrc.yaml b/server/application-server/.prettierrc.yaml new file mode 100644 index 00000000..e38ac728 --- /dev/null +++ b/server/application-server/.prettierrc.yaml @@ -0,0 +1,4 @@ +tabWidth: 4 +printWidth: 120 +plugins: + - prettier-plugin-java \ No newline at end of file diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 33d417cf..cbdcc113 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -90,7 +90,6 @@ "karma-coverage": "2.2.1", "karma-jasmine": "5.1.0", "karma-jasmine-html-reporter": "2.1.0", - "prettier": "3.3.3", "storybook": "8.3.4", "typescript": "5.5.4" }, diff --git a/webapp/package.json b/webapp/package.json index 79b83662..6638aced 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -102,7 +102,6 @@ "karma-coverage": "2.2.1", "karma-jasmine": "5.1.0", "karma-jasmine-html-reporter": "2.1.0", - "prettier": "3.3.3", "storybook": "8.3.4", "typescript": "5.5.4" } From 9edf554e4da8de1bf2040894a2f0f07cda22be14 Mon Sep 17 00:00:00 2001 From: Florian Ehrenstorfer <57101116+iam-flo@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:16:24 +0100 Subject: [PATCH 10/11] Automated Liquibase diff generation from hibernate schema changes in development (#137) Co-authored-by: Felix T.J. Dietrich Co-authored-by: Felix T.J. Dietrich --- .../generate-application-server-client.yml | 6 + package.json | 3 +- server/application-server/compose.yaml | 6 +- server/application-server/pom.xml | 48 +++ .../src/main/resources/application-prod.yml | 3 +- .../src/main/resources/db/initial-schema.xml | 306 ++++++++++++++++++ .../src/main/resources/db/master.xml | 11 +- 7 files changed, 369 insertions(+), 14 deletions(-) create mode 100644 server/application-server/src/main/resources/db/initial-schema.xml diff --git a/.github/workflows/generate-application-server-client.yml b/.github/workflows/generate-application-server-client.yml index 6c671cec..1c0ad012 100644 --- a/.github/workflows/generate-application-server-client.yml +++ b/.github/workflows/generate-application-server-client.yml @@ -37,6 +37,12 @@ jobs: distribution: 'temurin' java-version: '21' + - name: Set up directories + working-directory: server/application-server + run: | + mkdir -p ./keycloak-data + chmod -R 755 ./keycloak-data + - name: Install dependencies run: npm install diff --git a/package.json b/package.json index 55a64d59..59110344 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "generate:api:intelligence-service": "npm run generate:api:intelligence-service:clean && npm run generate:api:intelligence-service-specs && npm run generate:api:intelligence-service-client", "generate:api": "npm run generate:api:intelligence-service && npm run generate:api:application-server", "prettier:java:check": "prettier --check server/application-server/src/**/*.java", - "prettier:java:write": "prettier --write server/application-server/src/**/*.java" + "prettier:java:write": "prettier --write server/application-server/src/**/*.java", + "db:changelog:diff": "cd server/application-server && docker compose up -d postgres && mvn liquibase:diff && docker compose down postgres" }, "devDependencies": { "@openapitools/openapi-generator-cli": "2.13.5", diff --git a/server/application-server/compose.yaml b/server/application-server/compose.yaml index ad5b8703..ce2da33c 100644 --- a/server/application-server/compose.yaml +++ b/server/application-server/compose.yaml @@ -26,10 +26,14 @@ services: ports: - '8081:8080' volumes: + - keycloak-data:/opt/keycloak/data/ - ./keycloak-hephaestus-realm-example-config.json:/opt/keycloak/data/import/hephaestus-realm.json networks: - app-network networks: app-network: - driver: bridge \ No newline at end of file + driver: bridge + +volumes: + keycloak-data: \ No newline at end of file diff --git a/server/application-server/pom.xml b/server/application-server/pom.xml index 53ba506c..d704ef0c 100644 --- a/server/application-server/pom.xml +++ b/server/application-server/pom.xml @@ -72,6 +72,11 @@ org.liquibase liquibase-core + + org.liquibase.ext + liquibase-hibernate6 + 4.27.0 + org.springframework.boot spring-boot-starter-logging @@ -265,6 +270,49 @@ . + + org.liquibase + liquibase-maven-plugin + 4.27.0 + + db/master.xml + src/main/resources/db/changelog_new.xml + org.postgresql.Driver + jdbc:postgresql://localhost:5432/hephaestus + root + root + + hibernate:spring:de.tum.in.www1.hephaestus?dialect=org.hibernate.dialect.PostgreSQLDialect + &hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy + &hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy + + + true + + + + + org.liquibase.ext + liquibase-hibernate6 + 4.27.0 + + + org.springframework.boot + spring-boot-starter-data-jpa + 3.3.3 + + + jakarta.validation + jakarta.validation-api + 3.0.2 + + + org.postgresql + postgresql + 42.7.3 + + + \ No newline at end of file diff --git a/server/application-server/src/main/resources/application-prod.yml b/server/application-server/src/main/resources/application-prod.yml index 22613429..c3e91b94 100644 --- a/server/application-server/src/main/resources/application-prod.yml +++ b/server/application-server/src/main/resources/application-prod.yml @@ -5,8 +5,7 @@ spring: password: ${DATABASE_PASSWORD} jpa: hibernate: - # TODO: Change to none and use liquibase - ddl-auto: update + ddl-auto: none security: oauth2: diff --git a/server/application-server/src/main/resources/db/initial-schema.xml b/server/application-server/src/main/resources/db/initial-schema.xml new file mode 100644 index 00000000..879fbace --- /dev/null +++ b/server/application-server/src/main/resources/db/initial-schema.xml @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/application-server/src/main/resources/db/master.xml b/server/application-server/src/main/resources/db/master.xml index 55cc07d8..a0620641 100644 --- a/server/application-server/src/main/resources/db/master.xml +++ b/server/application-server/src/main/resources/db/master.xml @@ -5,15 +5,6 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"> - - - - - - - - - - + From 0fb30c75c7d37b117fc1592b67bd69900147d5a9 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Wed, 6 Nov 2024 22:23:07 +0100 Subject: [PATCH 11/11] remove quotes --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 40481df5..8add96b2 100644 --- a/compose.yaml +++ b/compose.yaml @@ -34,7 +34,7 @@ services: aliases: - postgres volumes: - - 'postgresql-data:/var/lib/postgresql/data' + - postgresql-data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready"] interval: 10s