diff --git a/.github/workflows/code_review_ms.yml b/.github/workflows/code_review_ms.yml index fdb049292..9155e03e9 100644 --- a/.github/workflows/code_review_ms.yml +++ b/.github/workflows/code_review_ms.yml @@ -1,46 +1,35 @@ name: Code Review onboarding-ms -# Controls when the workflow will run on: + workflow_dispatch: + pull_request: branches: - main types: - opened + - edited - synchronize - reopened + - ready_for_review paths: - 'apps/onboarding-ms/**' - - workflow_dispatch: - + - 'apps/onboarding-ms/pom.xml' + - '.github/workflows/code_review_ms.yml' + - '.github/workflows/templates/call_code_review.yml' + + # TODO: remove, just for testing + push: + branches: + - EC-95-pipeline-code-review-con-reusable-workflows jobs: - code-review: - runs-on: ubuntu-latest - permissions: - packages: read - id-token: write - steps: - - name: Setup Maven Action - uses: s4u/setup-maven-action@fa2c7e4517ed008b1f73e7e0195a9eecf5582cd4 # pin@v1.11.0 - with: - checkout-fetch-depth: 0 - java-version: 17 - java-distribution: 'temurin' - maven-version: '3.9.5' - cache-enabled: true - - - name: Build and analyze on Pull Requests - shell: bash - run: mvn --projects :test-coverage --also-make verify -Ponboarding-ms,report,coverage - -Dsonar.organization=pagopa - -Dsonar.projectKey=pagopa_selfcare-onboarding - -Dsonar.token=${{ secrets.SONAR_TOKEN }} - -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} - -Dsonar.pullrequest.branch=${{ github.head_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 + code_review: + uses: ./.github/workflows/templates/call_code_review.yml + name: Microservice Code Review + secrets: inherit + with: + pr_number: ${{ github.event.pull_request.number }} + source_branch: ${{ github.head_ref }} + target_branch: ${{ github.base_ref }} diff --git a/.github/workflows/templates/call_code_review.yml b/.github/workflows/templates/call_code_review.yml new file mode 100644 index 000000000..2ddd273c4 --- /dev/null +++ b/.github/workflows/templates/call_code_review.yml @@ -0,0 +1,41 @@ +on: + workflow_call: + inputs: + pr_number: + type: string + required: true + source_branch: + type: string + required: true + target_branch: + type: string + required: true + +jobs: + code_review: + name: 'Code Review' + runs-on: ubuntu-20.04 + + steps: + + - name: Setup Maven Action + uses: s4u/setup-maven-action@fa2c7e4517ed008b1f73e7e0195a9eecf5582cd4 + with: + checkout-fetch-depth: 0 + java-version: 17 + java-distribution: 'temurin' + maven-version: '3.9.5' + cache-enabled: true + + - name: Build and Analyze + shell: bash + run: mvn --projects :test-coverage --also-make verify -Ponboarding-ms,report,coverage + -Dsonar.organization=pagopa + -Dsonar.projectKey=pagopa_selfcare-onboarding + -Dsonar.token=${{ secrets.SONAR_TOKEN }} + -Dsonar.pullrequest.key=${{ inputs.pr_number }} + -Dsonar.pullrequest.branch=${{ inputs.source_branch }} + -Dsonar.pullrequest.base=refs/remotes/origin/${{ inputs.target_branch }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file