diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0df2d3d..76fc753 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,6 +9,75 @@ env: AWS_REGION: us-east-1 jobs: + + # ========================================================= + # TESTS (JUnit + JaCoCo) + # ========================================================= + test: + name: Test Application + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + cache: maven + + - name: Run tests with coverage + working-directory: app + run: mvn -B clean verify + + # ========================================================= + # SONARCLOUD + # ========================================================= + sonarqube: + name: SonarCloud + runs-on: ubuntu-latest + needs: test + if: github.ref == 'refs/heads/main' + environment: production + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: zulu + + - name: Cache SonarQube packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Build, test and analyze + working-directory: app + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + mvn -B clean verify \ + org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ + -Dsonar.projectKey=soat-tech-challenge-2025_lambda-identification-client \ + -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml + deploy: runs-on: ubuntu-latest environment: Production diff --git a/app/pom.xml b/app/pom.xml index c305023..19f663c 100644 --- a/app/pom.xml +++ b/app/pom.xml @@ -16,6 +16,7 @@ 2.16.2 1.2.3 3.11.3 + soat-tech-challenge-2025-1