From 2a0e088c3868d041d524bf8c628bf0408acb9048 Mon Sep 17 00:00:00 2001 From: Vincent Amstoutz Date: Sat, 8 Feb 2025 16:06:45 +0100 Subject: [PATCH] chore(ci): add a lint job --- .github/workflows/lint.yaml | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..5e5e05a --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,82 @@ +name: Lint + +on: + push: + pull_request: + +env: + fail-fast: true + +permissions: + contents: read + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + strategy: + matrix: + operating-system: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ] + php-versions: [ '8.3', '8.4' ] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup PHP with quality tools + uses: shivammathur/setup-php@v2 + + #TODO: extensions and caching if we use them + with: + php-version: ${{ matrix.php-versions }} + tools: composer, php-cs-fixer, rector, phpstan + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Lint composer + run: composer validate --strict + + - name: Install dependencies + run: composer install --prefer-dist + + - name: Composer normalize + run: composer normalize --dry-run + + - name: Composer audit + run: composer audit + + - name: Lint YAML files + run: php bin/console lint:yaml config/ src/ --parse-tags --env=prod + + - name: Lint Twig templates + run: php bin/console lint:twig templates/ --env=prod + + - name: Lint Parameters and Services + run: php bin/console lint:container --no-debug --env=prod + + - name: Lint Doctrine entities + run: php bin/console doctrine:schema:validate --skip-sync -vvv --no-interaction --env=prod + + - name: Setup PHP Code Quality Tools + run: composer run install-tools + + - name: Lint PHP files (CS) + run: composer run fix-cs -- --dry-run --diff --using-cache=no --stop-on-violation --show-progress=bar + + - name: Static analysis on PHP files + run: composer run phpstan -- -n + + - name: Lint with Rector + run: composer run rector -- -n --no-cache + + #TODO: lint MD files, lint JS & CSS \ No newline at end of file