From d68fc210e8f0bf6349831bbe346c5c054dc5855a Mon Sep 17 00:00:00 2001 From: bmunguli Date: Wed, 21 Feb 2024 15:58:05 +0100 Subject: [PATCH 01/16] ci: add ci analysis for sonar cloud --- .github/workflows/build-snapshot.yml | 16 +++++++++++++- pom.xml | 32 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml index fa9ef42d..2cecd0af 100644 --- a/.github/workflows/build-snapshot.yml +++ b/.github/workflows/build-snapshot.yml @@ -39,13 +39,27 @@ jobs: packages: write steps: - uses: actions/checkout@v3 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: java-version: '17' distribution: 'adopt' cache: maven + - name: Cache SonarCloud packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Build and Deploy with Maven run: mvn clean -X install env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: SonarCloud Code Analysis + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -B verify --batch-mode sonar:sonar \ No newline at end of file diff --git a/pom.xml b/pom.xml index 43e08140..4fe2dca3 100644 --- a/pom.xml +++ b/pom.xml @@ -98,9 +98,20 @@ 3.24.2 5.9.3 + 0.8.11 + + + 3.10.0.2594 + 3.8.1 + + + + eclipse-tractusx + eclipse-tractusx_sldt-digital-twin-registry + https://sonarcloud.io @@ -405,6 +416,27 @@ + + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + + + + prepare-agent + + + + report + test + + report + + + + + From b692ef4664ff440532e83fcd4f1732472db3cab9 Mon Sep 17 00:00:00 2001 From: bmunguli Date: Wed, 21 Feb 2024 16:04:13 +0100 Subject: [PATCH 02/16] refactor: add spaces between steps in workflow --- .github/workflows/build-snapshot.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml index 2cecd0af..78937e95 100644 --- a/.github/workflows/build-snapshot.yml +++ b/.github/workflows/build-snapshot.yml @@ -46,6 +46,7 @@ jobs: java-version: '17' distribution: 'adopt' cache: maven + - name: Cache SonarCloud packages uses: actions/cache@v4 with: From bd79bf0a189ace78c6117df1c890fab53d4bb948 Mon Sep 17 00:00:00 2001 From: bmunguli Date: Mon, 4 Mar 2024 16:46:20 +0100 Subject: [PATCH 03/16] chore: remove extra empty lines --- pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4fe2dca3..35b935f1 100644 --- a/pom.xml +++ b/pom.xml @@ -103,11 +103,9 @@ 3.10.0.2594 - 3.8.1 - eclipse-tractusx eclipse-tractusx_sldt-digital-twin-registry From 28e3a45d0cf6c4e048de056efb0e74ebee96e9bb Mon Sep 17 00:00:00 2001 From: bmunguli Date: Tue, 5 Mar 2024 17:26:50 +0100 Subject: [PATCH 04/16] chore: add sonar project name --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 35b935f1..6e0f5e68 100644 --- a/pom.xml +++ b/pom.xml @@ -108,6 +108,7 @@ eclipse-tractusx + sldt-digital-twin-registry eclipse-tractusx_sldt-digital-twin-registry https://sonarcloud.io From 1b45bda6678d78091c345158ed6beee4a4339540 Mon Sep 17 00:00:00 2001 From: bmunguli Date: Tue, 5 Mar 2024 17:49:00 +0100 Subject: [PATCH 05/16] fix: pass project key as part of the task instead in pom.xml - passing project key in pom.xml seems to cause --- .github/workflows/build-snapshot.yml | 2 +- pom.xml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml index 78937e95..27d33e1c 100644 --- a/.github/workflows/build-snapshot.yml +++ b/.github/workflows/build-snapshot.yml @@ -63,4 +63,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B verify --batch-mode sonar:sonar \ No newline at end of file + run: mvn -B --batch-mode sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6e0f5e68..6c8de481 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,6 @@ eclipse-tractusx sldt-digital-twin-registry - eclipse-tractusx_sldt-digital-twin-registry https://sonarcloud.io From a08c700969395b5c8a5957442998e80bd362df05 Mon Sep 17 00:00:00 2001 From: bmunguli Date: Fri, 8 Mar 2024 09:20:10 +0100 Subject: [PATCH 06/16] fix: add sonar properties as part of the cli task --- .github/workflows/build-snapshot.yml | 4 +++- pom.xml | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml index 27d33e1c..3243e673 100644 --- a/.github/workflows/build-snapshot.yml +++ b/.github/workflows/build-snapshot.yml @@ -39,6 +39,8 @@ jobs: packages: write steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 # required for sonar analysis - name: Set up JDK 17 uses: actions/setup-java@v3 @@ -63,4 +65,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B --batch-mode sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry \ No newline at end of file + run: mvn -B --batch-mode sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry -Dsonar.organization=eclipse-tractusx \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6c8de481..a660b56a 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,9 @@ eclipse-tractusx + eclipse-tractusx_sldt-digital-twin-registry sldt-digital-twin-registry + ${project.groupId}:${project.artifactId} https://sonarcloud.io From 0afbbf0bf2e3841b3ce444d40269fa519b9298cc Mon Sep 17 00:00:00 2001 From: bmunguli Date: Fri, 8 Mar 2024 09:22:48 +0100 Subject: [PATCH 07/16] fix: remove redudant argument --- .github/workflows/build-snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml index 3243e673..b40b114a 100644 --- a/.github/workflows/build-snapshot.yml +++ b/.github/workflows/build-snapshot.yml @@ -65,4 +65,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B --batch-mode sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry -Dsonar.organization=eclipse-tractusx \ No newline at end of file + run: mvn --batch-mode sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry -Dsonar.organization=eclipse-tractusx \ No newline at end of file From 01a8ca8a9dfdfb6243524a71ad0840fd7bbb2ffd Mon Sep 17 00:00:00 2001 From: bmunguli Date: Fri, 8 Mar 2024 10:18:04 +0100 Subject: [PATCH 08/16] chore: add debugging option to help identify the sonar task --- .github/workflows/build-snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml index b40b114a..5a544abe 100644 --- a/.github/workflows/build-snapshot.yml +++ b/.github/workflows/build-snapshot.yml @@ -65,4 +65,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn --batch-mode sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry -Dsonar.organization=eclipse-tractusx \ No newline at end of file + run: mvn --batch-mode -X sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry -Dsonar.organization=eclipse-tractusx \ No newline at end of file From 9e3ba02dc824f8269d0410189d530750b0a4f94f Mon Sep 17 00:00:00 2001 From: bmunguli Date: Mon, 11 Mar 2024 10:50:03 +0100 Subject: [PATCH 09/16] chore: access sonar organization and key from repository varuables --- .github/workflows/build-snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml index 5a544abe..5ff9f7d8 100644 --- a/.github/workflows/build-snapshot.yml +++ b/.github/workflows/build-snapshot.yml @@ -65,4 +65,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn --batch-mode -X sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry -Dsonar.organization=eclipse-tractusx \ No newline at end of file + run: mvn --batch-mode -X sonar:sonar -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} \ No newline at end of file From 60aa4582a4a27fd1dbdc5b54779f36a67f0c5f2f Mon Sep 17 00:00:00 2001 From: bmunguli Date: Tue, 12 Mar 2024 09:47:55 +0100 Subject: [PATCH 10/16] chore: remove module key configuration - Align with traceablitiy foss --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index a660b56a..c3728137 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,6 @@ eclipse-tractusx eclipse-tractusx_sldt-digital-twin-registry sldt-digital-twin-registry - ${project.groupId}:${project.artifactId} https://sonarcloud.io From 7c7e7fef596206f9847696789b2ba05479e8597e Mon Sep 17 00:00:00 2001 From: bmunguli Date: Tue, 12 Mar 2024 11:37:52 +0100 Subject: [PATCH 11/16] chore: bring back moduleKey configuration needed by multimodule projects --- pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c3728137..4cbe4ce3 100644 --- a/pom.xml +++ b/pom.xml @@ -108,9 +108,11 @@ eclipse-tractusx + https://sonarcloud.io eclipse-tractusx_sldt-digital-twin-registry + ${project.groupId}:${project.artifactId} sldt-digital-twin-registry - https://sonarcloud.io + 17 From c3ae7864018d805780f1eb5625f93f2c5080815e Mon Sep 17 00:00:00 2001 From: bmunguli Date: Tue, 12 Mar 2024 14:40:41 +0100 Subject: [PATCH 12/16] ci: revert back to hardcoded values - it seems accessing the values from variables does not work --- .github/workflows/build-snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml index 5ff9f7d8..b40b114a 100644 --- a/.github/workflows/build-snapshot.yml +++ b/.github/workflows/build-snapshot.yml @@ -65,4 +65,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn --batch-mode -X sonar:sonar -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} \ No newline at end of file + run: mvn --batch-mode sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry -Dsonar.organization=eclipse-tractusx \ No newline at end of file From aaabb26685c2885163f419a28fe3e363600187e1 Mon Sep 17 00:00:00 2001 From: bmunguli Date: Thu, 28 Mar 2024 11:32:57 +0100 Subject: [PATCH 13/16] fix: remove sonar cloud steps from build workflow - sonar can not run on prs from forks --- .github/workflows/build-snapshot.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml index b40b114a..6da712d0 100644 --- a/.github/workflows/build-snapshot.yml +++ b/.github/workflows/build-snapshot.yml @@ -39,30 +39,13 @@ jobs: packages: write steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 # required for sonar analysis - - name: Set up JDK 17 uses: actions/setup-java@v3 with: java-version: '17' distribution: 'adopt' cache: maven - - - name: Cache SonarCloud packages - uses: actions/cache@v4 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Build and Deploy with Maven run: mvn clean -X install env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: SonarCloud Code Analysis - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn --batch-mode sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry -Dsonar.organization=eclipse-tractusx \ No newline at end of file From aa13265dc9d7c829630748b714eeec533be0ac10 Mon Sep 17 00:00:00 2001 From: bmunguli Date: Thu, 28 Mar 2024 11:33:43 +0100 Subject: [PATCH 14/16] ci: add dedicated workflow for running sonar on schedule and main branch --- .github/workflows/sonar-scan.yaml | 59 +++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/sonar-scan.yaml diff --git a/.github/workflows/sonar-scan.yaml b/.github/workflows/sonar-scan.yaml new file mode 100644 index 00000000..78e02034 --- /dev/null +++ b/.github/workflows/sonar-scan.yaml @@ -0,0 +1,59 @@ +################################################################################ +# Copyright (c) 2024 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################ + +name: "Sonar Analysis" +on: + workflow_dispatch: + push: + branches: + - main + schedule: + - cron: "0 0 * * *" + +env: + JAVA_VERSION: 17 + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'adopt' + cache: maven + + - name: Cache SonarCloud packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn --batch-mode verify sonar:sonar -Dsonar.projectKey=eclipse-tractusx_sldt-digital-twin-registry -Dsonar.organization=eclipse-tractusx \ No newline at end of file From 1490f774c8a460c664d8fffb9491bce822cb0cca Mon Sep 17 00:00:00 2001 From: bmunguli Date: Thu, 28 Mar 2024 12:13:16 +0100 Subject: [PATCH 15/16] chore: clean up unused variable. --- .github/workflows/sonar-scan.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/sonar-scan.yaml b/.github/workflows/sonar-scan.yaml index 78e02034..d5bf6c2b 100644 --- a/.github/workflows/sonar-scan.yaml +++ b/.github/workflows/sonar-scan.yaml @@ -26,9 +26,6 @@ on: schedule: - cron: "0 0 * * *" -env: - JAVA_VERSION: 17 - jobs: build: name: Build From 090c1ff6e59b2078fb31fd1f5bc96407e97bb88f Mon Sep 17 00:00:00 2001 From: bmunguli Date: Thu, 28 Mar 2024 12:15:04 +0100 Subject: [PATCH 16/16] chore: remove empty line --- .github/workflows/build-snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml index 6da712d0..fa9ef42d 100644 --- a/.github/workflows/build-snapshot.yml +++ b/.github/workflows/build-snapshot.yml @@ -48,4 +48,4 @@ jobs: - name: Build and Deploy with Maven run: mvn clean -X install env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file