Skip to content

Commit

Permalink
Add code analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Feb 8, 2024
1 parent 3449800 commit a897fe4
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/code-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Code Analysis

on:
pull_request: null
push:
branches:
- develop
workflow_dispatch:
permissions:
contents: read
jobs:
code_analysis:
strategy:
fail-fast: false
matrix:
actions:
- name: 'PHPStan'
run: composer phpstan
- name: 'Coding Standards'
run: composer fix-cs
name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: 'ctype,curl,dom,iconv,imagick,intl,json,mbstring,openssl,pcre,pdo,reflection,spl,zip'
ini-values: post_max_size=256M, max_execution_time=180, memory_limit=512M
tools: composer:v2
- name: Install Composer dependencies
run: composer install --no-interaction --no-ansi --no-progress
- run: ${{ matrix.actions.run }}
17 changes: 17 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@
"putyourlightson/craft-sprig-core": "^2.6.4"
},
"require-dev": {
"craftcms/commerce": "^4.0.0",
"craftcms/ecs": "dev-main",
"craftcms/feed-me": "^5.0.0",
"craftcms/phpstan": "dev-main",
"markhuot/craft-pest-core": "^2.0.0-rc2",
"mockery/mockery": "^1.0",
"nystudio107/craft-seomatic": "^4.0.0",
"putyourlightson/craft-generate-test-spec": "v2.x-dev",
"yiisoft/yii2-redis": "^2.0"
},
"scripts": {
"phpstan": "phpstan --ansi --memory-limit=1G",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --fix --ansi"
},
"autoload": {
"psr-4": {
"putyourlightson\\blitz\\": "src/"
Expand All @@ -40,6 +48,15 @@
"putyourlightson\\blitztests\\": "tests/"
}
},
"config": {
"allow-plugins": {
"craftcms/plugin-installer": true,
"pestphp/pest-plugin": true,
"yiisoft/yii2-composer": true
},
"optimize-autoloader": true,
"sort-packages": true
},
"support": {
"docs": "https://putyourlightson.com/plugins/blitz",
"source": "https://github.com/putyourlightson/craft-blitz",
Expand Down
3 changes: 1 addition & 2 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function(ECSConfig $ecsConfig): void {
$ecsConfig->parallel();
$ecsConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests/pest',
__FILE__,
]);

$ecsConfig->parallel();
$ecsConfig->sets([SetList::CRAFT_CMS_4]);
};
6 changes: 3 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
includes:
- %currentWorkingDirectory%/vendor/craftcms/phpstan/phpstan.neon
- vendor/craftcms/phpstan/phpstan.neon
parameters:
level: 5
paths:
- src
scanFiles:
# This file must be added to the project root:
# https://github.com/craftcms/cms/blob/develop/lib/craft/behaviors/CustomFieldBehavior.php
- %currentWorkingDirectory%/lib/craft/behaviors/CustomFieldBehavior.php
- lib/craft/behaviors/CustomFieldBehavior.php
bootstrapFiles:
- %currentWorkingDirectory%/bootstrap.php
- bootstrap.php

0 comments on commit a897fe4

Please sign in to comment.