Fix/actions #95
This file contains 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
# This workflow checks out code, performs a Codacy security scan | |
# and integrates the results with the | |
# GitHub Advanced Security code scanning feature. For more information on | |
# the Codacy security scan action usage and parameters, see | |
# https://github.com/codacy/codacy-analysis-cli-action. | |
# For more information on Codacy Analysis CLI in general, see | |
# https://github.com/codacy/codacy-analysis-cli. | |
name: Codacy Security Scan | |
on: | |
push: | |
branches: ["master", "main"] | |
pull_request: | |
branches: ["master", "main"] | |
# Allows you to run this workflow manually from the Actions tab | |
# eslint-disable-next-line yml/no-empty-mapping-value | |
workflow_dispatch: | |
permissions: | |
contents: read | |
env: | |
NODE_VERSION: latest | |
jobs: | |
codacy-security-scan: | |
permissions: | |
contents: read # for actions/checkout to fetch code | |
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results | |
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | |
name: Codacy Security Scan | |
runs-on: ${{ vars.UBUNTU_VERSION }} | |
steps: | |
# Checkout the repository to the GitHub Actions runner | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis | |
- name: Run Codacy Analysis CLI | |
uses: codacy/[email protected] | |
with: | |
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository | |
# You can also omit the token and run the tools that support default configurations | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
verbose: true | |
output: results.sarif | |
format: sarif | |
# Adjust severity of non-security issues | |
gh-code-scanning-compat: true | |
# Force 0 exit code to allow SARIF file generation | |
# This will handover control about PR rejection to the GitHub side | |
max-allowed-issues: 2147483647 | |
# Upload the SARIF file generated in the previous step | |
- name: Upload SARIF results file | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: results.sarif | |
codacy-coverage-reporter: | |
name: Codacy Coverage Reporter | |
runs-on: ${{ vars.UBUNTU_VERSION }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/[email protected] | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: "npm" | |
- name: Validate composer.json and composer.lock | |
run: composer validate --strict | |
- 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: Check the coverage directory | |
run: | | |
if [ ! -d ./coverage ]; then | |
echo "No coverage directory found. Creating it." | |
mkdir coverage | |
fi | |
echo "Coverage directory found. Directory size: $(du -h ./coverage | cut -f1)" | |
- name: Test coverage | |
run: | | |
export XDEBUG_MODE=coverage | |
composer run-script test | |
- name: Check coverage file | |
run: | | |
echo "Coverage directory listing: $(ls -la ./coverage)" | |
echo "Current path: $(pwd)" | |
echo "Current listing: $(ls -la .)" | |
if [ ! -f ./coverage/clover.xml ]; then | |
echo "No coverage file found" | |
exit 1 | |
fi | |
echo "Coverage file found. File size: $(du -h ./coverage/clover.xml | cut -f1)" | |
- name: Codacy coverage reporter | |
uses: codacy/[email protected] | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
# or | |
# api-token: ${{ secrets.CODACY_API_TOKEN }} | |
coverage-reports: coverage/clover.xml | |
# or a comma-separated list for multiple reports | |
# coverage-reports: <PATH_TO_REPORT>, <PATH_TO_REPORT> |