diff --git a/.github/labeler.yml b/.github/labeler.yml index c8c2a7d4d..3aa2b5d5a 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,16 +1,22 @@ functions: -- apps/onboarding-functions/** + - changed-files: + - any-glob-to-any-file: ['apps/onboarding-functions/**'] onboarding-ms: -- apps/onboarding-ms/** + - changed-files: + - any-glob-to-any-file: ['apps/onboarding-ms/**'] libs: -- libs/** + - changed-files: + - any-glob-to-any-file: ['libs/**'] ops: -- .github/** -- infra/** -- .identity/** + - changed-files: + - any-glob-to-any-file: ['.github/**', 'infra/**', '.identity/**'] docs: -- README.md \ No newline at end of file + - changed-files: + - any-glob-to-any-file: ['README.md'] + +hotfix: + - base-branch: ['releases/*'] \ No newline at end of file diff --git a/.github/workflows/call_code_review.yml b/.github/workflows/call_code_review.yml new file mode 100644 index 000000000..ed2f520da --- /dev/null +++ b/.github/workflows/call_code_review.yml @@ -0,0 +1,44 @@ +on: + workflow_call: + inputs: + pr_number: + type: string + required: true + source_branch: + type: string + required: true + target_branch: + type: string + required: true + sonar_key: + type: string + required: true + +jobs: + code_review: + name: 'Build & Analysis' + 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=${{ inputs.sonar_key }} + -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 diff --git a/.github/workflows/code_review_functions.yml b/.github/workflows/code_review_functions.yml deleted file mode 100644 index 25ef749bd..000000000 --- a/.github/workflows/code_review_functions.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Code Review onboarding-functions - -on: - pull_request: - branches: - - main - types: - - opened - - synchronize - - reopened - paths: - - 'apps/onboarding-functions/**' - - workflow_dispatch: - -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-functions,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 diff --git a/.github/workflows/code_review_libs.yml b/.github/workflows/code_review_libs.yml deleted file mode 100644 index 2e114d5e9..000000000 --- a/.github/workflows/code_review_libs.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Code Review Libs - -on: - pull_request: - branches: - - main - types: - - opened - - synchronize - - reopened - paths: - - 'libs/**' - - workflow_dispatch: - -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-sdk,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 diff --git a/.github/workflows/code_review_ms.yml b/.github/workflows/code_review_ms.yml deleted file mode 100644 index fdb049292..000000000 --- a/.github/workflows/code_review_ms.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Code Review onboarding-ms - -# Controls when the workflow will run -on: - pull_request: - branches: - - main - types: - - opened - - synchronize - - reopened - paths: - - 'apps/onboarding-ms/**' - - workflow_dispatch: - - -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 diff --git a/.github/workflows/pr_functions.yml b/.github/workflows/pr_functions.yml new file mode 100644 index 000000000..b8ae73cb4 --- /dev/null +++ b/.github/workflows/pr_functions.yml @@ -0,0 +1,31 @@ +name: Code Review onboarding-functions + +on: + workflow_dispatch: + + pull_request: + branches: + - main + types: + - opened + - edited + - synchronize + - reopened + - ready_for_review + paths: + - 'apps/onboarding-functions/**' + - 'apps/onboarding-ms/pom.xml' + - '.github/workflows/code_review_functions.yml' + - '.github/workflows/call_code_review.yml' + +jobs: + + code_review: + uses: ./.github/workflows/call_code_review.yml + name: OnBoarding function Code Review + secrets: inherit + with: + pr_number: ${{ github.event.pull_request.number }} + source_branch: ${{ github.head_ref }} + target_branch: ${{ github.base_ref }} + sonar_key: 'pagopa_selfcare-onboarding' diff --git a/.github/workflows/pr_labeler.yml b/.github/workflows/pr_labeler.yml new file mode 100644 index 000000000..9979fef3d --- /dev/null +++ b/.github/workflows/pr_labeler.yml @@ -0,0 +1,26 @@ +name: PR - Labeler + +on: + workflow_dispatch: + + pull_request: + branches: + - main + - releases/** + types: + - opened + - synchronize + +permissions: + contents: read + pull-requests: write + +jobs: + labeler: + name: PR Labeler + runs-on: ubuntu-20.04 + + steps: + - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5 + with: + sync-labels: true diff --git a/.github/workflows/pr_libs.yml b/.github/workflows/pr_libs.yml new file mode 100644 index 000000000..20862e4d5 --- /dev/null +++ b/.github/workflows/pr_libs.yml @@ -0,0 +1,30 @@ +name: Code Review Libs + +on: + workflow_dispatch: + + pull_request: + branches: + - main + types: + - opened + - edited + - synchronize + - reopened + - ready_for_review + paths: + - 'libs/**' + - '.github/workflows/code_review_libs.yml' + - '.github/workflows/call_code_review.yml' + +jobs: + + code_review: + uses: ./.github/workflows/call_code_review.yml + name: Libs Code Review + secrets: inherit + with: + pr_number: ${{ github.event.pull_request.number }} + source_branch: ${{ github.head_ref }} + target_branch: ${{ github.base_ref }} + sonar_key: 'pagopa_selfcare-onboarding' diff --git a/.github/workflows/pr_ms.yml b/.github/workflows/pr_ms.yml new file mode 100644 index 000000000..ef823328f --- /dev/null +++ b/.github/workflows/pr_ms.yml @@ -0,0 +1,31 @@ +name: Code Review onboarding-ms + +on: + workflow_dispatch: + + pull_request: + branches: + - main + types: + - opened + - edited + - synchronize + - reopened + - ready_for_review + paths: + - 'apps/onboarding-ms/**' + - 'apps/onboarding-ms/pom.xml' + - '.github/workflows/code_review_ms.yml' + - '.github/workflows/call_code_review.yml' + +jobs: + + code_review: + uses: ./.github/workflows/call_code_review.yml + name: OnBoarding ms Code Review + secrets: inherit + with: + pr_number: ${{ github.event.pull_request.number }} + source_branch: ${{ github.head_ref }} + target_branch: ${{ github.base_ref }} + sonar_key: 'pagopa_selfcare-onboarding' diff --git a/.github/workflows/check_pr.yml b/.github/workflows/pr_validation.yml similarity index 57% rename from .github/workflows/check_pr.yml rename to .github/workflows/pr_validation.yml index 5a770e7d4..c55401c25 100644 --- a/.github/workflows/check_pr.yml +++ b/.github/workflows/pr_validation.yml @@ -1,37 +1,29 @@ -name: Check PR +name: PR - Validation -# Controls when the workflow will run on: + workflow_dispatch: + pull_request: branches: - main + - releases/** types: - opened - synchronize - - reopened - -permissions: - pull-requests: write -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - labeler: - name: Add label to PR based on the paths of files being changed - runs-on: ubuntu-latest - steps: - - uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # pin@v4 - - check_pr_size: - name: Check PR size doesn't break set limit - runs-on: ubuntu-latest + validate_pr_size: + name: Ensure PR is small + runs-on: ubuntu-20.04 steps: - # checkout your code with your git history - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 + name: Checkout with: fetch-depth: 0 - name: Get total lines changed + shell: bash run: | size=$(git diff --stat origin/main --diff-filter=d \ | grep -v .lock \ @@ -45,12 +37,13 @@ jobs: echo "" echo "Total lines changed (note: *.lock files are excluded from this count): " echo $size + + - name: Evaluate Lines Changed shell: bash - - run: | + run: | if [[ $size -gt 500 ]] then echo "Warning - total lines changed is greater than 500." echo "Please consider breaking this PR down." exit 1 fi - shell: bash