From 8977a0c2b2661730f38740ca233717e238c05bf3 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 1 Feb 2025 11:36:05 -0500 Subject: [PATCH] feat: sonarqube setup (#1805) * feat: sonarqube setup Signed-off-by: Adam Setch * feat: sonarqube setup Signed-off-by: Adam Setch * feat: sonarqube setup Signed-off-by: Adam Setch --------- Signed-off-by: Adam Setch --- .github/workflows/test.yml | 36 +++++++++++++++++++++++++++++++++--- README.md | 9 ++++++--- renovate.json | 11 +++++++++++ sonar-project.properties | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 sonar-project.properties diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c1f87a69..5c2f2c4e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,36 @@ jobs: - run: pnpm install - run: pnpm tsc --noEmit - run: pnpm test -- --coverage --runInBand --verbose - - name: Coveralls - uses: coverallsapp/github-action@v2 - \ No newline at end of file + - name: Archive code coverage results + uses: actions/upload-artifact@v4 + with: + name: code-coverage-report + path: coverage/lcov.info + + sonarqube: + name: SonarQube Cloud Analysis + runs-on: ubuntu-latest + needs: run-unit-tests + # Only analyze PRs from the same repository. Limitation of SonarQube Cloud + if: github.event.pull_request.head.repo.fork == false + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - uses: pnpm/action-setup@v3 + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'pnpm' + - run: pnpm install + - name: Download a single artifact + uses: actions/download-artifact@v4 + with: + name: code-coverage-report + path: coverage/ + - name: SonarQube Cloud Scan + uses: SonarSource/sonarqube-scan-action@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/README.md b/README.md index b88b1f8c3..d39b42002 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Gitify -[![CI Workflow][ci-workflow-badge]][github-actions] [![Release Workflow][release-workflow-badge]][github-actions] [![Coveralls][coveralls-badge]][coveralls] [![Renovate enabled][renovate-badge]][renovate] [![Contributors][contributors-badge]][github] [![Downloads - Total][downloads-total-badge]][website] [![Downloads - Latest Release][downloads-latest-badge]][website] [![OSS License][license-badge]][license] [![Latest Release][github-release-badge]][github-releases] [![Homebrew Cask][homebrew-cask-badge]][homebrew-cask] +[![CI Workflow][ci-workflow-badge]][github-actions] [![Release Workflow][release-workflow-badge]][github-actions] [![Coverage][coverage-badge]][coverage] [![Quality Gate Status][quality-badge]][quality] [![Renovate enabled][renovate-badge]][renovate] [![Contributors][contributors-badge]][github] [![Downloads - Total][downloads-total-badge]][website] [![Downloads - Latest Release][downloads-latest-badge]][website] [![OSS License][license-badge]][license] [![Latest Release][github-release-badge]][github-releases] [![Homebrew Cask][homebrew-cask-badge]][homebrew-cask] > GitHub Notifications on your menu bar. Available on macOS, Windows and Linux. @@ -43,8 +43,11 @@ For more information, see [LICENSE](LICENSE). [brew]: https://brew.sh/ [homebrew-cask]: https://formulae.brew.sh/cask/gitify -[coveralls]: https://coveralls.io/github/gitify-app/gitify -[coveralls-badge]: https://img.shields.io/coverallsCoverage/github/gitify-app/gitify?logo=coveralls +[coverage-badge]: https://img.shields.io/sonar/coverage/gitify-app_gitify?server=https%3A%2F%2Fsonarcloud.io&logo=sonarcloud +[coverage]: https://sonarcloud.io/summary/new_code?id=gitify-app_gitify +[quality-badge]: https://img.shields.io/sonar/quality_gate/gitify-app_gitify?server=https%3A%2F%2Fsonarcloud.io&logo=sonarcloud +[quality]: https://sonarcloud.io/summary/new_code?id=gitify-app_gitify + [ci-workflow-badge]: https://github.com/gitify-app/gitify/actions/workflows/ci.yml/badge.svg [release-workflow-badge]: https://github.com/gitify-app/gitify/actions/workflows/release.yml/badge.svg [downloads-total-badge]: https://img.shields.io/github/downloads/gitify-app/gitify/total?label=downloads@all&logo=github diff --git a/renovate.json b/renovate.json index d999917f5..10113fd49 100644 --- a/renovate.json +++ b/renovate.json @@ -26,5 +26,16 @@ "matchDatasources": ["npm"], "commitMessageTopic": "{{depName}}" } + ], + "customManagers": [ + { + "description": "Keep sonar.projectVersion variables in sonar-project.properties in-sync", + "customType": "regex", + "datasourceTemplate": "github-tags", + "depNameTemplate": "gitify-app/gitify", + "versioningTemplate": "loose", + "fileMatch": ["sonar-project.properties"], + "matchStrings": ["\\s?sonar.projectVersion=(?.+?)\\s"] + } ] } diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..76e0cd3f8 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,36 @@ +# ===================================================== +# SonarCloud +# https://docs.sonarsource.com/sonarcloud/advanced-setup/ci-based-analysis/github-actions-for-sonarcloud/ +# ===================================================== +sonar.projectKey=gitify-app_gitify +sonar.organization=gitify-app +sonar.projectVersion=v6.0.0 +sonar.projectDescription=GitHub notifications on your menu bar. + + +# ===================================================== +# Source Configuration +# https://docs.sonarsource.com/sonarcloud/advanced-setup/analysis-scope/ +# ===================================================== +sonar.sources=./src +sonar.exclusions=**/generated/** +sonar.typescript.tsconfigPaths=./tsconfig.json + + +# ===================================================== +# Test and Coverage Configuration +# https://docs.sonarsource.com/sonarcloud/advanced-setup/analysis-scope/ +# ===================================================== +sonar.tests=./src +sonar.test.inclusions=**/*.test.*, **/__mocks__/**, **/__helpers__/** +sonar.javascript.lcov.reportPaths=./coverage/lcov.info + + +# ===================================================== +# Project Metadata +# https://docs.sonarsource.com/sonarcloud/advanced-setup/ci-based-analysis/sonarscanner-for-npm/configuring/ +# ===================================================== +sonar.links.homepage=https://gitify.io +sonar.links.ci=https://github.com/gitify-app/gitify/actions +sonar.links.scm=https://github.com/gitify-app/gitify +sonar.links.issue=https://github.com/gitify-app/gitify/issues