chore: rerun cd after dockerhub token #8
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
| name: CI Backend | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| permissions: | |
| contents: read | |
| checks: write | |
| pull-requests: write | |
| concurrency: | |
| group: ci-backend-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| backend-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: backend/server/package-lock.json | |
| - name: Install backend dependencies | |
| working-directory: backend/server | |
| run: npm ci | |
| - name: Lint backend | |
| working-directory: backend/server | |
| run: npm run lint | |
| - name: Run backend unit tests with coverage | |
| working-directory: backend/server | |
| run: npm run test:cov -- --ci --runInBand | |
| - name: Build backend | |
| working-directory: backend/server | |
| run: npm run build | |
| - name: Publish backend JUnit report | |
| if: ${{ always() && hashFiles('backend/server/test-results/backend-junit.xml') != '' }} | |
| uses: dorny/test-reporter@v2 | |
| with: | |
| name: Backend unit tests | |
| path: backend/server/test-results/backend-junit.xml | |
| reporter: java-junit | |
| - name: Upload backend coverage and test artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-ci-artifacts | |
| if-no-files-found: warn | |
| path: | | |
| backend/server/coverage/** | |
| backend/server/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 backend | |
| 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-backend | |
| -Dsonar.projectName=TRAFIQ-Backend | |
| -Dsonar.sources=backend/server/src | |
| -Dsonar.tests=backend/server/src,backend/server/test | |
| -Dsonar.test.inclusions=backend/server/src/**/*.spec.ts,backend/server/test/**/*.ts | |
| -Dsonar.javascript.lcov.reportPaths=backend/server/coverage/lcov.info | |
| -Dsonar.typescript.tsconfigPaths=backend/server/tsconfig.json | |
| # - name: Enforce backend 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 |