diff --git a/.github/workflows/ci-node.yml b/.github/workflows/ci-node.yml
index 7ad7f97..b318a1c 100644
--- a/.github/workflows/ci-node.yml
+++ b/.github/workflows/ci-node.yml
@@ -171,9 +171,43 @@ jobs:
run: yarn test:coverage
env:
CI: true
+ # Coverage path logic (keep in sync with sonarcloud job's cache/restore step):
+ # Resolves the effective directory (app-directory if set, else working-directory),
+ # then prefixes 'coverage' with '
/' when running in a subdirectory.
+ - name: Store coverage report
+ uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
+ with:
+ path: ${{ (inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) && format('{0}/', inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) || ''}}coverage
+ key: cache-${{ github.run_id }}-${{ github.run_attempt }}
+ sonarcloud:
+ name: Run SonarQube Cloud Scan
+ if: ${{ !inputs.skip_sonar }}
+ runs-on: ubuntu-latest
+ needs: tests
+ defaults:
+ run:
+ working-directory: ${{ inputs.working-directory }}
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ # Coverage path logic (keep in sync with tests job's cache/save step):
+ # Resolves the effective directory (app-directory if set, else working-directory),
+ # then prefixes 'coverage' with '/' when running in a subdirectory.
+ - name: Restore coverage report
+ uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
+ with:
+ path: ${{ (inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) && format('{0}/', inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) || ''}}coverage
+ key: cache-${{ github.run_id }}-${{ github.run_attempt }}
+ fail-on-cache-miss: true
+ # Without this workaround, SonarQube Cloud reports a warning about an incorrect source path
+ - name: Override coverage report source path for SonarQube Cloud
+ working-directory: ${{ inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory }}
+ run: |
+ find coverage -type f \( -name '*.info' -o -name 'lcov.info' \) 2>/dev/null | xargs -r sed -i 's@SF:'$GITHUB_WORKSPACE'@SF:/github/workspace/@g' || true
+ find coverage -type f -name '*.json' 2>/dev/null | xargs -r sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' || true
- name: SonarQube Cloud Scan
- if: ${{ !inputs.skip_sonar }}
uses: SonarSource/sonarqube-scan-action@v6
with:
projectBaseDir: ${{ inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory }}