Skip to content

Merge branch 'release/25.2' into release/25.3 #7

Merge branch 'release/25.2' into release/25.3

Merge branch 'release/25.2' into release/25.3 #7

Workflow file for this run

name: Frontend SonarQube Scan

Check failure on line 1 in .github/workflows/fe-sonar.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/fe-sonar.yml

Invalid workflow file

(Line: 30, Col: 14): Non-scalar mapping key is not supported
# Only run the workflow for master/main and release branches
on:
workflow_call:
secrets:
SONAR_CLOUD_TOKEN:
required: true
description: "SonarCloud authentication token"
inputs:
SONAR_CLOUD_ORG:
required: false
description: "SonarCloud organization key, e.g., 'my-org'"
type: string
default: "collaborationfactory"
SONAR_PROPERTIES:
required: false
description: "Additional sonar-project.properties content"
type: string
default: ""
GITHUB_RUNNER:
required: false
description: "Github runner which is used to run sonar scan jobs"
type: string
default: 'medium'
jobs:
sonarqube-scan:
name: SonarQube Code Quality Scan
runs-on: {{ inputs.GITHUB_RUNNER }}
# Only run the workflow for master/main and release branches
if: github.ref_name == 'master' || github.ref_name == 'main' || startsWith(github.ref_name, 'release/')
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for SonarQube analysis
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.19.1
- name: Cache Node Modules
id: npm-cache
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Run Formatter Check
run: npx nx format:check
- name: Run Linter
run: npx nx run-many --target=lint --all --parallel --configuration=dev
- name: Run Unit Tests with Coverage
run: npx nx run-many --target=test --all --parallel --coverage --codeCoverage=true --coverageReporters=lcov --coverageReporters=html
continue-on-error: false
- name: Check for LCOV files
id: check-lcov
run: |
if find ./coverage -name "lcov*.info" -type f 2>/dev/null | grep -q .; then
echo "lcov_exists=true" >> $GITHUB_OUTPUT
echo "LCOV files found"
else
echo "lcov_exists=false" >> $GITHUB_OUTPUT
echo "No LCOV files found, will proceed without coverage"
fi
- name: Merge coverage reports
if: steps.check-lcov.outputs.lcov_exists == 'true'
run: |
echo "=== Finding all LCOV files ==="
find ./coverage -name "lcov*.info" -type f
echo ""
echo "=== Merging coverage files ==="
npx lcov-result-merger "coverage/**/lcov*.info" coverage/lcov.info
echo ""
echo "=== Merge completed ==="
ls -lh ./coverage/lcov.info || echo "Merge failed or no output file"
- name: Normalize LCOV paths
if: steps.check-lcov.outputs.lcov_exists == 'true'
run: |
if [ -f "./coverage/lcov.info" ]; then
sed -i 's|\\|/|g' ./coverage/lcov.info
echo "Normalized LCOV paths to Unix format"
else
echo "Warning: coverage/lcov.info not found"
fi
- name: Write sonar-project.properties
run: |
echo "sonar.host.url=https://sonarcloud.io" > sonar-project.properties
echo "sonar.organization=${{ inputs.SONAR_CLOUD_ORG || 'collaborationfactory' }}" >> sonar-project.properties
echo "sonar.projectKey=collaborationFactory_${{ github.event.repository.name }}" >> sonar-project.properties
echo "sonar.test.inclusions=**/*.spec.ts,**/*.test.ts,**/*.spec.tsx,**/*.test.tsx" >> sonar-project.properties
echo "sonar.branch.name=${{ github.ref_name }}" >> sonar-project.properties
echo "sonar.projectVersion=${{ github.ref_name }}" >> sonar-project.properties
echo "sonar.qualitygate.wait=true" >> sonar-project.properties
if [ -f "./coverage/lcov.info" ]; then
echo "sonar.javascript.lcov.reportPaths=./coverage/lcov.info" >> sonar-project.properties
fi
if [ -n "${{ inputs.SONAR_PROPERTIES }}" ]; then
echo "${{ inputs.SONAR_PROPERTIES }}" >> sonar-project.properties
fi
echo "=== SonarQube Configuration ==="
cat sonar-project.properties
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v6
env:
SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }}