AJenbo/agcms

View on GitHub
.github/workflows/test.yml

Summary

Maintainability
Test Coverage
name: Test

on:
  push:
    branches: [ "master" ]
  pull_request:
    types: [ "opened", "synchronize" ]

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php: [ '8.1', '8.2' ]

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 2

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

      - name: Get Cache
        id: composer-cache
        uses: actions/cache@v3
        with:
          path: |
            application/vendor
            ./.php-cs-fixer.cache
          key: composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: composer-

      - name: Install dependencies
        working-directory: ./application
        run: composer install

      - name: PHPStan
        working-directory: ./application
        run: vendor/bin/phpstan

      - name: PHPUnit
        run: application/vendor/bin/phpunit --printer mheap\\GithubActionsReporter\\Printer

      - name: Code style
        if: matrix.php == '8.1'
        run: |
         application/vendor/bin/php-cs-fixer fix --dry-run --diff --ansi || true
         application/vendor/bin/php-cs-fixer fix --dry-run --format=checkstyle | cs2pr

      - name: Upload Code Coverage To Scrutinizer
        run: |
          composer require scrutinizer/ocular --no-interaction --dev
          vendor/bin/ocular code-coverage:upload --format=php-clover build/logs/clover.xml

      - name: Upload coverage to Coveralls
        if: matrix.php == '8.1'
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: application/vendor/bin/php-coveralls

      - name: Upload coverage to Codecov
        if: matrix.php == '8.1'
        uses: codecov/codecov-action@v3

      - name: Upload coverage to Codacy
        if: matrix.php == '8.1'
        uses: codacy/codacy-coverage-reporter-action@v1.3.0
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: build/logs/clover.xml

      - name: Upload coverage to Codeclimate
        if: matrix.php == '8.1'
        uses: paambaati/codeclimate-action@v3.2.0
        env:
          CC_TEST_REPORTER_ID: dded30dc4b62f393c80ed752f13c7c7efaf748c3573daee0f4040615457ff9c0