Skip to content

Commit

Permalink
test combine phpcs & phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei committed Jul 9, 2024
1 parent 28dcb6f commit 033c067
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 47 deletions.
93 changes: 47 additions & 46 deletions .github/workflows/code_quality.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Code Quality'
name: 'CI'

on:
pull_request:
Expand All @@ -9,7 +9,8 @@ env:
PHPUNIT_FLAGS: "-v"

jobs:
setup:
code-quality:
name: "Code Quality"
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
Expand All @@ -21,6 +22,14 @@ jobs:
php-version: ${{ env.PHP_VERSION }}
coverage: none

- name: "Restore cache results"
uses: actions/cache/restore@v4
with:
path: .cache
key: "ci-result-cache-${{ github.run_id }}"
restore-keys: |
ci-result-cache-
- name: "Restore Composer Cache"
uses: actions/cache/restore@v4
id: restore-composer
Expand All @@ -34,71 +43,63 @@ jobs:
if: steps.restore-composer.outputs.cache-hit != 'true'
run: composer install --no-progress

- name: "Save vendor directory"
if: steps.restore-composer.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock','**/composer.json') }}


php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
needs: setup
steps:
- name: "Create .cache dir"
run: |
mkdir .cache
- name: "Restore PHP-cs-fixer cache results"
uses: actions/cache/restore@v4
with:
path: .cache
key: 'phpcs-result-cache-${{ github.run_id }}'
restore-keys: |
phpcs-result-cache-
- name: "Run PHPStan"
run: vendor/bin/phpstan analyse --error-format=github -vvv

- name: "Run php-cs-fixer"
run: >-
vendor/bin/php-cs-fixer fix --diff --dry-run
--config=.php-cs-fixer.dist.php
- name: "Save PHP-cs-fixer cache results"
- name: "Save cache results"
uses: actions/cache/save@v4
if: always()
with:
path: .cache
key: 'phpcs-result-cache-${{ github.run_id }}'
key: "ci-result-cache-${{ github.run_id }}"

phpstan:
name: PHPStan
- name: "Save vendor directory"
if: steps.restore-composer.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock','**/composer.json') }}

tests:
name: Tests
runs-on: ubuntu-latest
needs: setup
needs: code-quality
steps:
- name: "Restore PHPStan cache results"
- name: "Checkout code"
uses: actions/checkout@v4

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: ${{ env.PHP_VERSION }}
tools: composer:v2

- name: "Restore Composer Cache"
uses: actions/cache/restore@v4
id: restore-composer
with:
path: .cache
key: "phpstan-result-cache-${{ github.run_id }}"
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock','**/composer.json') }}
restore-keys: |
phpstan-result-cache-
${{ runner.os }}-composer-
- name: "Run PHPStan"
run: vendor/bin/phpstan analyse --error-format=github -vvv
- name: "Install Composer dependencies"
if: steps.restore-composer.outputs.cache-hit != 'true'
run: composer install --no-progress

- name: "Save PHPStan cache results"
- name: "Save vendor directory"
if: steps.restore-composer.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
if: always()
with:
path: .cache
key: "phpstan-result-cache-${{ github.run_id }}"
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock','**/composer.json') }}

phpunit:
name: PHPUnit
runs-on: ubuntu-latest
needs: setup
steps:
- name: "PHPUnit version"
run: vendor/bin/phpunit --version

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commit_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Commit Quality

on:
pull_request_target:
types: [opened, ready_for_review]
types: [ready_for_review]

permissions:
pull-requests: read
Expand Down

0 comments on commit 033c067

Please sign in to comment.