diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e18fae9..4f6819f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,8 +96,14 @@ jobs: - name: Install dependencies run: npm ci --legacy-peer-deps - - name: Run tests - run: npm test + - name: Run tests with coverage + run: npm run test:coverage + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/lcov.info typescript-build: name: TypeScript Build @@ -120,6 +126,29 @@ jobs: env: EXPO_NO_TELEMETRY: 1 + sonarcloud: + name: SonarCloud Analysis + runs-on: ubuntu-latest + needs: [typescript-tests] + if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download coverage report + uses: actions/download-artifact@v4 + with: + name: coverage-report + path: coverage + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # ───────────────────────────────────────────────────────── # Rust / Soroban Smart Contract Checks # ───────────────────────────────────────────────────────── @@ -217,6 +246,7 @@ jobs: typescript-typecheck, typescript-tests, typescript-build, + sonarcloud, rust-format, rust-clippy, rust-tests, @@ -240,6 +270,7 @@ jobs: typescript-typecheck, typescript-tests, typescript-build, + sonarcloud, rust-format, rust-clippy, rust-tests, @@ -256,6 +287,7 @@ jobs: [ "${{ needs.typescript-typecheck.result }}" != "success" ] || \ [ "${{ needs.typescript-tests.result }}" != "success" ] || \ [ "${{ needs.typescript-build.result }}" != "success" ] || \ + [ "${{ needs.sonarcloud.result }}" != "success" ] || \ [ "${{ needs.rust-format.result }}" != "success" ] || \ [ "${{ needs.rust-clippy.result }}" != "success" ] || \ [ "${{ needs.rust-tests.result }}" != "success" ] || \ diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..67e3b7b --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,20 @@ +sonar.projectKey=Smartdevs17_SubTrackr +sonar.organization=smartdevs17 + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=SubTrackr +sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=src +sonar.tests=src +sonar.test.inclusions=**/*.test.tsx,**/*.test.ts + +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8 + +# Coverage report paths +sonar.javascript.lcov.reportPaths=coverage/lcov.info + +# Exclusions +sonar.exclusions=**/node_modules/**,**/dist/**,**/build/**,**/contracts/**,**/stellarlend/**,assets/**