chore(deps-dev): bump fast-uri from 3.1.2 to 3.1.5 #212
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SonarCloud Analysis | |
| # This workflow runs SonarCloud static analysis for code quality and security | |
| # when explicitly enabled. It is disabled by default so forks do not run | |
| # SonarCloud unless they opt in via repository variables/secrets. | |
| # | |
| # Triggers: | |
| # - `push` and `pull_request` on `main` (but the job is guarded by an `if` | |
| # condition so it only executes when `ENABLE_SONARCLOUD` is `true` or the manual | |
| # `workflow_dispatch` input `run_sonarcloud` is provided and a `SONAR_TOKEN` | |
| # secret is present. | |
| # - `workflow_dispatch` allows manual runs with `run_sonarcloud` boolean input. | |
| name: SonarCloud Analysis | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| run_sonarcloud: | |
| description: 'Run SonarCloud analysis' | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| sonarcloud: | |
| name: SonarCloud Scan | |
| runs-on: ubuntu-latest | |
| # Guard: only run when repo variable `ENABLE_SONARCLOUD` is true OR manual | |
| # dispatch requests `run_sonarcloud=true`. We cannot reference `secrets` in | |
| # a job-level `if` expression, so the presence of `SONAR_TOKEN` is checked | |
| # at the step level below. This protects forks from unintentionally | |
| # publishing to SonarCloud. | |
| if: (vars.ENABLE_SONARCLOUD == 'true' || inputs.run_sonarcloud == true) | |
| permissions: | |
| contents: read | |
| # Expose the secret into job env so step-level `if` can test existence | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # SonarCloud benefits from a full repo history for better analysis | |
| # context; disable shallow clone for accurate results. | |
| fetch-depth: 0 | |
| # Debug info - can be removed if not required | |
| - name: Debug Info | |
| uses: ./.github/actions/debug-info | |
| with: | |
| show-env: 'false' | |
| - name: Log workflow context | |
| run: | | |
| echo "[SonarCloud] Triggered by $GITHUB_EVENT_NAME on ref $GITHUB_REF for $GITHUB_REPOSITORY" | |
| echo "[SonarCloud] ENABLE_SONARCLOUD=${{ vars.ENABLE_SONARCLOUD }}" | |
| # Check for SONAR_TOKEN in secrets; if missing, set output and print reason | |
| - id: check-sonar-token | |
| name: Check SONAR_TOKEN | |
| run: | | |
| if [ -z "${SONAR_TOKEN:-}" ]; then | |
| echo "SONAR_TOKEN is not set. Skipping SonarCloud analysis." | |
| echo "has_token=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_token=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: "Skip SonarCloud: missing SONAR_TOKEN" | |
| if: steps.check-sonar-token.outputs.has_token == 'false' | |
| run: | | |
| echo "Skipping SonarCloud CI scan because SONAR_TOKEN is not configured in repository secrets." | |
| echo "To enable scans, add a SonarCloud token as the `SONAR_TOKEN` secret, or set ENABLE_SONARCLOUD=false to disable the workflow." | |
| - uses: actions/setup-node@v4 | |
| if: steps.check-sonar-token.outputs.has_token == 'true' | |
| with: | |
| # Use Node 20 as in other CI workflows; the `cache: 'npm'` option | |
| # enables dependency caching via the setup action (lockfile-based). | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| if: steps.check-sonar-token.outputs.has_token == 'true' | |
| run: npm ci | |
| - name: Run tests with coverage | |
| if: steps.check-sonar-token.outputs.has_token == 'true' | |
| # Generate coverage reports so SonarCloud can import coverage data. | |
| run: npm run test:unit -- --run --coverage | |
| - name: SonarCloud Scan | |
| # The SonarCloud action requires a valid token. Only run when the token check reports true. | |
| if: steps.check-sonar-token.outputs.has_token == 'true' | |
| uses: SonarSource/sonarcloud-github-action@master | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Pass the token through to the action from the job env | |
| SONAR_TOKEN: ${{ env.SONAR_TOKEN }} | |
| with: | |
| args: > | |
| -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} | |
| -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} | |
| -Dsonar.sources=src | |
| -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info | |
| -Dsonar.verbose=true |