From 1b6006c1689030c1c1e7a74bdcbe34b9da1cdab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Dec 2023 18:25:19 +0100 Subject: [PATCH] QUAL phpstan github action --- .gitattributes | 3 +- .github/workflows/phpstan.yml | 60 +++++++++++++++ build/phpstan/bootstrap_action.php | 13 ++++ phpstan_action.neon | 118 +++++++++++++++++++++++++++++ tmp/.gitkeep | 0 5 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/phpstan.yml create mode 100644 build/phpstan/bootstrap_action.php create mode 100644 phpstan_action.neon create mode 100644 tmp/.gitkeep diff --git a/.gitattributes b/.gitattributes index de9ce3303a9..37e320f933d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,7 +3,7 @@ * text=auto -# Explicitly declare text files we want to always be normalized and converted +# Explicitly declare text files we want to always be normalized and converted # to native line endings on checkout. *.php text eol=lf *.pl text eol=lf @@ -21,6 +21,7 @@ *.yml text eol=lf *.yaml text eol=lf *.conf text eol=lf +*.neon text eol=lf .bash_aliases text eol=lf diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 00000000000..ac3f6fc79f2 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,60 @@ +# This is a basic workflow to check code with PHPSTAN tool + +name: PHPSTAN + +# Controls when the workflow will run +on: + # Triggers the workflow on pull request events but only for the develop branch + pull_request: + branches: [ develop ] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-version: + - "7.1" + - "8.2" + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup PHP + id: setup-php + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php-version }}" + tools: phpstan, cs2pr + extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap, mysql, pgsql, sqlite3, ldap, xml + - uses: actions/setup-node@v3 + with: + node-version: 14.x + registry-url: 'https://registry.npmjs.org' + - name: Restore phpstan cache + uses: actions/cache/restore@v3 + with: + path: ./tmp + key: "phpstan-cache-PR-${{ matrix.php-version }}-${{ github.run_id }}" + restore-keys: | + phpstan-cache-PR-${{ matrix.php-version }}- + - name: Debug + run: cd ./tmp && ls -al + - name: Run PHPSTAN + run: phpstan -vvv analyse --error-format=checkstyle --memory-limit 4G -c phpstan_action.neon | cs2pr --graceful-warnings + continue-on-error: true + - name: "Save phpstan cache" + uses: actions/cache/save@v3 + if: always() + with: + path: ./tmp + key: "phpstan-cache-PR-${{ matrix.php-version }}-${{ github.run_id }}" diff --git a/build/phpstan/bootstrap_action.php b/build/phpstan/bootstrap_action.php new file mode 100644 index 00000000000..f56067d66d8 --- /dev/null +++ b/build/phpstan/bootstrap_action.php @@ -0,0 +1,13 @@ +