Skip to content

chore: rerun ci after fixing sonar url #5

chore: rerun ci after fixing sonar url

chore: rerun ci after fixing sonar url #5

Workflow file for this run

name: CI Frontend
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: read
checks: write
pull-requests: write
concurrency:
group: ci-frontend-${{ github.ref }}
cancel-in-progress: true
jobs:
frontend-ci:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Lint frontend
working-directory: frontend
run: npm run lint
- name: Run frontend unit tests with coverage
working-directory: frontend
run: npm run test -- --coverage
- name: Build frontend
working-directory: frontend
run: npm run build
- name: Publish frontend JUnit report
if: ${{ always() && hashFiles('frontend/test-results/frontend-junit.xml') != '' }}
uses: dorny/test-reporter@v2
with:
name: Frontend unit tests
path: frontend/test-results/frontend-junit.xml
reporter: java-junit
- name: Upload frontend coverage and test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: frontend-ci-artifacts
if-no-files-found: warn
path: |
frontend/coverage/**
frontend/test-results/**
- name: Validate SonarQube endpoint for GitHub-hosted runner
shell: bash
run: |
if [ -z "${{ vars.SONAR_HOST_URL }}" ]; then
echo "::error::Set repository variable SONAR_HOST_URL to a publicly reachable SonarQube URL. GitHub-hosted runners cannot reach your machine's localhost."
exit 1
fi
if [[ "${{ vars.SONAR_HOST_URL }}" == *"localhost"* ]] || [[ "${{ vars.SONAR_HOST_URL }}" == *"127.0.0.1"* ]]; then
echo "::error::SONAR_HOST_URL=${{ vars.SONAR_HOST_URL }} points to localhost. Expose SonarQube with a tunnel and store that public URL in SONAR_HOST_URL."
exit 1
fi
- name: Run SonarQube scan for frontend
uses: SonarSource/sonarqube-scan-action@v5
env:
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dproject.settings=sonar-project.properties
-Dsonar.projectKey=raedchebbi-esprit-pidev-4twin3-2025-2026-trafiq-frontend
-Dsonar.projectName=TRAFIQ-Frontend
-Dsonar.sources=frontend/src
-Dsonar.tests=frontend/src
-Dsonar.test.inclusions=frontend/src/**/*.test.js,frontend/src/**/*.test.jsx
-Dsonar.javascript.lcov.reportPaths=frontend/coverage/lcov.info
- name: Enforce frontend SonarQube Quality Gate
uses: SonarSource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
scanMetadataReportFile: .scannerwork/report-task.txt
pollingTimeoutSec: 300