Skip to content

Commit

Permalink
Merge pull request #383 from cakephp/5.x-ci-workflow
Browse files Browse the repository at this point in the history
Update CI workflow
  • Loading branch information
dereuromark committed Apr 9, 2023
2 parents 2374ead + 3351668 commit 3897d72
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 71 deletions.
80 changes: 19 additions & 61 deletions .github/workflows/ci.yml
Expand Up @@ -11,94 +11,52 @@ on:

jobs:
testsuite:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0']
prefer-lowest: ['']
php-version: ['8.1', '8.2']
dependencies: ['highest']
include:
- php-version: '7.4'
prefer-lowest: 'prefer-lowest'
- php-version: '8.1'
dependencies: 'lowest'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: pcov

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Get date part for cache key
id: key-date
run: echo "::set-output name=date::$(date +'%Y-%m')"
coverage: none

- name: Cache composer dependencies
uses: actions/cache@v2
- name: Composer install
uses: ramsey/composer-install@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

- name: Composer Install
run: |
if [[ ${{ matrix.php-version }} == '8.0' ]]; then
composer install --ignore-platform-reqs
elif ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
else
composer install
fi
- name: Setup problem matchers for PHPUnit
if: matrix.php-version == '7.4'
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
dependency-versions: ${{ matrix.dependencies }}
composer-options: --ignore-platform-reqs

- name: Run PHPUnit
run: |
vendor/bin/phpcs --config-set installed_paths $(pwd)
vendor/bin/phpunit --filter CakePHP
- name: Submit code coverage
if: matrix.php-version == '7.4'
uses: codecov/codecov-action@v1
run: composer phpunit

cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl
php-version: '8.1'
tools: cs2pr
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Get date part for cache key
id: key-date
run: echo "::set-output name=date::$(date +'%Y-%m')"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

- name: Composer install
run: composer install
uses: ramsey/composer-install@v2
with:
composer-options: --ignore-platform-reqs

- name: Run PHP CodeSniffer
run: vendor/bin/phpcs --report=checkstyle CakePHP/ | cs2pr
run: vendor/bin/phpcs --report=checkstyle | cs2pr
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -18,7 +18,7 @@
"source": "https://github.com/cakephp/cakephp-codesniffer"
},
"require": {
"php": ">=7.2.0",
"php": ">=8.1.0",
"phpstan/phpdoc-parser": "^1.4.5",
"slevomat/coding-standard": "^8.4",
"squizlabs/php_codesniffer": "^3.7.1"
Expand All @@ -38,9 +38,10 @@
},
"scripts": {
"add-standard" : "phpcs --config-set installed_paths $(pwd)",
"phpunit": "phpunit vendor/squizlabs/php_codesniffer/tests/AllTests.php --filter CakePHP --no-configuration --bootstrap=vendor/squizlabs/php_codesniffer/tests/bootstrap.php --dont-report-useless-tests",
"test": [
"@add-standard",
"phpunit --filter CakePHP"
"@phpunit"
],
"cs-check": "phpcs --colors --parallel=16 -p -s CakePHP/",
"cs-fix": "phpcbf --colors --parallel=16 -p CakePHP/",
Expand Down
23 changes: 15 additions & 8 deletions docs/README.md
@@ -1,13 +1,14 @@
# CakePHP ruleset

The CakePHP standard contains 136 sniffs
The CakePHP standard contains 143 sniffs

CakePHP (19 sniffs)
CakePHP (20 sniffs)
-------------------
- CakePHP.Classes.ReturnTypeHint
- CakePHP.Commenting.DocBlockAlignment
- CakePHP.Commenting.FunctionComment
- CakePHP.Commenting.InheritDoc
- CakePHP.Commenting.TypeHint
- CakePHP.ControlStructures.ControlStructures
- CakePHP.ControlStructures.ElseIfDeclaration
- CakePHP.ControlStructures.WhileStructures
Expand Down Expand Up @@ -52,22 +53,22 @@ Generic (25 sniffs)
- Generic.WhiteSpace.IncrementDecrementSpacing
- Generic.WhiteSpace.ScopeIndent

PEAR (2 sniffs)
PEAR (1 sniff)
---------------
- PEAR.Functions.ValidDefaultValue
- PEAR.NamingConventions.ValidFunctionName

PSR1 (3 sniffs)
---------------
- PSR1.Classes.ClassDeclaration
- PSR1.Files.SideEffects
- PSR1.Methods.CamelCapsMethodName

PSR12 (16 sniffs)
PSR12 (17 sniffs)
-----------------
- PSR12.Classes.AnonClassDeclaration
- PSR12.Classes.ClassInstantiation
- PSR12.Classes.ClosingBrace
- PSR12.Classes.OpeningBraceSpace
- PSR12.ControlStructures.BooleanOperatorPlacement
- PSR12.ControlStructures.ControlStructureSpacing
- PSR12.Files.DeclareStatement
Expand All @@ -94,12 +95,13 @@ PSR2 (9 sniffs)
- PSR2.Methods.FunctionClosingBrace
- PSR2.Methods.MethodDeclaration

SlevomatCodingStandard (32 sniffs)
SlevomatCodingStandard (39 sniffs)
----------------------------------
- SlevomatCodingStandard.Arrays.TrailingArrayComma
- SlevomatCodingStandard.Classes.ClassConstantVisibility
- SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces
- SlevomatCodingStandard.Classes.ModernClassNameReference
- SlevomatCodingStandard.Classes.PropertyDeclaration
- SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment
- SlevomatCodingStandard.Commenting.DocCommentSpacing
- SlevomatCodingStandard.Commenting.EmptyComment
Expand All @@ -114,6 +116,7 @@ SlevomatCodingStandard (32 sniffs)
- SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses
- SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation
- SlevomatCodingStandard.Namespaces.NamespaceDeclaration
- SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly
- SlevomatCodingStandard.Namespaces.UnusedUses
- SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash
- SlevomatCodingStandard.Namespaces.UseFromSameNamespace
Expand All @@ -125,11 +128,16 @@ SlevomatCodingStandard (32 sniffs)
- SlevomatCodingStandard.TypeHints.DeclareStrictTypes
- SlevomatCodingStandard.TypeHints.LongTypeHints
- SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue
- SlevomatCodingStandard.TypeHints.ParameterTypeHint
- SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing
- SlevomatCodingStandard.TypeHints.PropertyTypeHint
- SlevomatCodingStandard.TypeHints.ReturnTypeHint
- SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing
- SlevomatCodingStandard.TypeHints.UnionTypeHintFormat
- SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable
- SlevomatCodingStandard.Variables.UnusedVariable

Squiz (29 sniffs)
Squiz (28 sniffs)
-----------------
- Squiz.Arrays.ArrayBracketSpacing
- Squiz.Classes.ClassFileName
Expand All @@ -144,7 +152,6 @@ Squiz (29 sniffs)
- Squiz.Functions.FunctionDeclarationArgumentSpacing
- Squiz.Functions.LowercaseFunctionKeywords
- Squiz.Functions.MultiLineFunctionDeclaration
- Squiz.NamingConventions.ValidFunctionName
- Squiz.Operators.ValidLogicalOperators
- Squiz.PHP.DisallowSizeFunctionsInLoops
- Squiz.PHP.Eval
Expand Down
2 changes: 2 additions & 0 deletions phpcs.xml
Expand Up @@ -4,6 +4,8 @@

<arg name="extensions" value="php"/>

<file>CakePHP/</file>

<!-- CakePHP coding standard -->
<rule ref="CakePHP"/>

Expand Down

0 comments on commit 3897d72

Please sign in to comment.