From 4572a5cf40dc2bf19c7d2cf595eea545dc9eb539 Mon Sep 17 00:00:00 2001 From: Ajay Negi Date: Mon, 2 Sep 2024 09:46:07 +0530 Subject: [PATCH] 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) {