Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 38 additions & 19 deletions .github/workflows/code-maven_java-PR_verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
- 'code/**'
- '.github/workflows/code*'

env:
MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"

jobs:
unit-tests:
name: Code / Verify
Expand All @@ -26,6 +29,24 @@ jobs:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Maven Cache
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Setup asdf Cache
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.asdf/data
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-

- name: Save tool-versions content
run: |
{
Expand All @@ -34,27 +55,32 @@ jobs:
echo "EOF"
} >> "$GITHUB_ENV"

- name: Setup IVM environment
- name: Maven / Setup IVM environment
uses: asdf-vm/actions/install@v3
with:
tool_versions: ${{ ENV.TOOL_VERSIONS }}
tool_versions: ${{ env.TOOL_VERSIONS }}

- name: Setup Java environment vars
working-directory: code
run: |
JAVA_HOME="$(asdf where java)"
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "JAVA_CACERTS_PATH=$JAVA_HOME/lib/security" >> $GITHUB_ENV
echo "JAVA_CACERTS=$JAVA_HOME/lib/security/cacerts" >> $GITHUB_ENV

- name: Store project version
if: ${{ vars.IS_INDITEXTECH_REPO == 'true' }}
id: version
run: |
echo "app-version=$(yq -oy '.project.version' code/pom.xml)" >> "$GITHUB_OUTPUT"
echo "app-name=$(yq -oy '.project.artifactId' code/pom.xml)" >> "$GITHUB_OUTPUT"

- name: Maven / Verify artifact with coverage
if: ${{ !(contains(github.event.pull_request.labels.*.name, 'autopublish/snapshot-binaries')) }}
working-directory: code
run: |
mvn -B clean verify -DskipITs -DfailIfNoTests=false -Dmaven.test.failure.ignore=false
mvn -B clean verify -Djacoco.skip=false -DskipITs -DfailIfNoTests=false -Dmaven.test.failure.ignore=false

- name: Prepare committer information and set GPG key
if: ${{ vars.IS_INDITEXTECH_REPO == 'true' }}
if: ${{ vars.IS_INDITEXTECH_REPO != 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCM_COMMITTER_PGP_KEY: ${{ secrets.CI_GPG_SECRET_KEY }}
Expand All @@ -80,7 +106,7 @@ jobs:
mvn -B build-helper:parse-version versions:set \
-DnewVersion="\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion}+PR${{ github.event.pull_request.number }}-SNAPSHOT"

mvn -B clean install gpg:sign org.sonatype.central:central-publishing-maven-plugin:publish -DskipITs -DfailIfNoTests=false -Dmaven.test.failure.ignore=false -Dbuild.type=snapshot --settings=.mvn/settings.xml
mvn -B clean install gpg:sign org.sonatype.central:central-publishing-maven-plugin:publish -Djacoco.skip=false -DskipITs -DfailIfNoTests=false -Dmaven.test.failure.ignore=false -Dbuild.type=snapshot --settings=.mvn/settings.xml

VERSION=${{ steps.version.outputs.app-version }}
VERSION=${VERSION/-SNAPSHOT}+PR${{ github.event.pull_request.number }}-SNAPSHOT
Expand All @@ -103,14 +129,7 @@ jobs:
create_check: false
check_name: "Code / Verify"

- name: Store project version
if: ${{ vars.IS_INDITEXTECH_REPO == 'true' }}
id: version
run: |
echo "app-version=$(yq -oy '.project.version' code/pom.xml)" >> "$GITHUB_OUTPUT"
echo "app-name=$(yq -oy '.project.artifactId' code/pom.xml)" >> "$GITHUB_OUTPUT"

- name: Setup IVM environment
- name: SonarCloud / Setup asdf tools
if: ${{ vars.IS_INDITEXTECH_REPO == 'true' }}
uses: asdf-vm/actions/install@v3
with:
Expand All @@ -119,7 +138,7 @@ jobs:
nodejs 20.10.0
maven 3.9.4

- name: Set asdf versions for SonarCloud
- name: SonarCloud / Set asdf versions
if: ${{ vars.IS_INDITEXTECH_REPO == 'true' }}
working-directory: code
run: |
Expand All @@ -133,8 +152,6 @@ jobs:
run: |
JAVA_HOME="$(asdf where java)"
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "JAVA_CACERTS_PATH=$JAVA_HOME/lib/security" >> $GITHUB_ENV
echo "JAVA_CACERTS=$JAVA_HOME/lib/security/cacerts" >> $GITHUB_ENV

- name: SonarCloud / Run Maven Sonar goal
if: ${{ vars.IS_INDITEXTECH_REPO == 'true' }}
Expand All @@ -144,6 +161,7 @@ jobs:
SONAR_SCANNER_OPTS: ''
working-directory: code
run: |
JACOCO_REPORT_PATH="$GITHUB_WORKSPACE/code/jacoco-report-aggregate/target/site/jacoco-aggregate/jacoco.xml"
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar \
-Dsonar.projectKey=PabloCollazoCollarte_"${{ steps.version.outputs.app-name }}" \
-Dsonar.projectName="${{ steps.version.outputs.app-name }}" \
Expand All @@ -159,4 +177,5 @@ jobs:
-Dsonar.qualitygate.timeout=300 \
-Dsonar.pullrequest.provider=GitHub \
-Dsonar.pullrequest.github.repository="${{ github.repository }}" \
-Dsonar.pullrequest.github.summary_comment=true
-Dsonar.pullrequest.github.summary_comment=true \
-Dsonar.coverage.jacoco.xmlReportPaths="$JACOCO_REPORT_PATH"
55 changes: 38 additions & 17 deletions .github/workflows/code-maven_java-sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ on:
types:
- published

env:
MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"

jobs:
unit-tests:
name: SonarCloud / Unit Tests
Expand All @@ -31,7 +34,25 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0


- name: Setup Maven Cache
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Setup asdf Cache
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.asdf/data
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-

- name: Save tool-versions content
run: |
{
Expand All @@ -40,46 +61,44 @@ jobs:
echo "EOF"
} >> "$GITHUB_ENV"

- name: Setup IVM environment
- name: Maven / Setup asdf tools
uses: asdf-vm/actions/install@v3
with:
tool_versions: ${{ ENV.TOOL_VERSIONS }}
tool_versions: ${{ env.TOOL_VERSIONS }}

- name: Setup Java environment vars
working-directory: code
run: |
JAVA_HOME="$(asdf where java)"
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "JAVA_CACERTS_PATH=$JAVA_HOME/lib/security" >> $GITHUB_ENV
echo "JAVA_CACERTS=$JAVA_HOME/lib/security/cacerts" >> $GITHUB_ENV

- name: Run unit tests with release event
- name: Maven / Run unit tests with release event
if: github.event_name == 'release'
working-directory: code
run: |
mvn -B clean verify -DskipEnforceSnapshots -DskipITs -DfailIfNoTests=false -Dmaven.test.failure.ignore=false
mvn -B clean verify -Djacoco.skip=false -DskipEnforceSnapshots -DskipITs -DfailIfNoTests=false -Dmaven.test.failure.ignore=false

- name: Run unit tests
- name: Maven / Run unit tests
if: github.event_name != 'release'
working-directory: code
run: |
mvn -B clean verify -DskipITs -DfailIfNoTests=false -Dmaven.test.failure.ignore=false
mvn -B clean verify -Djacoco.skip=false -DskipITs -DfailIfNoTests=false -Dmaven.test.failure.ignore=false

- name: Store project version
id: version
run: |
echo "app-version=$(yq -oy '.project.version' code/pom.xml)" >> "$GITHUB_OUTPUT"
echo "app-name=$(yq -oy '.project.artifactId' code/pom.xml)" >> "$GITHUB_OUTPUT"

- name: Setup IVM environment
- name: SonarCloud / Setup asdf tools
uses: asdf-vm/actions/install@v3
with:
tool_versions: |
java temurin-17.0.8+7
nodejs 20.10.0
maven 3.9.4

- name: Set asdf versions for SonarCloud
- name: SonarCloud / Set asdf versions
working-directory: code
run: |
asdf local java temurin-17.0.8+7
Expand All @@ -91,8 +110,6 @@ jobs:
run: |
JAVA_HOME="$(asdf where java)"
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "JAVA_CACERTS_PATH=$JAVA_HOME/lib/security" >> $GITHUB_ENV
echo "JAVA_CACERTS=$JAVA_HOME/lib/security/cacerts" >> $GITHUB_ENV

- name: SonarCloud / Run Maven Sonar goal with release event
env:
Expand All @@ -101,14 +118,16 @@ jobs:
if: ${{ github.event_name == 'release' }}
working-directory: code
run: |
JACOCO_REPORT_PATH="$GITHUB_WORKSPACE/code/jacoco-report-aggregate/target/site/jacoco-aggregate/jacoco.xml"
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar \
-Dsonar.projectKey=InditexTech_"${{ steps.version.outputs.app-name }}" \
-Dsonar.projectKey=PabloCollazoCollarte_"${{ steps.version.outputs.app-name }}" \
-Dsonar.projectName="${{ steps.version.outputs.app-name }}" \
-Dsonar.projectVersion="${{ github.event.release.tag_name }}" \
-Dsonar.branch.name="release/${{ github.event.release.tag_name }}" \
-Dsonar.host.url="https://sonarcloud.io/" \
-Dsonar.organization=inditextech \
-Dsonar.token="${LOGIN}"
-Dsonar.organization=pablocollazocollarte \
-Dsonar.token="${LOGIN}" \
-Dsonar.coverage.jacoco.xmlReportPaths="$JACOCO_REPORT_PATH"

- name: SonarCloud / Run Maven Sonar goal
env:
Expand All @@ -117,11 +136,13 @@ jobs:
if: ${{ github.event_name != 'release' }}
working-directory: code
run: |
JACOCO_REPORT_PATH="$GITHUB_WORKSPACE/code/jacoco-report-aggregate/target/site/jacoco-aggregate/jacoco.xml"
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar \
-Dsonar.projectKey=PabloCollazoCollarte_"${{ steps.version.outputs.app-name }}" \
-Dsonar.projectName="${{ steps.version.outputs.app-name }}" \
-Dsonar.projectVersion="${{ steps.version.outputs.app-version }}" \
-Dsonar.branch.name="${{ github.base_ref || github.ref_name }}" \
-Dsonar.host.url="https://sonarcloud.io/" \
-Dsonar.organization=pablocollazocollarte \
-Dsonar.token="${LOGIN}"
-Dsonar.token="${LOGIN}" \
-Dsonar.coverage.jacoco.xmlReportPaths="$JACOCO_REPORT_PATH"
87 changes: 87 additions & 0 deletions code/jacoco-report-aggregate/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.sivalabs</groupId>
<artifactId>spring-boot-microservices-series</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<artifactId>jacoco-report-aggregate</artifactId>
<packaging>pom</packaging>

<name>${project.groupId}:${project.artifactId}</name>
<description>InditexTech Karate Tools - Jacoco Report Aggregate</description>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>config-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>oauth2-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>service-registry</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>hystrix-dashboard</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>inventory-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>order-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>shoppingcart-ui</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>zipkin-server</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>quality-metric-jacoco-report-aggregate</id>
<phase>prepare-package</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
<configuration>
<title>${project.parent.artifactId}</title>
<footer>Code Coverage Report for ${project.parent.artifactId} ${project.version}</footer>
<includes>
<include>**/*.class</include>
</includes>
<outputDirectory>${jacoco.outputDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading