From 3b781c421cfea85b1912ad978fdb06111139cee5 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Mon, 27 Mar 2023 09:24:36 +0200 Subject: [PATCH 01/15] chore: add tests in DroneCI --- .drone.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 1c579d6..72c253b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,4 +6,10 @@ steps: - name: Build image: eclipse-temurin:17-jdk commands: - - ./mvnw package -B -DskipTests=true \ No newline at end of file + - ./mvnw package -B -DskipTests=true + - name: Tests + image: quay.io/testcontainers/dind-drone-plugin + build_image: eclipse-temurin:17-jdk + cmd: ./mvnw test + prefetch_images: + - "postgres:13-alpine" \ No newline at end of file -- 2.40.1 From c15e57febe2fdb68a05ff8840d9a88c6cf08d2da Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Mon, 27 Mar 2023 09:38:45 +0200 Subject: [PATCH 02/15] chore: add tests in DroneCI pt2 --- .drone.yml | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 72c253b..313cc18 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,7 +9,26 @@ steps: - ./mvnw package -B -DskipTests=true - name: Tests image: quay.io/testcontainers/dind-drone-plugin - build_image: eclipse-temurin:17-jdk - cmd: ./mvnw test - prefetch_images: - - "postgres:13-alpine" \ No newline at end of file + environment: + CI_WORKSPACE: "/drone/src" + settings: + cmd: ./mvnw test + build_image: eclipse-temurin:17-jdk + prefetch_images: + - "postgres:13-alpine" + volumes: + - name: dockersock + path: /var/run + +# Specify docker:dind as a service +services: + - name: docker + image: docker:dind + privileged: true + volumes: + - name: dockersock + path: /var/run + +volumes: + - name: dockersock + temp: {} \ No newline at end of file -- 2.40.1 From c34d3acabcc1758291605e49ced2bd79cdbfe21c Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Mon, 27 Mar 2023 10:25:22 +0200 Subject: [PATCH 03/15] chore: add -B flag to mvnw --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 313cc18..b3c030d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,7 +12,7 @@ steps: environment: CI_WORKSPACE: "/drone/src" settings: - cmd: ./mvnw test + cmd: ./mvnw -B test build_image: eclipse-temurin:17-jdk prefetch_images: - "postgres:13-alpine" -- 2.40.1 From a77e84a8485571222c288df3bd150551988c247c Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Mon, 27 Mar 2023 10:38:49 +0200 Subject: [PATCH 04/15] feat: add Dockerfile build --- .drone.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index b3c030d..a70237e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,11 +3,11 @@ type: docker name: default steps: - - name: Build + - name: Maven build image: eclipse-temurin:17-jdk commands: - ./mvnw package -B -DskipTests=true - - name: Tests + - name: UT & IT Tests image: quay.io/testcontainers/dind-drone-plugin environment: CI_WORKSPACE: "/drone/src" @@ -19,6 +19,12 @@ steps: volumes: - name: dockersock path: /var/run + - name: Docker image + image: thegeeklab/drone-docker-buildx:23 + privileged: true + settings: + pull_image: true + dry_run: true # Specify docker:dind as a service services: -- 2.40.1 From 1f182efc9802bbd7fc0fdcd5b0ad40bfa6ee84ca Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Mon, 27 Mar 2023 10:39:59 +0200 Subject: [PATCH 05/15] chore: pipeline reorder --- .drone.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index a70237e..35478a8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,10 +3,6 @@ type: docker name: default steps: - - name: Maven build - image: eclipse-temurin:17-jdk - commands: - - ./mvnw package -B -DskipTests=true - name: UT & IT Tests image: quay.io/testcontainers/dind-drone-plugin environment: @@ -19,6 +15,10 @@ steps: volumes: - name: dockersock path: /var/run + - name: Packaging + image: eclipse-temurin:17-jdk + commands: + - ./mvnw package -B -DskipTests=true - name: Docker image image: thegeeklab/drone-docker-buildx:23 privileged: true -- 2.40.1 From 11e3321220fe2c078004f11676fbb38fbbe533fa Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Mon, 27 Mar 2023 10:43:27 +0200 Subject: [PATCH 06/15] chore: messing with parallelism --- .drone.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.drone.yml b/.drone.yml index 35478a8..63e3b88 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,12 +19,16 @@ steps: image: eclipse-temurin:17-jdk commands: - ./mvnw package -B -DskipTests=true + depends_on: + - UT & IT Tests - name: Docker image image: thegeeklab/drone-docker-buildx:23 privileged: true settings: pull_image: true dry_run: true + depends_on: + - UT & IT Tests # Specify docker:dind as a service services: -- 2.40.1 From 5beaf44407b5311392d180f17e6bc62275a658d2 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Mon, 27 Mar 2023 13:19:58 +0200 Subject: [PATCH 07/15] chore: add pre-commit checks --- .drone.yml | 7 +- .markdownlint.yaml | 2 + .pre-commit-config.yaml | 31 ++++++++ .run/Execute all tests.run.xml | 2 +- .run/Jooby run.run.xml | 2 +- .run/docker-compose up (debug).run.xml | 2 +- Dockerfile | 2 +- README.md | 18 +++-- conf/application.conf | 2 +- schema/json/ChatContext.json | 2 +- src/etc/stork/stork.yml | 2 +- .../polpetta/mezzotre/InjectionModule.java | 4 +- .../i18n/LocalizedMessageFactory.java | 7 +- .../polpetta/mezzotre/i18n/LocalizedTool.java | 2 +- .../github/polpetta/mezzotre/orm/di/Db.java | 68 +++++++++-------- .../polpetta/mezzotre/orm/model/Base.java | 5 +- .../polpetta/mezzotre/route/Constants.java | 4 +- .../polpetta/mezzotre/route/di/Route.java | 5 +- .../mezzotre/telegram/command/Executor.java | 5 +- .../mezzotre/telegram/command/Start.java | 14 ++-- .../mezzotre/telegram/command/di/Command.java | 37 ++++----- .../polpetta/mezzotre/util/di/ThreadPool.java | 4 +- .../migration/V1_0_0__Create_initial_db.sql | 1 - src/main/resources/i18n/message.properties | 2 +- .../resources/i18n/message_en_US.properties | 2 +- src/main/resources/i18n/message_it.properties | 2 +- .../resources/i18n/message_it_IT.properties | 2 +- src/main/resources/template/command/start.vm | 2 +- .../polpetta/mezzotre/IntegrationTest.java | 7 -- .../helper/IntegrationAppFactory.java | 1 - .../polpetta/mezzotre/helper/Loader.java | 75 +++++++++++-------- .../orm/model/UserIntegrationTest.java | 3 +- .../route/TelegramIntegrationTest.java | 46 ++++++------ .../mezzotre/telegram/command/RouterTest.java | 16 ++-- .../command/StartIntegrationTest.java | 58 +++++++------- .../mezzotre/telegram/command/StartTest.java | 66 ++++++++-------- 36 files changed, 286 insertions(+), 224 deletions(-) create mode 100644 .markdownlint.yaml create mode 100644 .pre-commit-config.yaml diff --git a/.drone.yml b/.drone.yml index 63e3b88..c54ca53 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,6 +3,11 @@ type: docker name: default steps: + - name: Static checks + image: eclipse-temurin:17-jdk + commands: + - apt-get update -qq && apt-get install python3 pip && pip install pre-commit + - pre-commit run --all-files - name: UT & IT Tests image: quay.io/testcontainers/dind-drone-plugin environment: @@ -41,4 +46,4 @@ services: volumes: - name: dockersock - temp: {} \ No newline at end of file + temp: {} diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..f90ed06 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,2 @@ +MD013: + line_length: 120 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..50f5f59 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +exclude: "mvnw" +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-toml + - id: mixed-line-ending + - repo: https://github.com/gruntwork-io/pre-commit + rev: v0.1.17 + hooks: + - id: shellcheck + - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.4.0 + hooks: + - id: pretty-format-java + args: [--autofix] + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.32.2 + hooks: + - id: markdownlint + - id: markdownlint-fix + - repo: https://github.com/jorisroovers/gitlint + rev: v0.17.0 + hooks: + - id: gitlint diff --git a/.run/Execute all tests.run.xml b/.run/Execute all tests.run.xml index 28aa703..3a4861c 100644 --- a/.run/Execute all tests.run.xml +++ b/.run/Execute all tests.run.xml @@ -14,4 +14,4 @@