Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ops: code review workflow and test coverage #37

Merged
merged 32 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9695e03
replace product api with sdk
manuraf Nov 3, 2023
1df1481
introduce ONBOARDING_ORCHESTRATION_ENABLED
manuraf Nov 3, 2023
a240fa6
rename env variable for secret convention
manuraf Nov 3, 2023
bcbad95
fix code review workflow
manuraf Nov 3, 2023
38d5c0e
fix code review functions
manuraf Nov 3, 2023
39e67f9
add permissions packages read
manuraf Nov 3, 2023
a3a7538
permissions packages read
manuraf Nov 3, 2023
08f9718
add id-token write
manuraf Nov 3, 2023
5952160
fix secrets
manuraf Nov 3, 2023
553a3e5
remove secrets
manuraf Nov 3, 2023
5886c79
fix unit test
manuraf Nov 4, 2023
4b4834a
remove maven cache
manuraf Nov 4, 2023
11371b8
add maven-settings-action
manuraf Nov 4, 2023
affe9dd
maven-settings-action v2.8.0
manuraf Nov 4, 2023
01bb3f4
selfcare-github as id server
manuraf Nov 4, 2023
cac9589
Merge branch 'develop' into refactor/replace-product-api
manuraf Nov 7, 2023
4e8535d
add sparse-checkout for monorepo
manuraf Nov 7, 2023
a70b72e
add maven settings for release sdk
manuraf Nov 7, 2023
14899a3
test ls workflow
manuraf Nov 7, 2023
ffdb308
fix launch verify
manuraf Nov 7, 2023
16e53f6
add secret connection string
manuraf Nov 8, 2023
b216f6b
refactor onboarding sdk
manuraf Nov 8, 2023
f9c949b
fix submodule onboarding sdk
manuraf Nov 8, 2023
4f0c9bf
set jacoco.exec for onboarding-ms
manuraf Nov 8, 2023
b7b29db
added test coverage module for aggregating reports
manuraf Nov 9, 2023
8a4837f
code review functions and apps
manuraf Nov 9, 2023
ddad288
checkout entire project for libs
manuraf Nov 9, 2023
8dd3c25
readme
manuraf Nov 9, 2023
282a903
readme
manuraf Nov 9, 2023
06ceea9
fix name
manuraf Nov 9, 2023
2d5b6cb
Merge branch 'develop' into code-review-ms
manuraf Nov 9, 2023
b1e484b
fix dockerfile onboarding-ms
manuraf Nov 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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>
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
Loading