Skip to content

Lint

Lint #23

Workflow file for this run

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: "Lint"
#
# Based on workflows from Composer:
#
# * https://github.com/composer/composer/blob/2.5.4/.github/workflows/lint.yml
# * https://github.com/composer/composer/blob/2.5.4/.github/workflows/phpstan.yml
#
on:
workflow_dispatch:
push:
tags-ignore:
- '**'
pull_request:
tags-ignore:
- '**'
env:
COMPOSER_FLAGS: "--ansi --no-interaction --prefer-dist"
SYMFONY_PHPUNIT_VERSION: ""
permissions:
contents: read
jobs:
validation:
name: "Composer Validation"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "intl, zip"
ini-values: "memory_limit=-1, phar.readonly=0, error_reporting=E_ALL, display_errors=On"
php-version: "latest"
- name: "Install dependencies from composer.lock"
run: "composer install ${{ env.COMPOSER_FLAGS }}"
- name: "Validate composer.json"
run: "composer validate --strict"
lint:
name: "Lint"
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "7.2"
- "8.3"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "intl, zip"
ini-values: "memory_limit=-1, error_reporting=E_ALL, display_errors=On"
php-version: "${{ matrix.php-version }}"
tools: cs2pr
- name: Retrieve Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: "Cache dependencies installed with Composer"
uses: "actions/cache@v4"
with:
path: "${{ steps.composer-cache.outputs.dir }}"
key: "php-${{ matrix.php-version }}-symfony-php-unit-version-${{ env.SYMFONY_PHPUNIT_VERSION }}-${{ hashFiles('**/composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-symfony-php-unit-version-${{ env.SYMFONY_PHPUNIT_VERSION }}"
- name: "Update dependencies from composer.json"
if: "matrix.experimental == true"
run: "composer config platform --unset && composer update ${{ env.COMPOSER_FLAGS }}"
- name: "Install dependencies from composer.lock"
if: "matrix.experimental == false"
run: "composer config platform --unset && composer install ${{ env.COMPOSER_FLAGS }}"
- name: Install PHPUnit
run: "./vendor/bin/simple-phpunit install"
- name: "Lint PHP files"
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"
- name: "Run PHPStan"
run: "./vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"