Skip to content

Fix/actions

Fix/actions #52

Workflow file for this run

# This workflow helps you trigger a SonarCloud analysis of your code and populates
# GitHub Code Scanning alerts with the vulnerabilities found.
# Free for open source project.
name: SonarCloud analysis
on:
push:
branches: ["master", "main"]
pull_request:
branches: ["master", "main"]
types: [opened, synchronize, reopened]
# Allows you to run this workflow manually from the Actions tab
# eslint-disable-next-line yml/no-empty-mapping-value
workflow_dispatch:
permissions:
pull-requests: read # allows SonarCloud to decorate PRs with analysis results
env:
NODE_VERSION: latest
jobs:
sonarqube:
name: SonarQube
runs-on: ${{ vars.UBUNTU_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/[email protected]
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Starting local web server
# bash shell is required for Windows, otherwise the background
# server does not start and work properly
shell: bash
run: npm run start-server &
- name: Wait for server to start up
run: npx wait-on --timeout 15000 http://127.0.0.1:3000
- name: Server warm up
run: sleep 5
- name: Test coverage
run: npm run coverage
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}