Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

Commit 6a0acd9

Browse files
authored
Add php-cs-fixer & PHPStan on CI (#16)
1 parent b62970d commit 6a0acd9

File tree

8 files changed

+3642
-0
lines changed

8 files changed

+3642
-0
lines changed

.github/workflows/code-style.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: PHP CS Fixe
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
check:
11+
name: Check
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP 8.2
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: 8.2
22+
23+
- name: Install Composer Dependencies
24+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
25+
26+
- name: Run checks of code style
27+
run: composer cs-check

.github/workflows/phpstan.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
analyze:
11+
name: Analyze
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP 8.2
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: 8.2
22+
23+
- name: Install Composer dependencies
24+
run: composer update --no-interaction --prefer-dist
25+
26+
- name: Run tests via PHPStan
27+
run: composer phpstan

.php-cs-fixer.dist.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Gomzyakov\CS\Finder;
6+
use Gomzyakov\CS\Config;
7+
8+
// Routes for analysis with `php-cs-fixer`
9+
$routes = ['./src', './tests'];
10+
11+
return Config::createWithFinder(Finder::createWithRoutes($routes));

composer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "gomzyakov/good-first-issue",
3+
"description": "Make your first open-source contribution.",
4+
"type": "project",
5+
"license": "MIT",
6+
"keywords": [
7+
"good-first-issue"
8+
],
9+
"homepage": "https://github.com/gomzyakov/good-first-issue",
10+
"require": {
11+
"php": "^8.2",
12+
"ext-json": "*"
13+
},
14+
"require-dev": {
15+
"friendsofphp/php-cs-fixer": "^3.34",
16+
"gomzyakov/php-cs-fixer-config": "^1.30",
17+
"phpunit/phpunit": "^10.4",
18+
"phpstan/phpstan": "^1.10"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"GoodFirstIssue\\": "src/"
23+
}
24+
},
25+
"autoload-dev": {
26+
"psr-4": {
27+
"Tests\\": "tests/"
28+
}
29+
},
30+
"scripts": {
31+
"cs-fix": "@php ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php",
32+
"cs-check": "@php ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run",
33+
"phpstan": "@php ./vendor/bin/phpstan analyze -c ./phpstan.neon.dist --no-progress --ansi",
34+
"phpunit": "@php ./vendor/bin/phpunit ./tests --no-coverage --color=always",
35+
"test": [
36+
"@cs-check",
37+
"@phpstan",
38+
"@phpunit"
39+
]
40+
}
41+
}

0 commit comments

Comments
 (0)