From d19bd3e21ee9b352f8f0f9d90c6eacb5a53766a2 Mon Sep 17 00:00:00 2001 From: tk Date: Tue, 4 Feb 2025 20:29:12 +0100 Subject: [PATCH 1/3] Add Sonar Cloud build. --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++++++++++++++ pom.xml | 2 ++ 2 files changed, 38 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b69d55f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: SonarQube +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build and analyze + 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: 'zulu' # Alternative distribution options are available. + - name: Cache SonarQube packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build and analyze + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=sauce-code_cuckoo diff --git a/pom.xml b/pom.xml index 94349f8..15928de 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,8 @@ 21 ${java.version} ${java.version} + sauce-code + https://sonarcloud.io From a4669a202f432bc9aecc498f581309e42aadc8b4 Mon Sep 17 00:00:00 2001 From: tk Date: Tue, 4 Feb 2025 20:31:41 +0100 Subject: [PATCH 2/3] Raise Java Version from 17 to 21. --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b69d55f..bf42fdb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,10 +13,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: - java-version: 17 + java-version: 21 distribution: 'zulu' # Alternative distribution options are available. - name: Cache SonarQube packages uses: actions/cache@v4 From c411e1e64fee275a5fd6cdd54c8aae824b166756 Mon Sep 17 00:00:00 2001 From: tk Date: Tue, 4 Feb 2025 23:08:13 +0100 Subject: [PATCH 3/3] Add Sonar Cloud badges. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index bc13be8..6d06bed 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ ![Source Encoding](https://img.shields.io/badge/Source%20Encoding-UTF--8-blue) ![Java CI with Maven](https://github.com/sauce-code/cuckoo/workflows/Java%20CI%20with%20Maven/badge.svg) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=sauce-code_cuckoo&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=sauce-code_cuckoo) +[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=sauce-code_cuckoo&metric=bugs)](https://sonarcloud.io/summary/new_code?id=sauce-code_cuckoo) +[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=sauce-code_cuckoo&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=sauce-code_cuckoo) +[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=sauce-code_cuckoo&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=sauce-code_cuckoo) # Cuckoo Chess