Skip to content

Merge pull request #897 from carstingaxion/fix/update-phpcs-rules #259

Merge pull request #897 from carstingaxion/fix/update-phpcs-rules

Merge pull request #897 from carstingaxion/fix/update-phpcs-rules #259

Workflow file for this run

name: SonarCloud
on:
push:
branches:
- main
jobs:
sonarcloud:
name: 'PHPUnit and Jest Tests'
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: xdebug
- name: Composer Install
run: composer install --optimize-autoloader --prefer-dist
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'
# Restoring the short lived node_modules cache
# to be used across all workflows running on the last commit.
# https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache
- uses: actions/cache/restore@v4
id: node_modules-cache
with:
path: |
./node_modules
key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }}
- name: NPM install
if: steps.node_modules-cache.outputs.cache-hit != 'true'
run: npm ci --legacy-peer-deps
# Creating a short lived node_modules cache
- uses: actions/cache/save@v4
if: steps.node_modules-cache.outputs.cache-hit != 'true'
with:
path: |
./node_modules
key: ${{ steps.node_modules-cache.outputs.cache-primary-key }}
- name: Log debug information
run: |
npm --version
node --version
git --version
php --version
composer --version
- name: Running Tests
run: |
php --version
npm i -g @wordpress/env
npm run test:unit:php
npm run test:unit:js
docker cp $(docker ps -aqf "name=tests-wordpress"):/var/www/html/coverage.xml coverage.xml
if: ${{ success() || failure() }}
- name: Fix Code Coverage Paths
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}