From 66ca8ca91d81b8a24a1023c46d24e9bb41a564b1 Mon Sep 17 00:00:00 2001 From: Manuel Rafeli Date: Tue, 28 Nov 2023 16:19:43 +0100 Subject: [PATCH] ops: using cache and 3.9.5 version about maven on workflow (#52) * added mock upload contract * remove sparse checkout from code review * fetch-depth to 0 * test * add Run tests step * fix run tests * test * setup-maven-action * fix version * fix version * fix test value * cache-enabled tru * cache-enabled: true * test * enable cache * fix checkout ref * fix code review functions * use pin-github-action --- .github/workflows/check_pr.yml | 4 ++-- .github/workflows/code_review_functions.yml | 18 +++++++--------- .github/workflows/code_review_libs.yml | 13 ++++++------ .github/workflows/code_review_ms.yml | 21 ++++++++----------- .../workflows/deploy_onboarding_functions.yml | 17 +++++++-------- .github/workflows/release_onboarding_sdk.yml | 7 ++++--- .../service/OnboardingServiceDefaultTest.java | 6 ++++++ 7 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.github/workflows/check_pr.yml b/.github/workflows/check_pr.yml index 39a1633a1..f591e94d2 100644 --- a/.github/workflows/check_pr.yml +++ b/.github/workflows/check_pr.yml @@ -20,14 +20,14 @@ jobs: name: Add label to PR based on the paths of files being changed runs-on: ubuntu-latest steps: - - uses: actions/labeler@v4 + - uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # pin@v4 check_pr_size: name: Check PR size doesn't break set limit runs-on: ubuntu-latest steps: # checkout your code with your git history - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 with: fetch-depth: 0 diff --git a/.github/workflows/code_review_functions.yml b/.github/workflows/code_review_functions.yml index de18c8e07..8eb910598 100644 --- a/.github/workflows/code_review_functions.yml +++ b/.github/workflows/code_review_functions.yml @@ -22,18 +22,14 @@ jobs: packages: read id-token: write steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - apps/onboarding-functions - libs/ - test-coverage/ - - - name: Set up JDK 17 - uses: actions/setup-java@v3 + - name: Setup Maven Action + uses: s4u/setup-maven-action@fa2c7e4517ed008b1f73e7e0195a9eecf5582cd4 # pin@v1.11.0 with: + checkout-fetch-depth: 0 java-version: 17 - distribution: 'temurin' + java-distribution: 'temurin' + maven-version: '3.9.5' + cache-enabled: true - name: Build and analyze on Pull Requests shell: bash @@ -43,7 +39,7 @@ jobs: -Dsonar.token=${{ secrets.SONAR_TOKEN }} -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} -Dsonar.pullrequest.branch=${{ github.head_ref }} - -Dsonar.pullrequest.base=${{ github.base_ref }} + -Dsonar.pullrequest.base=refs/remotes/origin/${{ github.base_ref }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/code_review_libs.yml b/.github/workflows/code_review_libs.yml index cd6d61a87..898374161 100644 --- a/.github/workflows/code_review_libs.yml +++ b/.github/workflows/code_review_libs.yml @@ -22,13 +22,14 @@ jobs: packages: read id-token: write steps: - - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 + - name: Setup Maven Action + uses: s4u/setup-maven-action@fa2c7e4517ed008b1f73e7e0195a9eecf5582cd4 # pin@v1.11.0 with: + checkout-fetch-depth: 0 java-version: 17 - distribution: 'temurin' + java-distribution: 'temurin' + maven-version: '3.9.5' + cache-enabled: true - name: Build and analyze on Pull Requests shell: bash @@ -38,7 +39,7 @@ jobs: -Dsonar.token=${{ secrets.SONAR_TOKEN }} -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} -Dsonar.pullrequest.branch=${{ github.head_ref }} - -Dsonar.pullrequest.base=${{ github.base_ref }} + -Dsonar.pullrequest.base=refs/remotes/origin/${{ github.base_ref }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/code_review_ms.yml b/.github/workflows/code_review_ms.yml index cd3a1a62e..ebe33e844 100644 --- a/.github/workflows/code_review_ms.yml +++ b/.github/workflows/code_review_ms.yml @@ -12,9 +12,10 @@ on: - reopened paths: - 'apps/onboarding-ms/**' - + workflow_dispatch: + jobs: code-review: @@ -23,18 +24,14 @@ jobs: packages: read id-token: write steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - apps/onboarding-ms - libs/ - test-coverage/ - - - name: Set up JDK 17 - uses: actions/setup-java@v3 + - name: Setup Maven Action + uses: s4u/setup-maven-action@fa2c7e4517ed008b1f73e7e0195a9eecf5582cd4 # pin@v1.11.0 with: + checkout-fetch-depth: 0 java-version: 17 - distribution: 'temurin' + java-distribution: 'temurin' + maven-version: '3.9.5' + cache-enabled: true - name: Build and analyze on Pull Requests shell: bash @@ -44,7 +41,7 @@ jobs: -Dsonar.token=${{ secrets.SONAR_TOKEN }} -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} -Dsonar.pullrequest.branch=${{ github.head_ref }} - -Dsonar.pullrequest.base=${{ github.base_ref }} + -Dsonar.pullrequest.base=refs/remotes/origin/${{ github.base_ref }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/deploy_onboarding_functions.yml b/.github/workflows/deploy_onboarding_functions.yml index 6c6afc240..6dfac8501 100644 --- a/.github/workflows/deploy_onboarding_functions.yml +++ b/.github/workflows/deploy_onboarding_functions.yml @@ -34,7 +34,7 @@ jobs: build: name: Build Onboarding Functions runs-on: ubuntu-latest - if: ${{ (github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == 'true') }} + if: ${{ (github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true) }} environment: "${{ inputs.environment != null && inputs.environment || (github.base_ref == 'main' && 'prod' || (github.base_ref == 'develop' && 'uat' || 'dev')) }}-cd" permissions: packages: write @@ -42,16 +42,15 @@ jobs: id-token: write steps: - - uses: actions/checkout@v4 - name: Checkout - with: - ref: ${{ github.ref_name }} - - - name: Set up JDK 17 - uses: actions/setup-java@v3 + - name: Setup Maven Action + uses: s4u/setup-maven-action@fa2c7e4517ed008b1f73e7e0195a9eecf5582cd4 # pin@v1.11.0 with: + checkout-fetch-depth: 0 + checkout-ref: ${{ github.ref_name }} java-version: 17 - distribution: 'temurin' + java-distribution: 'temurin' + maven-version: '3.9.5' + cache-enabled: true - name: "Build Functions and dependencies" shell: bash diff --git a/.github/workflows/release_onboarding_sdk.yml b/.github/workflows/release_onboarding_sdk.yml index 258a5c6f0..d95570a53 100644 --- a/.github/workflows/release_onboarding_sdk.yml +++ b/.github/workflows/release_onboarding_sdk.yml @@ -3,6 +3,7 @@ name: Release onboarding sdk on: workflow_dispatch: + jobs: setup: name: Release @@ -10,18 +11,18 @@ jobs: permissions: packages: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 with: ref: ${{ github.ref_name }} - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # pin@v3 with: distribution: 'temurin' java-version: '17' cache: maven - - uses: s4u/maven-settings-action@v2.8.0 + - uses: s4u/maven-settings-action@60912582505985be4cc55d2b890eb32767f8de5f # pin@v2.8.0 with: servers: '[{"id": "selfcare-github", "username": "${{ github.actor }}", "password": "${{ secrets.GITHUB_TOKEN }}"}]' diff --git a/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/OnboardingServiceDefaultTest.java b/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/OnboardingServiceDefaultTest.java index e1310e37e..eb7974759 100644 --- a/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/OnboardingServiceDefaultTest.java +++ b/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/OnboardingServiceDefaultTest.java @@ -8,6 +8,7 @@ import io.quarkus.test.vertx.RunOnVertxContext; import io.quarkus.test.vertx.UniAsserter; import io.smallrye.mutiny.Uni; +import it.pagopa.selfcare.azurestorage.AzureBlobClient; import it.pagopa.selfcare.onboarding.common.InstitutionType; import it.pagopa.selfcare.onboarding.common.PartyRole; import it.pagopa.selfcare.onboarding.controller.request.*; @@ -60,6 +61,9 @@ public class OnboardingServiceDefaultTest { @InjectMock ProductService productService; + @InjectMock + AzureBlobClient azureBlobClient; + @InjectMock SignatureService signatureService; @@ -599,6 +603,8 @@ void complete(UniAsserter asserter) { mockSimpleProductValidAssert(onboarding.getProductId(), false, asserter); mockVerifyOnboardingNotFound(asserter); + when(azureBlobClient.uploadFile(any(),any(),any())).thenReturn("upload-file"); + asserter.assertThat(() -> onboardingService.complete(onboarding.getId().toHexString(), testFile), Assertions::assertNotNull); }