Update AlDanial/cloc (#201) #620
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow | |
name: "Back-end" | |
on: # yamllint disable-line rule:truthy | |
pull_request: null | |
push: | |
branches: | |
- "master" | |
# Add [skip ci] to commit message to skip CI. | |
permissions: {} # yamllint disable-line rule:braces | |
#permissions: "read-all" | |
#permissions: | |
# contents: "read" # Private repositories need read permission | |
concurrency: | |
group: "${{ github.workflow }}-${{ github.ref }}" | |
cancel-in-progress: true | |
jobs: | |
syntax_errors: | |
name: "1️⃣ Syntax errors" | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 5 | |
steps: | |
- | |
name: "Set up PHP" | |
uses: "shivammathur/setup-php@2.30.0" | |
with: | |
php-version: "8.2" | |
coverage: "none" | |
tools: "parallel-lint" | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v4.1.5" | |
- | |
name: "Search for invalid complex curly syntax 🐌" | |
run: | | |
! git grep -e '\${[A-Z_a-z]' -- '*.php' '*.scss' | |
- | |
name: "Check source code for syntax errors" | |
run: "composer exec --no-interaction -- parallel-lint src/ tests/" | |
# @TODO Check template files for syntax errors | |
unit_tests: | |
name: "2️⃣ Unit and functional tests" | |
needs: | |
- "syntax_errors" | |
strategy: | |
#fail-fast: false | |
matrix: | |
php-version: | |
- "8.2" | |
dependencies: | |
- "lowest" | |
- "highest" | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 5 | |
#services: | |
# database: | |
# image: "mariadb:11.0.2" | |
# env: | |
# MYSQL_DATABASE: "cylinder" | |
# MYSQL_USER: "dba" | |
# MYSQL_PASSWORD: "plaintextoffender" | |
# MYSQL_RANDOM_ROOT_PASSWORD: "1" | |
# options: >- | |
# --health-cmd "healthcheck.sh --connect --innodb_initialized" | |
# --health-interval 1s | |
# --health-timeout 10s | |
# --health-retries 30 | |
steps: | |
- | |
name: "Set up PHP" | |
uses: "shivammathur/setup-php@2.30.0" | |
with: | |
php-version: "${{ matrix.php-version }}" | |
- | |
name: "Setup problem matcher for PHPUnit" | |
run: | | |
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v4.1.5" | |
- | |
name: "Install dependencies" | |
uses: "ramsey/composer-install@3.0.0" | |
#env: | |
# COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ github.token }}"}}' | |
# yamllint disable-line rule:line-length | |
# COMPOSER_AUTH: '{"http-basic":{"nova.laravel.com":{"username":"${{ secrets.NOVA_LICENSE_ACCOUNT }}","password":"${{ secrets.NOVA_LICENSE_KEY }}"}}}' | |
with: | |
dependency-versions: "${{ matrix.dependencies }}" | |
#composer-options: "--with=laravel/framework:${{ matrix.laravel-constraint }}" | |
- | |
name: "Declare strict types" | |
if: "${{ matrix.dependencies == 'highest' }}" | |
run: | | |
echo "::group::Install slevomat/coding-standard" | |
composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer false | |
composer require --no-scripts --dev --with-all-dependencies slevomat/coding-standard | |
echo "::endgroup::" | |
composer exec -- phpcbf --standard=vendor/slevomat/coding-standard/SlevomatCodingStandard \ | |
--sniffs=SlevomatCodingStandard.TypeHints.DeclareStrictTypes src/ \ | |
|| test "$?" = 1 && git diff -- src/ | |
- | |
name: "Execute unit tests" | |
#run: "composer exec -- phpunit" | |
run: "composer exec -- pest --ci" | |
# @TODO Run functional tests | |
- | |
name: "Tests have failed: upload logs" | |
if: "${{ failure() }}" | |
uses: "actions/upload-artifact@v4.5.0" | |
with: | |
path: "storage/logs/" | |
# Prefix with project name (github.repository contains a slash) | |
name: "laravel-logs-${{ matrix.php-version }}-${{ matrix.dependencies }}" | |
- | |
name: "Send coverage to Coveralls" | |
env: | |
COVERALLS_REPO_TOKEN: "${{ github.token }}" | |
if: "${{ env.COVERALLS_REPO_TOKEN && matrix.php-version == '8.2' && matrix.dependencies == 'highest' }}" | |
uses: "coverallsapp/github-action@v2.3.0" | |
with: | |
github-token: "${{ env.COVERALLS_REPO_TOKEN }}" | |
flag-name: "Unit" | |
allow-empty: false | |
static_analysis: | |
name: "3️⃣ Static Analysis" | |
needs: | |
- "syntax_errors" | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 5 | |
steps: | |
- | |
name: "Set up PHP" | |
uses: "shivammathur/setup-php@2.30.0" | |
with: | |
php-version: "8.2" | |
coverage: "none" | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v4.1.5" | |
- | |
name: "Check JSON files" | |
run: | | |
git ls-files --cached -z -- '*.json' \ | |
| xargs -t --null -L 1 -- \ | |
php -r 'json_decode(file_get_contents($argv[1]), null, 512, JSON_THROW_ON_ERROR);' | |
- | |
name: "Validate Composer configuration" | |
run: "composer validate --no-interaction --strict" | |
- | |
name: "Install dependencies" | |
uses: "ramsey/composer-install@3.0.0" | |
with: | |
dependency-versions: "highest" | |
- | |
name: "Check PSR-4 mapping 🐌" | |
run: "composer dump-autoload --dev --optimize --strict-psr" | |
- | |
name: "Check for security vulnerability advisories" | |
run: "composer audit" | |
#- | |
# name: "Check architecture" | |
# run: "composer exec -- phparkitect check --config=vendor/mortexa/laravel-arkitect/src/phparkitect.php" | |
- | |
# https://github.com/phpstan/phpstan/issues/9475 | |
name: "Search for $this typos 🐌" | |
run: | | |
! git grep --line-number -e '\$this\s*->\s*\$this\|\$\$this' -- ':!:*/back-end.yml' | |
- | |
name: "Perform static analysis" | |
run: "composer exec -- phpstan analyze -v --level=5 src/" | |
# @TODO Cognitive Complexity tomasvotruba/cognitive-complexity | |
# Mess Detector phpmd/phpmd | |
# Magic Number Detector povils/phpmnd | |
# Copy-Paste Detector https://github.com/mkrauser/phpcpd | |
coding_standards: | |
name: "4️⃣ Coding Standards" | |
needs: | |
- "syntax_errors" | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 5 | |
steps: | |
- | |
name: "Set up PHP" | |
uses: "shivammathur/setup-php@2.30.0" | |
with: | |
php-version: "8.2" | |
coverage: "none" | |
tools: "phpcs,cs2pr" | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v4.1.5" | |
- | |
name: "Install dependencies" | |
uses: "ramsey/composer-install@3.0.0" | |
with: | |
dependency-versions: "highest" | |
- | |
name: "Detect coding standards violations" | |
run: "composer exec -- phpcs -q --report=checkstyle --standard=PSR12 src/ | cs2pr" | |
# yamllint disable-line rule:comments-indentation | |
#- | |
# name: "Detect coding standards violations" | |
# id: "pint" | |
# run: "composer exec -- pint --verbose --test" | |
#- | |
# name: "Annotate Pint results" | |
# if: "${{ failure() && steps.pint.outcome == 'failure' }}" | |
# run: "composer exec -- pint --test --format=checkstyle | cs2pr" |