Skip to content

Commit

Permalink
feat: setup phpstan & rector (#89)
Browse files Browse the repository at this point in the history
* feat: setup phpstan

* feat: cache composer dependencies

* fix: do not check --prefer-lowest with phpstan yet

* feat: setup and applied rector

* fix: smol refactor that rector didn't catch

* fix: updated phpstan baseline after rector change

* fix: use a promoted property for a dependency

* fix: use actions/checkout@v4 instead of master
  • Loading branch information
shavounet authored Oct 26, 2023
1 parent 9c0b98c commit c81c5ad
Show file tree
Hide file tree
Showing 13 changed files with 553 additions and 96 deletions.
64 changes: 61 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Continuous Integration
on: [push, pull_request]
on: [ push, pull_request ]

jobs:
linter:
name: Code style
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
Expand All @@ -22,10 +22,68 @@ jobs:
flags: [ '', '--prefer-lowest' ]
fail-fast: false
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.version }}
coverage: xdebug2
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- run: composer update --prefer-dist --no-interaction ${{ matrix.flags }}
- run: bin/atoum

phpstan:
name: PHPStan checks
runs-on: ubuntu-20.04
strategy:
matrix:
version: [ 8.1, 8.2 ]
flags:
- ''
# TODO add --prefer-lowest once we're ready to handle it
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.version }}
coverage: xdebug2
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- run: composer update --prefer-dist --no-interaction ${{ matrix.flags }}
- run: bin/phpstan

rector:
name: Rector checks
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: xdebug2
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- run: composer update --prefer-dist --no-interaction
- run: bin/rector --dry-run
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"atoum/stubs": "*",
"m6web/php-cs-fixer-config": "3.2.0",
"friendsofphp/php-cs-fixer": "3.35.1",
"guzzlehttp/promises": "^2"
"guzzlehttp/promises": "^2",
"phpstan/phpstan": "1.10.38",
"phpstan/phpstan-symfony": "1.3.4",
"rector/rector": "0.18.5"
},
"autoload": {
"psr-4": {"M6Web\\Bundle\\GuzzleHttpBundle\\": "src/"}
Expand Down
Loading

0 comments on commit c81c5ad

Please sign in to comment.