Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion .github/workflows/ci-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<dir>/' 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 '<dir>/' 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
Comment on lines 180 to 201
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complex path construction expression ${{ (inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) && format('{0}/', inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) || ''}}coverage is duplicated between lines 179 and 197. This duplication makes the workflow harder to maintain and increases the risk of inconsistencies if one instance is updated but not the other. While GitHub Actions doesn't support workflow-level variables for reusable expressions, consider adding a comment explaining the logic or simplifying the expression if possible.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments.

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 }}
Expand Down