Skip to content

Commit

Permalink
mise en place de PHPStan dans la CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Mopolo committed Nov 30, 2023
1 parent c51de10 commit 375bfdc
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 21 deletions.
59 changes: 45 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ jobs:
unit:
name: "Unit tests"
runs-on: ubuntu-20.04

strategy:
fail-fast: false
matrix:
php: ["5.6", "7.0"]

steps:
- uses: actions/checkout@v2

- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'

- name: Composer - Get Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
Expand Down Expand Up @@ -54,20 +54,17 @@ jobs:
with:
php-version: '5.6'

- name: Composer - Get Cache Directory
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v1
id: cache-composer
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-php.5.6-${{ github.sha }}
restore-keys: composer-php.5.6-

- name: Composer - Create cache directory
run: mkdir -p /home/runner/.composer/cache
if: steps.cache-composer.outputs.cache-hit != 'true'
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: CS fixer prerequisites
run: make configs/application/config.php
Expand All @@ -78,6 +75,40 @@ jobs:
- name: Tests - CS Fixer
run: ./bin/php-cs-fixer fix --dry-run -vv

phpstan:
name: "PHPStan"
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v4

- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: phpstan

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Prerequisites
run: make configs/application/config.php

- name: Composer install
run: composer install --no-scripts --ignore-platform-req=php

- name: PHPStan
run: phpstan analyse

functional:
name: "Functional tests"
runs-on: ubuntu-20.04
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
CURRENT_UID ?= $(shell id -u)
DOCKER_UP_OPTIONS ?=

.PHONY: install docker-up docker-stop docker-down test hooks vendors db-seed db-migrations reset-db init console
.PHONY: install docker-up docker-stop docker-down test hooks vendors db-seed db-migrations reset-db init console phpstan

install: vendors

Expand Down Expand Up @@ -109,3 +109,6 @@ db-seed:

console:
CURRENT_UID=$(CURRENT_UID) docker-compose run --rm cliphp bash

phpstan:
docker run -v $(shell pwd):/app --rm ghcr.io/phpstan/phpstan
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dms/meetup-api-client": "^2.3",
"robmorgan/phinx": "^0.9.2",
"presta/sitemap-bundle": "^1.5",
"setasign/fpdf": "1.53",
"setasign/fpdf": "1.6",
"ezyang/htmlpurifier": "^4.10",
"phpoffice/phpspreadsheet": "^1.6",
"phpmailer/phpmailer": "5.2.9",
Expand Down Expand Up @@ -111,9 +111,9 @@
"type": "package",
"package": {
"name": "setasign/fpdf",
"version": "1.53",
"version": "1.6",
"dist": {
"url": "http://www.fpdf.org/en/dl.php?v=153&f=zip",
"url": "http://www.fpdf.org/en/dl.php?v=16&f=zip",
"type": "zip"
},
"autoload": {
Expand Down
7 changes: 4 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
parameters:
phpVersion: 70400 # PHP 7.4
level: 1
paths:
- sources
scanFiles:
- dependencies/magpierss/extlib/Snoopy.class.inc
- dependencies/magpierss/rss_cache.inc
- dependencies/magpierss/rss_fetch.inc
- dependencies/magpierss/rss_parse.inc
- dependencies/magpierss/rss_utils.inc
excludePaths:
analyse:
# Ces fichiers utilisent des alias de classes
- sources/AppBundle/Twig/AssetsExtension.php
- sources/AppBundle/Twig/TwigExtension.php
# Ce fichier est impossible à analyser, des variables globales, du eval, etc.
- sources/Afup/Utils/Configuration.php
ignoreErrors:
# Variable globale
-
message: '#Undefined variable: \$configuration#'
path: sources/Afup/Utils/SymfonyKernel.php
# Variable globale
-
message: '#Undefined variable: \$smarty#'
path: sources/AppBundle/Controller/LegacyController.php

0 comments on commit 375bfdc

Please sign in to comment.