Skip to content

Commit

Permalink
ops: code review workflow and test coverage (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuraf authored Nov 10, 2023
1 parent ae7d026 commit 40c43d7
Show file tree
Hide file tree
Showing 49 changed files with 382 additions and 69 deletions.
31 changes: 9 additions & 22 deletions .github/workflows/code_review_functions.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Code Review Functions
name: Code Review onboarding-functions

# Controls when the workflow will run
on:
pull_request:
branches:
Expand All @@ -11,7 +10,7 @@ on:
- synchronize
- reopened
paths:
- 'onboarding-functions/**'
- 'apps/onboarding-functions/**'

workflow_dispatch:

Expand All @@ -21,42 +20,30 @@ jobs:
runs-on: ubuntu-latest
permissions:
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
with:
java-version: 17
distribution: 'temurin'

- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar-project.properties/cache
key: ${{ runner.os }}-sonar-project.properties
restore-keys: ${{ runner.os }}-sonar-project.properties

- name: Build and analyze on Pull Requests
shell: bash
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
run: mvn --projects :test-coverage --also-make verify -Ponboarding-functions,report,coverage
-Dsonar.organization=pagopa
-Dsonar.projectKey=pagopa_selfcare-onboarding
-Dsonar.coverage.jacoco.xmlReportPaths=./target/jacoco-report/jacoco.xml
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.token=${{ secrets.SONAR_TOKEN }}
-Dsonar.coverage.exclusions='**/exception/**, **/response/**, **/request/**, **/entity/**, **/utils/**, **/*Constant*, **/*Config.java, **/src/test/**'
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
-Dsonar.pullrequest.branch=${{ github.head_ref }}
-Dsonar.pullrequest.base=${{ github.base_ref }}
--file onboarding-functions/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
44 changes: 44 additions & 0 deletions .github/workflows/code_review_libs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Code Review Libs

on:
pull_request:
branches:
- main
- develop
types:
- opened
- synchronize
- reopened
paths:
- 'libs/**'

workflow_dispatch:

jobs:

code-review:
runs-on: ubuntu-latest
permissions:
packages: read
id-token: write
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- 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=${{ github.base_ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
8 changes: 3 additions & 5 deletions .github/workflows/code_review_ms.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code Review MS
name: Code Review onboarding-ms

# Controls when the workflow will run
on:
Expand Down Expand Up @@ -28,6 +28,7 @@ jobs:
sparse-checkout: |
apps/onboarding-ms
libs/
test-coverage/
- name: Set up JDK 17
uses: actions/setup-java@v3
Expand All @@ -37,13 +38,10 @@ jobs:

- name: Build and analyze on Pull Requests
shell: bash
run: mvn --projects :onboarding-ms --also-make verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
run: mvn --projects :test-coverage --also-make verify -Ponboarding-ms,report,coverage
-Dsonar.organization=pagopa
-Dsonar.projectKey=pagopa_selfcare-onboarding
-Dsonar.coverage.jacoco.xmlReportPaths=./target/jacoco-report/jacoco.xml
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.token=${{ secrets.SONAR_TOKEN }}
-Dsonar.coverage.exclusions='**/exception/**, **/response/**, **/request/**, **/entity/**, **/utils/**, **/*Constant*, **/*Config.java, **/src/test/**'
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
-Dsonar.pullrequest.branch=${{ github.head_ref }}
-Dsonar.pullrequest.base=${{ github.base_ref }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ override.tf.json
# example: *tfplan*

**/.tfsec/*
pagopa_selfcare-onboarding
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This repo structure and build monorepo with Apache Maven for selfcare onboarding domain.

Applications under apps/ depend on shared code under libs/.
Applications under apps/ depend on shared code under libs/. test-coverage/ is used to assess the test coverage of the entire project.


```
Expand All @@ -12,7 +12,11 @@ Applications under apps/ depend on shared code under libs/.
│   ├── onboarding-functions
│   └── onboarding-ms
└── libs
   ├── onboarding-sdk
   ├── onboarding-sdk-pom
   ├── onboarding-sdk-common
   ├── onboarding-sdk-azure-storage
   ├── onboarding-sdk-product
└── test-coverage
```

Look at single README module for more information.
Expand All @@ -36,11 +40,11 @@ and usage of a couple of lesser known command line switches.
| Action | in working directory | with Maven |
|:---------------------------------------------------------------------------------------------------|:----------------------:|:-----------------------------------------------------------------------------------|
| Build the world | `.` | `mvn clean package -DskipTests` |
| Run `onboarding-ms` | `.` | `java -jar apps/onboarding-ms/target/onboarding-ms-0.0.1-SNAPSHOT.jar` |
| Run `onboarding-ms` | `.` | `java -jar apps/onboarding-ms/target/onboarding-ms-1.0.0-SNAPSHOT.jar` |
| Build and test the world | `.` | `mvn clean package` |
| Build the world | `./apps/onboarding-ms` | `mvn --file ../.. clean package -DskipTests` |
| Build `onboarding-ms` and its dependencies | `.` | `mvn --projects :onboarding-ms --also-make clean package -DskipTests` |
| Build `onboarding-ms` and its dependencies | `./apps/onboarding-ms` | `mvn --file ../.. --projects :onboarding-ms --also-make clean package -DskipTests` |
| Build `onboarding-sdk` and its dependents (aka. reverse dependencies or *rdeps* in Bazel parlance) | `.` | `mvn --projects :onboarding-sdk --also-make-dependents clean package -DskipTests` |
| Build `onboarding-sdk` and its dependents (aka. reverse dependencies or *rdeps* in Bazel parlance) | `.` | `mvn --projects :onboarding-sdk-pom --also-make-dependents clean package -DskipTests` |
| Print dependencies of `onboarding-sdk` | `./apps/onboarding-ms` | `mvn dependency:list` |

5 changes: 1 addition & 4 deletions apps/onboarding-ms/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ WORKDIR /src
COPY --link ./pom.xml .

WORKDIR /src/libs
COPY --link ./libs/pom.xml .

WORKDIR /src/libs/onboarding-sdk
COPY ./libs/onboarding-sdk/ .
COPY --link ./libs/ .

WORKDIR /src/apps
COPY --link ./apps/pom.xml .
Expand Down
3 changes: 2 additions & 1 deletion apps/onboarding-ms/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ onboarding-ms.blob-storage.filepath-product = products.json
onboarding-ms.blob-storage.connection-string-product = ${BLOB-STORAGE-PRODUCT-CONNECTION-STRING:UseDevelopmentStorage=true;}

## Jacoco
quarkus.jacoco.includes=it/pagopa/selfcare/controller/*,it/pagopa/selfcare/service/**,it/pagopa/selfcare/repository/**
quarkus.jacoco.includes=it/pagopa/selfcare/onboarding/controller/*,it/pagopa/selfcare/onboarding/service/**,it/pagopa/selfcare/onboarding/repository/**
quarkus.jacoco.data-file=target/jacoco.exec
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk</artifactId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.1.0</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>

<artifactId>onboarding-sdk-azure-storage</artifactId>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk</artifactId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.1.0</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>
<artifactId>onboarding-sdk-common</artifactId>
<name>onboarding-sdk-common</name>
Expand Down
File renamed without changes.
64 changes: 64 additions & 0 deletions libs/onboarding-sdk-pom/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-libs</artifactId>
<version>0.0.1</version>
</parent>

<artifactId>onboarding-sdk-pom</artifactId>
<packaging>pom</packaging>
<name>onboarding-sdk-pom</name>
<version>0.1.0</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<distributionManagement>
<repository>
<id>selfcare-github</id>
<name>Selfcare Onboarding SDK</name>
<url>https://maven.pkg.github.com/pagopa/selfcare-onboarding</url>
</repository>
</distributionManagement>

<modules>
<module>../onboarding-sdk-azure-storage</module>
<module>../onboarding-sdk-common</module>
<module>../onboarding-sdk-product</module>
</modules>


<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>true</append>
</configuration>
</execution>

<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>

</project>
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk</artifactId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.1.0</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>
<artifactId>onboarding-sdk-product</artifactId>
<name>onboarding-sdk-product</name>
Expand All @@ -26,7 +27,7 @@
<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-common</artifactId>
<version>${parent.version}</version>
<version>${project.version}</version>
</dependency>

<dependency>
Expand Down
28 changes: 0 additions & 28 deletions libs/onboarding-sdk/pom.xml

This file was deleted.

26 changes: 25 additions & 1 deletion libs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,31 @@
<packaging>pom</packaging>

<modules>
<module>onboarding-sdk</module>
<module>onboarding-sdk-pom</module>
</modules>


<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.10.0.2594</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
</plugin>
</plugins>
</pluginManagement>

</build>

</project>
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<modules>
<module>apps</module>
<module>libs</module>
<module>test-coverage</module>
</modules>

<repositories>
Expand Down
Loading

0 comments on commit 40c43d7

Please sign in to comment.