Skip to content

Commit 48a3300

Browse files
authored
Merge pull request #33 from codeigniter4/self-apply
enhancement: Self Apply
2 parents 071b935 + 0ea566d commit 48a3300

File tree

13 files changed

+508
-9
lines changed

13 files changed

+508
-9
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: composer
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: daily

.github/workflows/phpcsfixer.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: PHPCSFixer
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
paths:
8+
- '**.php'
9+
- '.github/workflows/phpcsfixer.yml'
10+
push:
11+
branches:
12+
- develop
13+
paths:
14+
- '**.php'
15+
- '.github/workflows/phpcsfixer.yml'
16+
17+
jobs:
18+
build:
19+
name: Coding Standards
20+
runs-on: ubuntu-latest
21+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
27+
- name: Set up PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: '8.1'
31+
extensions: json, tokenizer
32+
coverage: none
33+
env:
34+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Get composer cache directory
37+
id: composer-cache
38+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
39+
40+
- name: Cache composer dependencies
41+
uses: actions/cache@v3
42+
with:
43+
path: ${{ steps.composer-cache.outputs.dir }}
44+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}
45+
restore-keys: ${{ runner.os }}-composer-
46+
47+
- name: Install dependencies
48+
run: |
49+
if [ -f composer.lock ]; then
50+
composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
51+
else
52+
composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
53+
fi
54+
55+
- name: Check code for standards compliance
56+
run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --using-cache=no --diff

.github/workflows/phpstan.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: PHPStan
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
paths:
8+
- '**.php'
9+
- 'composer.*'
10+
- 'phpstan*'
11+
- '.github/workflows/phpstan.yml'
12+
push:
13+
branches:
14+
- develop
15+
paths:
16+
- '**.php'
17+
- 'composer.*'
18+
- 'phpstan*'
19+
- '.github/workflows/phpstan.yml'
20+
21+
jobs:
22+
build:
23+
name: PHP ${{ matrix.php-versions }} Static Analysis
24+
runs-on: ubuntu-latest
25+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
php-versions: ['7.4', '8.0', '8.1']
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v3
34+
35+
- name: Setup PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ matrix.php-versions }}
39+
tools: phpstan, phpunit
40+
extensions: intl, json, mbstring, xml
41+
coverage: none
42+
env:
43+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Get composer cache directory
46+
id: composer-cache
47+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
48+
49+
- name: Cache composer dependencies
50+
uses: actions/cache@v3
51+
with:
52+
path: ${{ steps.composer-cache.outputs.dir }}
53+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}
54+
restore-keys: ${{ runner.os }}-composer-
55+
56+
- name: Create PHPStan cache directory
57+
run: mkdir -p build/phpstan
58+
59+
- name: Cache PHPStan results
60+
uses: actions/cache@v3
61+
with:
62+
path: build/phpstan
63+
key: ${{ runner.os }}-phpstan-${{ github.sha }}
64+
restore-keys: ${{ runner.os }}-phpstan-
65+
66+
- name: Install dependencies
67+
run: |
68+
if [ -f composer.lock ]; then
69+
composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
70+
else
71+
composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
72+
fi
73+
74+
- name: Run static analysis
75+
run: vendor/bin/phpstan analyze

.github/workflows/psalm.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Psalm
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
paths:
8+
- '**.php'
9+
- 'composer.*'
10+
- 'psalm*'
11+
- '.github/workflows/psalm.yml'
12+
push:
13+
branches:
14+
- develop
15+
paths:
16+
- '**.php'
17+
- 'composer.*'
18+
- 'psalm*'
19+
- '.github/workflows/psalm.yml'
20+
21+
jobs:
22+
build:
23+
name: Psalm Analysis
24+
runs-on: ubuntu-latest
25+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
31+
- name: Setup PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: '8.1'
35+
tools: phpstan, phpunit
36+
extensions: intl, json, mbstring, xml
37+
coverage: none
38+
env:
39+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Get composer cache directory
42+
id: composer-cache
43+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
44+
45+
- name: Cache composer dependencies
46+
uses: actions/cache@v3
47+
with:
48+
path: ${{ steps.composer-cache.outputs.dir }}
49+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}
50+
restore-keys: ${{ runner.os }}-composer-
51+
52+
- name: Create Psalm cache directory
53+
run: mkdir -p build/psalm
54+
55+
- name: Cache Psalm results
56+
uses: actions/cache@v3
57+
with:
58+
path: build/psalm
59+
key: ${{ runner.os }}-psalm-${{ github.sha }}
60+
restore-keys: ${{ runner.os }}-psalm-
61+
62+
- name: Install dependencies
63+
run: |
64+
if [ -f composer.lock ]; then
65+
composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
66+
else
67+
composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
68+
fi
69+
70+
- name: Run Psalm analysis
71+
run: vendor/bin/psalm

.github/workflows/rector.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Rector
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
paths:
8+
- '**.php'
9+
- 'composer.*'
10+
- 'rector.php'
11+
- '.github/workflows/rector.yml'
12+
push:
13+
branches:
14+
- develop
15+
paths:
16+
- '**.php'
17+
- 'composer.*'
18+
- 'rector.php'
19+
- '.github/workflows/rector.yml'
20+
21+
jobs:
22+
build:
23+
name: PHP ${{ matrix.php-versions }} Rector Analysis
24+
runs-on: ubuntu-latest
25+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
php-versions: ['7.4', '8.0', '8.1']
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v3
34+
35+
- name: Set up PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ matrix.php-versions }}
39+
tools: phpstan
40+
extensions: intl, json, mbstring, xml
41+
coverage: none
42+
env:
43+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Get composer cache directory
46+
id: composer-cache
47+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
48+
49+
- name: Cache composer dependencies
50+
uses: actions/cache@v3
51+
with:
52+
path: ${{ steps.composer-cache.outputs.dir }}
53+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}
54+
restore-keys: ${{ runner.os }}-composer-
55+
56+
- name: Install dependencies
57+
run: |
58+
if [ -f composer.lock ]; then
59+
composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
60+
else
61+
composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
62+
fi
63+
64+
- name: Analyze for refactoring
65+
run: |
66+
composer global require --dev rector/rector:^0.13.8
67+
rector process --dry-run --no-progress-bar

.php-cs-fixer.dist.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use CodeIgniter\CodingStandard\CodeIgniter4;
4+
use Nexus\CsConfig\Factory;
5+
use PhpCsFixer\Finder;
6+
7+
$finder = Finder::create()
8+
->files()
9+
->in([
10+
__DIR__ . '/src/',
11+
])
12+
->exclude('build')
13+
->append([__FILE__]);
14+
15+
$overrides = [];
16+
17+
$options = [
18+
'finder' => $finder,
19+
'cacheFile' => 'build/.php-cs-fixer.cache',
20+
];
21+
22+
return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects();

composer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,29 @@
3535
"roave/security-advisories": "dev-latest",
3636
"vimeo/psalm": "^4.22"
3737
},
38+
"require-dev": {
39+
"codeigniter4/framework": "^4.1",
40+
"icanhazstring/composer-unused": "^0.8.2",
41+
"rector/rector": "0.13.5"
42+
},
3843
"minimum-stability": "dev",
3944
"prefer-stable": true,
4045
"config": {
4146
"allow-plugins": {
4247
"phpstan/extension-installer": true
4348
}
49+
},
50+
"scripts": {
51+
"analyze": [
52+
"phpstan analyze",
53+
"psalm",
54+
"rector process --dry-run"
55+
],
56+
"ci": [
57+
"Composer\\Config::disableProcessTimeout",
58+
"@analyze",
59+
"@style"
60+
],
61+
"style": "php-cs-fixer fix --verbose --ansi --using-cache=no"
4462
}
4563
}

phpstan.neon.dist

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
parameters:
2+
tmpDir: build/phpstan
3+
level: 5
4+
paths:
5+
- src/
6+
bootstrapFiles:
7+
- vendor/codeigniter4/framework/system/Test/bootstrap.php
8+
excludePaths:
9+
- src/Config/Routes.php
10+
- src/Views/*
11+
ignoreErrors:
12+
universalObjectCratesClasses:
13+
- CodeIgniter\Entity
14+
- CodeIgniter\Entity\Entity
15+
- Faker\Generator
16+
scanDirectories:
17+
- vendor/codeigniter4/framework/system/Helpers
18+
dynamicConstantNames:
19+
- APP_NAMESPACE
20+
- CI_DEBUG
21+
- ENVIRONMENT

psalm.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="7"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
autoloader="psalm_autoload.php"
9+
cacheDirectory="build/psalm/"
10+
>
11+
<projectFiles>
12+
<directory name="src/" />
13+
<ignoreFiles>
14+
<directory name="vendor" />
15+
<file name="src/ide/phpstorm/.phpstorm.meta.php" />
16+
<file name="src/Template/composer-unused.php" />
17+
<file name="src/Template/psalm_autoload.php" />
18+
</ignoreFiles>
19+
</projectFiles>
20+
</psalm>

0 commit comments

Comments
 (0)