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 }}