From 34825978fd57afd3c8141fc5c379b51802192ce3 Mon Sep 17 00:00:00 2001 From: Diego Lagos <92735530+diegolagospagopa@users.noreply.github.com> Date: Thu, 16 Jan 2025 17:02:02 +0100 Subject: [PATCH] breaking: P4ADEV-1930 update github actions (#13) * updated release and snapshot action * updated codereview * Minor fix * Minor fix * Minor fix * typo fix * try sonar cloud action * try sonar cloud action * try sonar cloud action * pre-commit fixs --- .github/workflows/codereview.yml | 116 ++++++++++++++------- .github/workflows/flow-release.yml | 55 ++++++++++ .github/workflows/flow-snapshot-docker.yml | 86 +++++++++++++++ .github/workflows/release.yml | 24 ----- .github/workflows/snapshot-docker.yml | 23 ---- force-release | 1 + src/main/resources/application.yml | 2 +- 7 files changed, 222 insertions(+), 85 deletions(-) create mode 100644 .github/workflows/flow-release.yml create mode 100644 .github/workflows/flow-snapshot-docker.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/snapshot-docker.yml create mode 100644 force-release diff --git a/.github/workflows/codereview.yml b/.github/workflows/codereview.yml index 22616bd..216b512 100644 --- a/.github/workflows/codereview.yml +++ b/.github/workflows/codereview.yml @@ -2,48 +2,90 @@ name: TEMPLATE-PAYMENTS - Code Review on: push: - branches: - - main - - uat - - develop + branches: [ main, uat, develop ] pull_request: - types: - - opened - - edited - - synchronize + types: [ opened, edited, synchronize ] + branches: [ main, uat, develop ] + +env: + JAVA_VERSION: '21' + JAVA_DISTRIBUTION: 'corretto' + jobs: - build: + code-review: + name: Code Review & Quality Analysis runs-on: ubuntu-latest + timeout-minutes: 30 + steps: - - name: Checkout sources - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7 + - name: Checkout repository + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Java - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 #v4.2.1 - with: - distribution: 'corretto' - java-version: 21 - - - name: Grant execute permission for gradlew - run: chmod +x ./gradlew - - - name: Build with Gradle - working-directory: ./ - run: ./gradlew clean build jacocoTestReport - - - name: Sonar Scan - working-directory: ./ - run: > - ./gradlew sonar - -Dorg.gradle.jvmargs=-Xmx4096M - -Dsonar.host.url=https://sonarcloud.io - -Dsonar.organization=${{ vars.SONARCLOUD_ORG }} - -Dsonar.projectKey=${{ vars.SONARCLOUD_PROJECT_KEY }} - -Dsonar.projectName="${{ vars.SONARCLOUD_PROJECT_NAME }}" - -Dsonar.token=${{ secrets.SONAR_TOKEN }} - -Dsonar.sources=src/main - -Dsonar.tests=src/test - -Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml - -Dsonar.exclusions='**/enums/**, **/model/**, **/dto/**, **/*Constant*, **/*Config.java, **/*Scheduler.java, **/*Application.java, **/src/test/**, **/Dummy*.java' + uses: actions/setup-java@v4 + with: + distribution: ${{ env.JAVA_DISTRIBUTION }} + java-version: ${{ env.JAVA_VERSION }} + cache: 'gradle' + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Run Tests & Coverage + id: tests + run: ./gradlew clean build jacocoTestReport --info + + - name: SonarCloud Scan + uses: SonarSource/sonarqube-scan-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.organization=${{ vars.SONARCLOUD_ORG }} + -Dsonar.projectKey=${{ vars.SONARCLOUD_PROJECT_KEY }} + -Dsonar.sources=src/main + -Dsonar.tests=src/test + -Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml + -Dsonar.exclusions='**/enums/**, **/model/**, **/dto/**, **/*Constant*, **/*Config.java, **/*Scheduler.java, **/*Application.java, **/src/test/**, **/Dummy*.java' + -Dsonar.qualitygate.wait=true + + - name: SonarQube Quality Gate check + uses: sonarsource/sonarqube-quality-gate-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + scanMetadataReportFile: .scannerwork/report-task.txt + + - name: Save Test Results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-reports-${{ github.run_id }} + path: build/reports/tests/ + retention-days: 7 + + - name: Save Coverage Results + if: always() + uses: actions/upload-artifact@v4 + with: + name: coverage-reports-${{ github.run_id }} + path: build/reports/jacoco/ + retention-days: 7 + + - name: Merge Reports + if: always() + uses: actions/upload-artifact/merge@v4 + with: + name: all-reports-${{ github.run_id }} + pattern: '*-reports-${{ github.run_id }}' + retention-days: 7 diff --git a/.github/workflows/flow-release.yml b/.github/workflows/flow-release.yml new file mode 100644 index 0000000..b2c7cc3 --- /dev/null +++ b/.github/workflows/flow-release.yml @@ -0,0 +1,55 @@ +name: 🚀 Flow Release + +on: + push: + branches: + - develop + - uat + - main + paths-ignore: + - 'CODEOWNERS' + - '**.md' + - '.**' + workflow_dispatch: + +jobs: + + checkout: + name: 🔖 Checkout Repository + runs-on: ubuntu-22.04 + steps: + - name: Checkout code + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 + with: + ref: ${{ github.ref_name }} + + payments-flow-release: + name: 🚀 Release + runs-on: ubuntu-22.04 + needs: checkout + steps: + - name: 🚀 release + docker + # /~https://github.com/pagopa/github-actions-template/releases/tag/v2.0.0 + uses: pagopa/github-actions-template/payments-flow-release@b825ee193430395706a4a7e580b8435bdded0227 + with: + current_branch: ${{ github.ref_name }} + + azure-devops-trigger: + name: 🅰️ Azure DevOps Pipeline Trigger + needs: payments-flow-release + runs-on: ubuntu-22.04 + steps: + - name: Trigger Azure DevOps Pipeline + # /~https://github.com/pagopa/github-actions-template/releases/tag/v2.1.0 + uses: pagopa/github-actions-template/azure-devops-trigger-pipeline@cad30356d9046af6e7b0cee43db4cf919cc408f9 + with: + enable_azure_devops_step: 'true' + azure_devops_project_url: 'https://dev.azure.com/pagopaspa/p4pa-projects' + azure_devops_pipeline_name: 'p4pa-payhub-deploy-aks.deploy' + azure_devops_pat: ${{ secrets.AZURE_DEVOPS_TOKEN }} + azure_template_parameters: | + { + "APPS_TOP": "[p4pa-auth]", + "POSTMAN_BRANCH": "${{ github.ref_name }}", + "TRIGGER_MESSAGE": "p4pa-auth" + } diff --git a/.github/workflows/flow-snapshot-docker.yml b/.github/workflows/flow-snapshot-docker.yml new file mode 100644 index 0000000..090afe0 --- /dev/null +++ b/.github/workflows/flow-snapshot-docker.yml @@ -0,0 +1,86 @@ +name: 📦 Flow Snapshot Docker + +on: + push: + branches-ignore: + - 'develop' + - 'uat' + - 'main' + paths-ignore: + - 'CODEOWNERS' + - '**.md' + - '.**' + workflow_dispatch: + inputs: + docker_build_enabled: + description: 'Enable Docker build' + required: false + default: 'true' + azdo_trigger_enabled: + description: 'Enable Azure DevOps trigger' + required: false + default: 'true' + argocd_target_branch: + description: 'argocd target branch name' + required: false + default: 'main' + postman_branch: + description: postman branch name' + required: false + default: 'develop' + +env: + # branch choosed by workflow_dispatch or by push event + CURRENT_BRANCH: ${{ github.event.inputs.branch || github.ref_name }} + +jobs: + checkout: + name: 🔖 Checkout Repository + runs-on: ubuntu-22.04 + steps: + - name: Checkout code + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 + with: + ref: ${{ env.CURRENT_BRANCH }} + + docker-build: + name: 📦 Docker Build and Push + needs: checkout + runs-on: ubuntu-22.04 + if: ${{ github.event_name == 'push' || github.event.inputs.docker_build_enabled == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 + with: + ref: ${{ env.CURRENT_BRANCH }} + + - name: Run Snapshot Docker Build/Push + # /~https://github.com/pagopa/github-actions-template/releases/tag/v2.0.0 + uses: pagopa/github-actions-template/payments-flow-docker-snapshot@b825ee193430395706a4a7e580b8435bdded0227 + with: + current_branch: ${{ github.ref_name }} + + azure-devops-trigger: + name: 🅰️ Azure DevOps Pipeline Trigger + needs: docker-build + runs-on: ubuntu-22.04 + if: | + always() && + needs.docker-build.result != 'failure' && + github.event.inputs.azdo_trigger_enabled == 'true' + steps: + - name: Trigger Azure DevOps Pipeline + # /~https://github.com/pagopa/github-actions-template/releases/tag/v2.1.0 + uses: pagopa/github-actions-template/azure-devops-trigger-pipeline@cad30356d9046af6e7b0cee43db4cf919cc408f9 + with: + enable_azure_devops_step: 'true' + azure_devops_project_url: 'https://dev.azure.com/pagopaspa/p4pa-projects' + azure_devops_pipeline_name: 'p4pa-payhub-deploy-aks.deploy' + azure_devops_pat: ${{ secrets.AZURE_DEVOPS_TOKEN }} + azure_template_parameters: | + { + "APPS_TOP": "[one-color]", + "ARGOCD_TARGET_BRANCH": "${{ github.event.inputs.argocd_target_branch }}", + "POSTMAN_BRANCH": "${{ github.event.inputs.postman_branch }}", + "TRIGGER_MESSAGE": "p4pa-auth" + } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 07ae6f5..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Release - -on: - # Trigger the workflow on push on the main branch - push: - branches: - - main - paths-ignore: - - 'CODEOWNERS' - - '**.md' - - '.**' - -jobs: - release: - name: Release - runs-on: ubuntu-22.04 - - steps: - - - name: 🚀 Release with docker action - id: release - uses: pagopa/eng-github-actions-iac-template/global/release-with-docker@main # - with: - github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/snapshot-docker.yml b/.github/workflows/snapshot-docker.yml deleted file mode 100644 index 3496adf..0000000 --- a/.github/workflows/snapshot-docker.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Snapshot docker build and push - -on: - push: - # Sequence of patterns matched against refs/heads - branches-ignore: - - 'main' - paths-ignore: - - 'CODEOWNERS' - - '**.md' - - '.**' - -jobs: - release: - name: Snapshot Docker - runs-on: ubuntu-22.04 - - steps: - - name: 📦 Docker build and push - id: release - uses: pagopa/eng-github-actions-iac-template/global/docker-build-push@main # - with: - github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/force-release b/force-release new file mode 100644 index 0000000..dd3467d --- /dev/null +++ b/force-release @@ -0,0 +1 @@ +1623 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 61bc0a7..2d2296c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - http: "\${SERVER_PORT:8080}" + http: "${SERVER_PORT:8080}" spring: application: