Skip to content

Commit

Permalink
feat: Added event bus integration for sending payment transaction sta…
Browse files Browse the repository at this point in the history
…tus changes to mil-preset (#11)

Co-authored-by: fabrizio.guerrini <[email protected]>
Co-authored-by: antoniotarricone <[email protected]>
  • Loading branch information
3 people authored Jun 13, 2023
1 parent d4cba8c commit 47285aa
Show file tree
Hide file tree
Showing 32 changed files with 1,501 additions and 323 deletions.
62 changes: 48 additions & 14 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ on:
jobs:
pr-validation:
runs-on: ubuntu-latest

steps:
- name: PR title validation
uses: amannn/action-semantic-pull-request@v5
uses: amannn/action-semantic-pull-request@c3cd5d1ea3580753008872425915e343e351ab54
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -34,25 +34,59 @@ jobs:
starts with an uppercase character.
wip: false

- name: Checkout the repository
uses: actions/checkout@v3
- name: Checkout the source code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
token: ${{ secrets.GIT_PAT }}
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
- name: Cache JDK
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: cache-jdk
with:
key: OpenJDK17U-jdk_x64_linux_hotspot_17.0.7_7.tar.gz
path: |
${{ runner.temp }}/jdk_setup.tar.gz
${{ runner.temp }}/jdk_setup.sha256
- name: Download JDK and verify its hash
if: steps.cache-jdk.outputs.cache-hit != 'true'
run: |
echo "e9458b38e97358850902c2936a1bb5f35f6cffc59da9fcd28c63eab8dbbfbc3b ${{ runner.temp }}/jdk_setup.tar.gz" >> ${{ runner.temp }}/jdk_setup.sha256
curl -L "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.7%2B7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.7_7.tar.gz" -o "${{ runner.temp }}/jdk_setup.tar.gz"
sha256sum --check --status "${{ runner.temp }}/jdk_setup.sha256"
- name: Setup JDK
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2
with:
java-version: '17'
distribution: 'temurin'
distribution: "jdkfile"
jdkFile: "${{ runner.temp }}/jdk_setup.tar.gz"
java-version: "17"
cache: maven

- name: Cache Maven
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: cache-maven
with:
key: apache-maven-3.9.2-bin.tar.gz
path: |
${{ runner.temp }}/maven_setup.tar.gz
${{ runner.temp }}/maven_setup.sha256
- name: Build dependencies with Maven
run: mvn clean validate -Pbootstrap
- name: Download Maven and verify its hash
if: steps.cache-maven.outputs.cache-hit != 'true'
run: |
echo "809ef3220c6d179195c06c324cb9a6d34d8ecba566c5cfd8eb83167bc034117d ${{ runner.temp }}/maven_setup.tar.gz" >> ${{ runner.temp }}/maven_setup.sha256
curl -L "https://dlcdn.apache.org/maven/maven-3/3.9.2/binaries/apache-maven-3.9.2-bin.tar.gz" -o "${{ runner.temp }}/maven_setup.tar.gz"
sha256sum --check --status "${{ runner.temp }}/maven_setup.sha256"
- name: Setup Maven
run: |
mkdir ${{ runner.temp }}/maven
tar -xvf ${{ runner.temp }}/maven_setup.tar.gz -C ${{ runner.temp }}/maven --strip-components=1
echo "<settings><servers><server><id>github</id><username>${{ secrets.GIT_USER }}</username><password>${{ secrets.GIT_PAT }}</password></server></servers></settings>" >> ${{ runner.temp }}/settings.xml
#- name: Execute unit-testing
# run: mvn clean test

- name: Execute unit-test + Calculate test coverage + SCA with Sonar
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn verify -Pvalidate --no-transfer-progress
run: ${{ runner.temp }}/maven/bin/mvn verify -Pvalidate -s ${{ runner.temp }}/settings.xml --no-transfer-progress
100 changes: 71 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# Checkout the source code.
#
- name: Checkout the source code
uses: actions/checkout@v3
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
token: ${{ secrets.GIT_PAT }}
fetch-depth: 0
Expand All @@ -31,7 +31,7 @@ jobs:
# Calculation of the new version (dry-run).
#
- name: Calculation of the new version (dry-run)
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@8e58d20d0f6c8773181f43eb74d6a05e3099571d
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -44,42 +44,88 @@ jobs:
dry_run: true

#
# Setup the JDK.
# Cache JDK.
#
- name: Setup the JDK
if: steps.semantic.outputs.new_release_published == 'true'
uses: actions/setup-java@v3
- name: Cache JDK
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: cache-jdk
with:
key: OpenJDK17U-jdk_x64_linux_hotspot_17.0.7_7.tar.gz
path: |
${{ runner.temp }}/jdk_setup.tar.gz
${{ runner.temp }}/jdk_setup.sha256
#
# Download JDK and verify its hash.
#
- name: Download JDK and verify its hash
if: steps.cache-jdk.outputs.cache-hit != 'true'
run: |
echo "e9458b38e97358850902c2936a1bb5f35f6cffc59da9fcd28c63eab8dbbfbc3b ${{ runner.temp }}/jdk_setup.tar.gz" >> ${{ runner.temp }}/jdk_setup.sha256
curl -L "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.7%2B7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.7_7.tar.gz" -o "${{ runner.temp }}/jdk_setup.tar.gz"
sha256sum --check --status "${{ runner.temp }}/jdk_setup.sha256"
#
# Setup JDK.
#
- name: Setup JDK
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2
with:
java-version: '17'
distribution: 'temurin'
distribution: "jdkfile"
jdkFile: "${{ runner.temp }}/jdk_setup.tar.gz"
java-version: "17"
cache: maven

#
# Cache Maven.
#
- name: Cache Maven
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: cache-maven
with:
key: apache-maven-3.9.2-bin.tar.gz
path: |
${{ runner.temp }}/maven_setup.tar.gz
${{ runner.temp }}/maven_setup.sha256
#
# Download Maven and verify its hash.
#
- name: Download Maven and verify its hash
if: steps.cache-maven.outputs.cache-hit != 'true'
run: |
echo "809ef3220c6d179195c06c324cb9a6d34d8ecba566c5cfd8eb83167bc034117d ${{ runner.temp }}/maven_setup.tar.gz" >> ${{ runner.temp }}/maven_setup.sha256
curl -L "https://dlcdn.apache.org/maven/maven-3/3.9.2/binaries/apache-maven-3.9.2-bin.tar.gz" -o "${{ runner.temp }}/maven_setup.tar.gz"
sha256sum --check --status "${{ runner.temp }}/maven_setup.sha256"
#
# Setup Maven.
#
- name: Setup Maven
run: |
mkdir ${{ runner.temp }}/maven
tar -xvf ${{ runner.temp }}/maven_setup.tar.gz -C ${{ runner.temp }}/maven --strip-components=1
echo "<settings><servers><server><id>github</id><username>${{ secrets.GIT_USER }}</username><password>${{ secrets.GIT_PAT }}</password></server></servers></settings>" >> ${{ runner.temp }}/settings.xml
#
# Update of pom.xml with the new version + Git add + commit + push of the updated pom.xml.
#
- name: Update of pom.xml with the new version + Git add + commit + push of the updated pom.xml
if: steps.semantic.outputs.new_release_published == 'true'
run: |
mvn versions:set -DnewVersion=${{ steps.semantic.outputs.new_release_version }} --no-transfer-progress
${{ runner.temp }}/maven/bin/mvn versions:set -DnewVersion=${{ steps.semantic.outputs.new_release_version }} -s ${{ runner.temp }}/settings.xml --no-transfer-progress
git config user.name "GitHub Workflow"
git config user.email "<>"
git add pom.xml
git commit -m "pom.xml updated with new version ${{ steps.semantic.outputs.new_release_version }}"
git push origin main
#
# Sleep for 60s to avoid this issue: https://github.com/semantic-release/semantic-release/issues/2204
#
- name: Sleep for 60s to avoid the issue 2204
if: steps.semantic.outputs.new_release_published == 'true'
run: sleep 60s

#
# Calculation of the new version (again) with tagging + releasing + etc.
#
- name: Calculation of the new version (again) with tagging + releasing + etc
if: steps.semantic.outputs.new_release_published == 'true'
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@8e58d20d0f6c8773181f43eb74d6a05e3099571d
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -91,16 +137,15 @@ jobs:
dry_run: false

#
# Build dependencies + Execute unit-test + Calculate test coverage + SCA with Sonar + Build native image + Docker build + Docker login + Docker push
# Execute unit-test + Calculate test coverage + SCA with Sonar + Build native image + Docker build + Docker login + Docker push
#
- name: Build dependencies + Execute unit-test + Calculate test coverage + SCA with Sonar + Build native image + Docker build + Docker login + Docker push
- name: Execute unit-test + Calculate test coverage + SCA with Sonar + Build native image + Docker build + Docker login + Docker push
if: steps.semantic.outputs.new_release_published == 'true'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn clean validate -Pbootstrap --no-transfer-progress
mvn verify -Pvalidate --no-transfer-progress
mvn clean package -Pnative -Dmaven.test.skip=true --no-transfer-progress
${{ runner.temp }}/maven/bin/mvn verify -Pvalidate -s ${{ runner.temp }}/settings.xml --no-transfer-progress
${{ runner.temp }}/maven/bin/mvn clean package -Pnative -Dmaven.test.skip=true -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image@sha256:05baf3fd2173f6f25ad35216b6b066c35fbfb97f06daba75efb5b22bc0a85b9c -s ${{ runner.temp }}/settings.xml --no-transfer-progress
docker build -f src/main/docker/Dockerfile.native-micro -t ghcr.io/${{ github.repository }}:latest -t ghcr.io/${{ github.repository }}:${{ steps.semantic.outputs.new_release_version }} .
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker push -a ghcr.io/${{ github.repository }}
Expand All @@ -116,27 +161,24 @@ jobs:

permissions:
id-token: write

steps:
#
# Login to Azure.
#
- name: Login to Azure
uses: azure/login@v1
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

#
# Update Container App
#
- name: Update Container App
uses: azure/CLI@v1
uses: azure/CLI@fa0f960f00db49b95fdb54328a767aee31e80105
with:
inlineScript: |
az config set extension.use_dynamic_install=yes_without_prompt
az containerapp update -n ${{ secrets.AZURE_CONTAINER_APP_NAME }} -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --image ghcr.io/${{ github.repository }}:${{ needs.release.outputs.new_release_version }}
# TODO: Run Integration Test
# TODO: Run Performance Test
77 changes: 30 additions & 47 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<surefire-plugin.version>3.0.0-M9</surefire-plugin.version>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<sonar-plugin.version>3.9.1.2184</sonar-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.0.2.Final</quarkus.platform.version>
<quarkus.platform.version>3.1.1.Final</quarkus.platform.version>
<skipITs>true</skipITs>
<common.version>2.0.1</common.version>
<common.version>2.0.2</common.version>

<sonar.host.url>https://sonarcloud.io:443/</sonar.host.url>
<sonar.organization>pagopa</sonar.organization>
Expand All @@ -41,7 +41,7 @@
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-bom</artifactId>
<version>2.0.2</version>
<version>2.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -111,6 +111,15 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging-kafka</artifactId>
</dependency>
<dependency>
<groupId>it.pagopa.swclient.mil</groupId>
<artifactId>common</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand All @@ -126,11 +135,6 @@
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>it.pagopa.swclient.mil</groupId>
<artifactId>common</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jacoco</artifactId>
Expand All @@ -157,13 +161,29 @@
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-reactive-messaging-in-memory</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>redpanda</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/pagopa/mil-common</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
<executions>
<execution>
<id>generate-sources</id>
Expand Down Expand Up @@ -246,43 +266,6 @@
</plugins>
</build>
<profiles>
<!-- To clone and install dependencies: -->
<!-- mvn clean validate -Pbootstrap -Dmaven.home=<path to Maven home> -->
<profile>
<id>bootstrap</id>
<activation>
<property>
<name>bootstrap</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>2.0.0-M3</version>
<configuration>
<mavenHome>${maven.home}</mavenHome>
<goals>install</goals>
</configuration>
<executions>
<execution>
<id>clone_and_install_mil-common</id>
<phase>validate</phase>
<configuration>
<connectionUrl>scm:git:https://github.com/pagopa/mil-common.git</connectionUrl>
<scmVersionType>tag</scmVersionType>
<scmVersion>${common.version}</scmVersion>
</configuration>
<goals>
<goal>bootstrap</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>native</id>
<activation>
Expand Down
Loading

0 comments on commit 47285aa

Please sign in to comment.