From 8212555203ca04fedde1381facd35bd0f4aad8ee Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Wed, 14 Oct 2020 22:39:58 -0400 Subject: [PATCH 1/4] Add sonar coverage reporting to master build --- .github/workflows/maven.yml | 7 +++++- pom.xml | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index fcf45e539..1b74e039e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -12,6 +12,7 @@ on: env: OSS_USERNAME: ${{ secrets.OSS_USERNAME }} OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} jobs: build: @@ -40,7 +41,11 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - name: Run tests - run: ./mvnw -V -B -ntp -ff verify + run: ./mvnw -V -B -ntp -ff verify jacoco:report + - name: Static Analysis (Sonar) + # Sonar will require at least Java 11 soon. + if: matrix.java_version == '11' + run: ./mvnw -B -ntp -ff jacoco:report-aggregate org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=OpenAPITools_openapi-diff -Dsonar.organization=openapitools -Dsonar.host.url=https://sonarcloud.io -Dsonar.branch.name=${GITHUB_REF##*/} - name: Release Snapshot if: matrix.java_version == '11' run: ./mvnw -V -B -ntp -ff deploy diff --git a/pom.xml b/pom.xml index 49167d444..6b453b853 100644 --- a/pom.xml +++ b/pom.xml @@ -306,6 +306,11 @@ 1.6.8 true + + org.jacoco + jacoco-maven-plugin + 0.8.6 + @@ -347,6 +352,51 @@ + + org.jacoco + jacoco-maven-plugin + + + jacoco-initialize + + prepare-agent + + + + jacoco-site + test + + report + + + + default-check + + check + + + + + PACKAGE + + + LINE + COVEREDRATIO + 0 + + + + + + + + + + + + + + From 782abd6c731e360ac435772566c9b0a919804990 Mon Sep 17 00:00:00 2001 From: Jochen Schalanda Date: Fri, 16 Oct 2020 17:36:07 +0200 Subject: [PATCH 2/4] Run SonarCloud analysis for PRs --- .github/workflows/maven.yml | 13 +++++++++-- .github/workflows/pr.yml | 13 +++++++++++ pom.xml | 44 ++++++++++--------------------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 1b74e039e..d85cc10c2 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -40,12 +40,21 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- + - name: Cache SonarCloud packages + uses: actions/cache@v2.1.2 + if: matrix.java_version == '11' + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar - name: Run tests run: ./mvnw -V -B -ntp -ff verify jacoco:report - name: Static Analysis (Sonar) - # Sonar will require at least Java 11 soon. if: matrix.java_version == '11' - run: ./mvnw -B -ntp -ff jacoco:report-aggregate org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=OpenAPITools_openapi-diff -Dsonar.organization=openapitools -Dsonar.host.url=https://sonarcloud.io -Dsonar.branch.name=${GITHUB_REF##*/} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./mvnw -B -ntp -ff org.sonarsource.scanner.maven:sonar-maven-plugin:sonar - name: Release Snapshot if: matrix.java_version == '11' run: ./mvnw -V -B -ntp -ff deploy diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 047beb4c2..0bbe28a30 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -32,5 +32,18 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- + - name: Cache SonarCloud packages + uses: actions/cache@v2.1.2 + if: matrix.java_version == '11' + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar - name: Run tests run: ./mvnw -V -B -ntp -ff verify + - name: Static Analysis (Sonar) + if: matrix.java_version == '11' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./mvnw -B -ntp -ff org.sonarsource.scanner.maven:sonar-maven-plugin:sonar diff --git a/pom.xml b/pom.xml index 6b453b853..7aa3599e7 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,12 @@ UTF-8 UTF-8 github + + openapitools + OpenAPITools_openapi-diff + https://sonarcloud.io + ${project.artifactId} + 2.0.22 1.7.30 @@ -311,6 +317,11 @@ jacoco-maven-plugin 0.8.6 + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.7.0.1746 + @@ -362,40 +373,7 @@ prepare-agent - - jacoco-site - test - - report - - - - default-check - - check - - - - - PACKAGE - - - LINE - COVEREDRATIO - 0 - - - - - - - - - - - - From 49fdd18a342175bfc5a425fbeabb9e2cf0bae05d Mon Sep 17 00:00:00 2001 From: Jochen Schalanda Date: Fri, 16 Oct 2020 17:53:11 +0200 Subject: [PATCH 3/4] Add SonarCloud badge to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9f804609b..885940bb8 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Compare two OpenAPI specifications (3.x) and render the difference to HTML plaintext, or Markdown files. [![Build](https://github.com/OpenAPITools/openapi-diff/workflows/Main%20Build/badge.svg)](https://github.com/OpenAPITools/openapi-diff/actions?query=branch%3Amaster+workflow%3A"Main+Build") +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=OpenAPITools_openapi-diff&metric=alert_status)](https://sonarcloud.io/dashboard?id=OpenAPITools_openapi-diff) [![Maven Central](https://img.shields.io/maven-central/v/org.openapitools.openapidiff/openapi-diff-core)](https://search.maven.org/artifact/org.openapitools.openapidiff/openapi-diff-core) [![Join the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM) From 816df1f56a1feb56c352832d42ba90b40a07c301 Mon Sep 17 00:00:00 2001 From: Jochen Schalanda Date: Fri, 16 Oct 2020 17:54:57 +0200 Subject: [PATCH 4/4] Remove duplicate SONAR_TOKEN environment variable --- .github/workflows/maven.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index d85cc10c2..2fbfae808 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -12,7 +12,6 @@ on: env: OSS_USERNAME: ${{ secrets.OSS_USERNAME }} OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} jobs: build: