jbboehr/laravel-blade-linter

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
name: ci

on:
    push:
        branches:
            - master
            - develop
    pull_request:
        branches:
            - master

jobs:
    lint:
        runs-on: ubuntu-latest
        name: "Lint | PHP ${{ matrix.php-version }}"
        strategy:
            matrix:
                php-version:
                    - "8.0"
                    - "8.1"
                    - "8.2"
        steps:
            - uses: actions/checkout@v3

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

            - name: Validate composer.json and composer.lock
              run: composer validate

            - name: Cache Composer packages
              id: composer-cache
              uses: actions/cache@v3
              with:
                  path: vendor
                  key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
                  restore-keys: |
                      ${{ runner.os }}-php-

            - name: Install dependencies
              run: composer install --prefer-dist --no-progress

            - name: phpcs
              run: php vendor/bin/phpcs

            - name: phpstan
              run: php vendor/bin/phpstan analyze

    test:
        runs-on: ubuntu-latest
        name: "Test | PHP ${{ matrix.php-version }}"
        strategy:
            matrix:
                php-version:
                    - "8.0"
                    - "8.1"
                    - "8.2"
        steps:
            - uses: actions/checkout@v3

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

            - name: Setup BATS
              uses: mig4/setup-bats@v1
              with:
                  bats-version: 1.8.2

            - name: Cache Composer packages
              id: composer-cache
              uses: actions/cache@v3
              with:
                  path: vendor
                  key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
                  restore-keys: |
                      ${{ runner.os }}-php-

            - name: Install dependencies
              run: composer install --prefer-dist --no-progress

            - name: Run test suite
              run: php vendor/bin/phpunit

            - name: Run BATS test suite
              run: bats -r tests

    coverage:
        runs-on: ubuntu-latest
        name: "Coverage | PHP ${{ matrix.php-version }}"
        strategy:
            matrix:
                php-version:
                    - "8.2"
        steps:
            - uses: actions/checkout@v3

            - name: Install PHP
              uses: shivammathur/setup-php@v2
              with:
                  coverage: pcov
                  php-version: "${{ matrix.php-version }}"
                  tools: composer:v2

            - name: Cache Composer packages
              id: composer-cache
              uses: actions/cache@v3
              with:
                  path: vendor
                  key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
                  restore-keys: |
                      ${{ runner.os }}-php-

            - name: Install dependencies
              run: composer install --prefer-dist --no-progress

            - name: Run test suite with coverage
              run: php vendor/bin/phpunit --coverage-text --coverage-clover=build/logs/clover.xml

            - name: Upload code coverage
              # https://github.com/paambaati/codeclimate-action/issues/638#issuecomment-1363476627
              uses: paambaati/codeclimate-action@v3.2.0
              env:
                  CC_TEST_REPORTER_ID: 5e69f83b32c4968b77d6c542803258d9b2b53486e746056499625d90cbcad228
              with:
                  coverageCommand: "true"
                  coverageLocations: |
                    build/logs/clover.xml:clover

    nix:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v3

            - uses: cachix/install-nix-action@v18
              with:
                  nix_path: nixpkgs=channel:nixos-22.11

            - run: nix build -L

            - run: nix flake check -L