Skip to content

Commit

Permalink
[EC-95] Reusable workflows for code review pipelines (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusty93 authored Jan 22, 2024
1 parent e6cf5de commit f9c2c4e
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 161 deletions.
20 changes: 13 additions & 7 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -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
- changed-files:
- any-glob-to-any-file: ['README.md']

hotfix:
- base-branch: ['releases/*']
44 changes: 44 additions & 0 deletions .github/workflows/call_code_review.yml
Original file line number Diff line number Diff line change
@@ -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 }}
44 changes: 0 additions & 44 deletions .github/workflows/code_review_functions.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/code_review_libs.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/code_review_ms.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/pr_functions.yml
Original file line number Diff line number Diff line change
@@ -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'
26 changes: 26 additions & 0 deletions .github/workflows/pr_labeler.yml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions .github/workflows/pr_libs.yml
Original file line number Diff line number Diff line change
@@ -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'
31 changes: 31 additions & 0 deletions .github/workflows/pr_ms.yml
Original file line number Diff line number Diff line change
@@ -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'
Loading

0 comments on commit f9c2c4e

Please sign in to comment.