From ec849ccb132949aafc8714d91711b94106a13b80 Mon Sep 17 00:00:00 2001 From: Ajay Negi Date: Sun, 1 Sep 2024 23:58:44 +0530 Subject: [PATCH 1/8] Spring Boot CI Pipeline --- .github/workflows/spring-boot-ci.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/spring-boot-ci.yml b/.github/workflows/spring-boot-ci.yml index 765ba73..b3f7e3a 100644 --- a/.github/workflows/spring-boot-ci.yml +++ b/.github/workflows/spring-boot-ci.yml @@ -23,7 +23,23 @@ jobs: java-version: '17' - name: Install dependencies - run: mvn clean install + run: mvn clean install -d + + - name: Output environment variables + run: | + echo "ENV=$ENV" + echo "DATABASE_URL=$DATABASE_URL" + echo "DATABASE_USERNAME=$DATABASE_USERNAME" + echo "DATABASE_PASSWORD=$DATABASE_PASSWORD" + echo "DATABASE_DRIVER_CLASS_NAME=$DATABASE_DRIVER_CLASS_NAME" + echo "MAIL_SERVICE_HOST=$MAIL_SERVICE_HOST" + echo "MAIL_SERVICE_PORT=$MAIL_SERVICE_PORT" + echo "MAIL_SERVICE_USERNAME=$MAIL_SERVICE_USERNAME" + echo "MAIL_SERVICE_PASSWORD=$MAIL_SERVICE_PASSWORD" + echo "MAIL_SERVICE_SMTP=$MAIL_SERVICE_SMTP" + echo "MAIL_SERVICE_STARTTLS=$MAIL_SERVICE_STARTTLS" + echo "MAIL_SERVICE_DOMAIN_NAME=$MAIL_SERVICE_DOMAIN_NAME" + - name: Run Spring Boot Application run: mvn spring-boot:run From 29c6539eae16a15e84ceaba1960322ed0a1bdacc Mon Sep 17 00:00:00 2001 From: Ajay Negi Date: Sun, 1 Sep 2024 23:59:54 +0530 Subject: [PATCH 2/8] Spring Boot CI Pipeline --- .github/workflows/spring-boot-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/spring-boot-ci.yml b/.github/workflows/spring-boot-ci.yml index b3f7e3a..a8f22a8 100644 --- a/.github/workflows/spring-boot-ci.yml +++ b/.github/workflows/spring-boot-ci.yml @@ -3,10 +3,10 @@ name: Spring Boot CI Pipeline on: push: branches: - - 'main' + - '**' pull_request: branches: - - '**' + - 'main' jobs: build-and-test: From 9258deed2530571ad881c4032d612e803dbceea8 Mon Sep 17 00:00:00 2001 From: Ajay Negi Date: Mon, 2 Sep 2024 00:00:33 +0530 Subject: [PATCH 3/8] Spring Boot CI Pipeline --- .github/workflows/spring-boot-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spring-boot-ci.yml b/.github/workflows/spring-boot-ci.yml index a8f22a8..8bfe0fa 100644 --- a/.github/workflows/spring-boot-ci.yml +++ b/.github/workflows/spring-boot-ci.yml @@ -23,7 +23,7 @@ jobs: java-version: '17' - name: Install dependencies - run: mvn clean install -d + run: mvn clean install - name: Output environment variables run: | From 101c562894ebd35e66eddcf9e0463e1a8e06d7e5 Mon Sep 17 00:00:00 2001 From: Ajay Negi Date: Mon, 2 Sep 2024 00:11:45 +0530 Subject: [PATCH 4/8] Spring Boot CI Pipeline --- .github/workflows/spring-boot-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spring-boot-ci.yml b/.github/workflows/spring-boot-ci.yml index 8bfe0fa..8dd3fe0 100644 --- a/.github/workflows/spring-boot-ci.yml +++ b/.github/workflows/spring-boot-ci.yml @@ -23,7 +23,7 @@ jobs: java-version: '17' - name: Install dependencies - run: mvn clean install + run: mvn clean install -DskipTests - name: Output environment variables run: | From 4572a5cf40dc2bf19c7d2cf595eea545dc9eb539 Mon Sep 17 00:00:00 2001 From: Ajay Negi Date: Mon, 2 Sep 2024 09:46:07 +0530 Subject: [PATCH 5/8] Updated checks --- .github/workflows/java-code-quality.yml | 55 +++++++++++++++++++ .github/workflows/spring-boot-ci.yml | 24 ++++++-- .gitignore | 2 +- .../LibrarymanApiApplication.java | 2 + 4 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/java-code-quality.yml diff --git a/.github/workflows/java-code-quality.yml b/.github/workflows/java-code-quality.yml new file mode 100644 index 0000000..4ee78c4 --- /dev/null +++ b/.github/workflows/java-code-quality.yml @@ -0,0 +1,55 @@ +name: Java Code Quality and Formatting + +on: [push, pull_request] + +jobs: + lint: + name: Analyze and Lint Java Code + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + # This step checks out the code from your repository so the workflow can analyze it. + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + # This step sets up Java Development Kit (JDK) version 17, which is required to compile and run your Java code. + + - name: Cache Maven dependencies + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + # This step caches Maven dependencies to speed up the build process. It saves the downloaded dependencies + # so that they don't need to be downloaded again in future runs unless the `pom.xml` file changes. + + - name: Install dependencies + run: mvn install -DskipTests + # This command installs all the necessary dependencies for your project based on the `pom.xml` file. + # The `-DskipTests` flag is used to skip running tests at this stage, focusing on dependency installation. + + - name: Run Checkstyle + run: mvn checkstyle:check + # This command runs Checkstyle, a tool that checks your Java code against defined coding standards. + # It helps ensure that your code follows best practices and is consistently formatted. + + - name: Run PMD + run: mvn pmd:check + # This command runs PMD, a static code analysis tool that looks for potential bugs and code quality issues. + # It helps you identify common mistakes or bad practices in your code. + + - name: Run SpotBugs + run: mvn spotbugs:check + # This command runs SpotBugs, another static analysis tool that focuses on finding bugs in your code. + # SpotBugs can detect various types of bugs that could lead to issues in production. + + - name: Verify code formatting with Spotless (excluding Javadocs) + run: mvn spotless:check -Dspotless.apply.skip + # This command runs Spotless with the Javadoc checks skipped. + # The `-Dspotless.apply.skip` flag is used to bypass the application of Spotless checks for Javadocs. diff --git a/.github/workflows/spring-boot-ci.yml b/.github/workflows/spring-boot-ci.yml index 8dd3fe0..028d9d0 100644 --- a/.github/workflows/spring-boot-ci.yml +++ b/.github/workflows/spring-boot-ci.yml @@ -41,8 +41,25 @@ jobs: echo "MAIL_SERVICE_DOMAIN_NAME=$MAIL_SERVICE_DOMAIN_NAME" - - name: Run Spring Boot Application - run: mvn spring-boot:run +# - name: Run Spring Boot Application +# run: mvn spring-boot:run +# env: +# ENV: production +# DATABASE_URL: ${{ secrets.DATABASE_URL }} +# DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }} +# DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} +# DATABASE_DRIVER_CLASS_NAME: ${{ secrets.DATABASE_DRIVER_CLASS_NAME }} +# +# MAIL_SERVICE_HOST: ${{ secrets.MAIL_SERVICE_HOST }} +# MAIL_SERVICE_PORT: ${{ secrets.MAIL_SERVICE_PORT }} +# MAIL_SERVICE_USERNAME: ${{ secrets.MAIL_SERVICE_USERNAME }} +# MAIL_SERVICE_PASSWORD: ${{ secrets.MAIL_SERVICE_PASSWORD }} +# MAIL_SERVICE_SMTP: ${{ secrets.MAIL_SERVICE_SMTP }} +# MAIL_SERVICE_STARTTLS: ${{ secrets.MAIL_SERVICE_STARTTLS }} +# MAIL_SERVICE_DOMAIN_NAME: ${{ secrets.MAIL_SERVICE_DOMAIN_NAME }} + + - name: Run Tests + run: mvn test env: ENV: production DATABASE_URL: ${{ secrets.DATABASE_URL }} @@ -57,6 +74,3 @@ jobs: MAIL_SERVICE_SMTP: ${{ secrets.MAIL_SERVICE_SMTP }} MAIL_SERVICE_STARTTLS: ${{ secrets.MAIL_SERVICE_STARTTLS }} MAIL_SERVICE_DOMAIN_NAME: ${{ secrets.MAIL_SERVICE_DOMAIN_NAME }} - - - name: Run Tests - run: mvn test diff --git a/.gitignore b/.gitignore index 5944935..49bad9c 100644 --- a/.gitignore +++ b/.gitignore @@ -35,5 +35,5 @@ build/ .DS_Store src/main/resources/application-dev.properties -.github/workflows/java-code-quality.yml + .github/workflows/maven-publish.yml diff --git a/src/main/java/com/libraryman_api/LibrarymanApiApplication.java b/src/main/java/com/libraryman_api/LibrarymanApiApplication.java index 6f54436..df9a8cf 100644 --- a/src/main/java/com/libraryman_api/LibrarymanApiApplication.java +++ b/src/main/java/com/libraryman_api/LibrarymanApiApplication.java @@ -2,8 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableAsync; @SpringBootApplication +@EnableAsync public class LibrarymanApiApplication { public static void main(String[] args) { From 0c26b577be9338b24ca0dbd2c2937d4df23db7d4 Mon Sep 17 00:00:00 2001 From: Ajay Negi Date: Mon, 2 Sep 2024 09:54:46 +0530 Subject: [PATCH 6/8] Implement code quality and formatting checks --- .github/workflows/build-test-lint-format.yml | 75 +++++++++++++++++++ .github/workflows/java-code-quality.yml | 55 -------------- .github/workflows/spring-boot-ci.yml | 76 -------------------- 3 files changed, 75 insertions(+), 131 deletions(-) create mode 100644 .github/workflows/build-test-lint-format.yml delete mode 100644 .github/workflows/java-code-quality.yml delete mode 100644 .github/workflows/spring-boot-ci.yml diff --git a/.github/workflows/build-test-lint-format.yml b/.github/workflows/build-test-lint-format.yml new file mode 100644 index 0000000..e4c1ef6 --- /dev/null +++ b/.github/workflows/build-test-lint-format.yml @@ -0,0 +1,75 @@ +name: Automated Testing + +on: + push: + branches: + - '**' + pull_request: + branches: + - 'main' + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Cache Maven dependencies + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Install dependencies + run: mvn clean install -DskipTests + + - name: Run Tests + run: mvn test + env: + ENV: production + DATABASE_URL: ${{ secrets.DATABASE_URL }} + DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }} + DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} + DATABASE_DRIVER_CLASS_NAME: ${{ secrets.DATABASE_DRIVER_CLASS_NAME }} + + MAIL_SERVICE_HOST: ${{ secrets.MAIL_SERVICE_HOST }} + MAIL_SERVICE_PORT: ${{ secrets.MAIL_SERVICE_PORT }} + MAIL_SERVICE_USERNAME: ${{ secrets.MAIL_SERVICE_USERNAME }} + MAIL_SERVICE_PASSWORD: ${{ secrets.MAIL_SERVICE_PASSWORD }} + MAIL_SERVICE_SMTP: ${{ secrets.MAIL_SERVICE_SMTP }} + MAIL_SERVICE_STARTTLS: ${{ secrets.MAIL_SERVICE_STARTTLS }} + MAIL_SERVICE_DOMAIN_NAME: ${{ secrets.MAIL_SERVICE_DOMAIN_NAME }} + + lint-and-format: + runs-on: ubuntu-latest + needs: build-and-test + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Run Checkstyle + run: mvn checkstyle:check + + - name: Run PMD + run: mvn pmd:check + + - name: Run SpotBugs + run: mvn spotbugs:check + + - name: Verify code formatting with Spotless (excluding Javadocs) + run: mvn spotless:check -Dspotless.apply.skip diff --git a/.github/workflows/java-code-quality.yml b/.github/workflows/java-code-quality.yml deleted file mode 100644 index 4ee78c4..0000000 --- a/.github/workflows/java-code-quality.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Java Code Quality and Formatting - -on: [push, pull_request] - -jobs: - lint: - name: Analyze and Lint Java Code - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - # This step checks out the code from your repository so the workflow can analyze it. - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - # This step sets up Java Development Kit (JDK) version 17, which is required to compile and run your Java code. - - - name: Cache Maven dependencies - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - # This step caches Maven dependencies to speed up the build process. It saves the downloaded dependencies - # so that they don't need to be downloaded again in future runs unless the `pom.xml` file changes. - - - name: Install dependencies - run: mvn install -DskipTests - # This command installs all the necessary dependencies for your project based on the `pom.xml` file. - # The `-DskipTests` flag is used to skip running tests at this stage, focusing on dependency installation. - - - name: Run Checkstyle - run: mvn checkstyle:check - # This command runs Checkstyle, a tool that checks your Java code against defined coding standards. - # It helps ensure that your code follows best practices and is consistently formatted. - - - name: Run PMD - run: mvn pmd:check - # This command runs PMD, a static code analysis tool that looks for potential bugs and code quality issues. - # It helps you identify common mistakes or bad practices in your code. - - - name: Run SpotBugs - run: mvn spotbugs:check - # This command runs SpotBugs, another static analysis tool that focuses on finding bugs in your code. - # SpotBugs can detect various types of bugs that could lead to issues in production. - - - name: Verify code formatting with Spotless (excluding Javadocs) - run: mvn spotless:check -Dspotless.apply.skip - # This command runs Spotless with the Javadoc checks skipped. - # The `-Dspotless.apply.skip` flag is used to bypass the application of Spotless checks for Javadocs. diff --git a/.github/workflows/spring-boot-ci.yml b/.github/workflows/spring-boot-ci.yml deleted file mode 100644 index 028d9d0..0000000 --- a/.github/workflows/spring-boot-ci.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Spring Boot CI Pipeline - -on: - push: - branches: - - '**' - pull_request: - branches: - - 'main' - -jobs: - build-and-test: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Install dependencies - run: mvn clean install -DskipTests - - - name: Output environment variables - run: | - echo "ENV=$ENV" - echo "DATABASE_URL=$DATABASE_URL" - echo "DATABASE_USERNAME=$DATABASE_USERNAME" - echo "DATABASE_PASSWORD=$DATABASE_PASSWORD" - echo "DATABASE_DRIVER_CLASS_NAME=$DATABASE_DRIVER_CLASS_NAME" - echo "MAIL_SERVICE_HOST=$MAIL_SERVICE_HOST" - echo "MAIL_SERVICE_PORT=$MAIL_SERVICE_PORT" - echo "MAIL_SERVICE_USERNAME=$MAIL_SERVICE_USERNAME" - echo "MAIL_SERVICE_PASSWORD=$MAIL_SERVICE_PASSWORD" - echo "MAIL_SERVICE_SMTP=$MAIL_SERVICE_SMTP" - echo "MAIL_SERVICE_STARTTLS=$MAIL_SERVICE_STARTTLS" - echo "MAIL_SERVICE_DOMAIN_NAME=$MAIL_SERVICE_DOMAIN_NAME" - - -# - name: Run Spring Boot Application -# run: mvn spring-boot:run -# env: -# ENV: production -# DATABASE_URL: ${{ secrets.DATABASE_URL }} -# DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }} -# DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} -# DATABASE_DRIVER_CLASS_NAME: ${{ secrets.DATABASE_DRIVER_CLASS_NAME }} -# -# MAIL_SERVICE_HOST: ${{ secrets.MAIL_SERVICE_HOST }} -# MAIL_SERVICE_PORT: ${{ secrets.MAIL_SERVICE_PORT }} -# MAIL_SERVICE_USERNAME: ${{ secrets.MAIL_SERVICE_USERNAME }} -# MAIL_SERVICE_PASSWORD: ${{ secrets.MAIL_SERVICE_PASSWORD }} -# MAIL_SERVICE_SMTP: ${{ secrets.MAIL_SERVICE_SMTP }} -# MAIL_SERVICE_STARTTLS: ${{ secrets.MAIL_SERVICE_STARTTLS }} -# MAIL_SERVICE_DOMAIN_NAME: ${{ secrets.MAIL_SERVICE_DOMAIN_NAME }} - - - name: Run Tests - run: mvn test - env: - ENV: production - DATABASE_URL: ${{ secrets.DATABASE_URL }} - DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }} - DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} - DATABASE_DRIVER_CLASS_NAME: ${{ secrets.DATABASE_DRIVER_CLASS_NAME }} - - MAIL_SERVICE_HOST: ${{ secrets.MAIL_SERVICE_HOST }} - MAIL_SERVICE_PORT: ${{ secrets.MAIL_SERVICE_PORT }} - MAIL_SERVICE_USERNAME: ${{ secrets.MAIL_SERVICE_USERNAME }} - MAIL_SERVICE_PASSWORD: ${{ secrets.MAIL_SERVICE_PASSWORD }} - MAIL_SERVICE_SMTP: ${{ secrets.MAIL_SERVICE_SMTP }} - MAIL_SERVICE_STARTTLS: ${{ secrets.MAIL_SERVICE_STARTTLS }} - MAIL_SERVICE_DOMAIN_NAME: ${{ secrets.MAIL_SERVICE_DOMAIN_NAME }} From 739914b0ce93a52d903c92163b98aedcd21e97ca Mon Sep 17 00:00:00 2001 From: Ajay Negi Date: Mon, 2 Sep 2024 10:03:00 +0530 Subject: [PATCH 7/8] Implement code quality and formatting checks --- .github/workflows/build-test-lint-format.yml | 46 ++++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build-test-lint-format.yml b/.github/workflows/build-test-lint-format.yml index e4c1ef6..5d6375a 100644 --- a/.github/workflows/build-test-lint-format.yml +++ b/.github/workflows/build-test-lint-format.yml @@ -49,27 +49,27 @@ jobs: MAIL_SERVICE_STARTTLS: ${{ secrets.MAIL_SERVICE_STARTTLS }} MAIL_SERVICE_DOMAIN_NAME: ${{ secrets.MAIL_SERVICE_DOMAIN_NAME }} - lint-and-format: - runs-on: ubuntu-latest - needs: build-and-test - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - - name: Run Checkstyle - run: mvn checkstyle:check - - - name: Run PMD - run: mvn pmd:check - - - name: Run SpotBugs - run: mvn spotbugs:check +# lint-and-format: +# runs-on: ubuntu-latest +# needs: build-and-test +# steps: +# - name: Checkout code +# uses: actions/checkout@v3 +# +# - name: Set up JDK 17 +# uses: actions/setup-java@v3 +# with: +# java-version: '17' +# distribution: 'temurin' +# +# - name: Run Checkstyle +# run: mvn checkstyle:check +# +# - name: Run PMD +# run: mvn pmd:check +# +# - name: Run SpotBugs +# run: mvn spotbugs:check - - name: Verify code formatting with Spotless (excluding Javadocs) - run: mvn spotless:check -Dspotless.apply.skip +# - name: Verify code formatting with Spotless (excluding Javadocs) +# run: mvn spotless:check -Dspotless.apply.skip From 4aecfe7a3c8654597bac650e0efb2ef23f0f5475 Mon Sep 17 00:00:00 2001 From: Ajay Negi Date: Mon, 2 Sep 2024 10:38:47 +0530 Subject: [PATCH 8/8] Implement code quality and formatting checks --- .github/workflows/build-test-lint-format.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-test-lint-format.yml b/.github/workflows/build-test-lint-format.yml index 5d6375a..03f928c 100644 --- a/.github/workflows/build-test-lint-format.yml +++ b/.github/workflows/build-test-lint-format.yml @@ -21,13 +21,13 @@ jobs: java-version: '17' distribution: 'temurin' - - name: Cache Maven dependencies - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- +# - name: Cache Maven dependencies +# uses: actions/cache@v3 +# with: +# path: ~/.m2/repository +# key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} +# restore-keys: | +# ${{ runner.os }}-maven- - name: Install dependencies run: mvn clean install -DskipTests