fapi-cz/php-client

View on GitHub
.github/workflows/main.yml

Summary

Maintainability
Test Coverage
name: 'build'

on:
  pull_request:
    branches:
      - master
  push:
    branches:
      - 'master'

env:
  extensions: 'json'
  cache-version: '1'
  composer-version: 'v2'
  composer-install: 'composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-stable'

jobs:
  coding_style:
    name: 'Coding style'
    runs-on: '${{ matrix.operating-system }}'

    strategy:
      matrix:
        php-version: [ '8.1', '8.2' ]
        operating-system: [ 'ubuntu-latest' ]
      fail-fast: false

    steps:
      - name: 'Checkout'
        uses: 'actions/checkout@v2'

      - name: 'Setup PHP cache environment'
        id: 'extcache'
        uses: 'shivammathur/cache-extensions@v1'
        with:
          php-version: '${{ matrix.php-version }}'
          extensions: '${{ env.extensions }}'
          key: '${{ env.cache-version }}'

      - name: 'Cache PHP extensions'
        uses: 'actions/cache@v2'
        with:
          path: '${{ steps.extcache.outputs.dir }}'
          key: '${{ steps.extcache.outputs.key }}'
          restore-keys: '${{ steps.extcache.outputs.key }}'

      - name: 'Install PHP'
        uses: 'shivammathur/setup-php@v2'
        with:
          php-version: '${{ matrix.php-version }}'
          extensions: '${{ env.extensions }}'
          tools: 'composer:${{ env.composer-version }}'

      - name: "Setup problem matchers for PHP"
        run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'

      - name: 'Get Composer cache directory'
        id: 'composercache'
        run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'

      - name: 'Cache PHP dependencies'
        uses: "actions/cache@v2"
        with:
          path: '${{ steps.composercache.outputs.dir }}'
          key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
          restore-keys: '${{ runner.os }}-composer-'

      - name: 'Validate Composer'
        run: 'composer validate'

      - name: 'Install dependencies'
        run: '${{ env.composer-install }}'

      - name: 'Coding Standard'
        run: 'bin/cs'

  php_stan:
    name: 'PHP Stan'
    runs-on: '${{ matrix.operating-system }}'

    strategy:
      matrix:
        php-version: [ '8.1', '8.2' ]
        operating-system: [ 'ubuntu-latest' ]
      fail-fast: false

    steps:
      - name: 'Checkout'
        uses: 'actions/checkout@v2'

      - name: 'Setup PHP cache environment'
        id: 'extcache'
        uses: 'shivammathur/cache-extensions@v1'
        with:
          php-version: '${{ matrix.php-version }}'
          extensions: '${{ env.extensions }}'
          key: '${{ env.cache-version }}'

      - name: 'Cache PHP extensions'
        uses: 'actions/cache@v2'
        with:
          path: '${{ steps.extcache.outputs.dir }}'
          key: '${{ steps.extcache.outputs.key }}'
          restore-keys: '${{ steps.extcache.outputs.key }}'

      - name: 'Install PHP'
        uses: 'shivammathur/setup-php@v2'
        with:
          php-version: '${{ matrix.php-version }}'
          extensions: '${{ env.extensions }}'
          tools: 'composer:${{ env.composer-version }}'

      - name: 'Setup problem matchers for PHP'
        run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'

      - name: 'Get Composer cache directory'
        id: 'composercache'
        run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'

      - name: 'Cache PHP dependencies'
        uses: 'actions/cache@v2'
        with:
          path: '${{ steps.composercache.outputs.dir }}'
          key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
          restore-keys: '${{ runner.os }}-composer-'

      - name: 'Install dependencies'
        run: '${{ env.composer-install }}'

      - name: 'PHPStan'
        run: 'bin/stan'

  tests:
    name: 'Tests'
    runs-on: '${{ matrix.operating-system }}'

    strategy:
      matrix:
        php-version: [ '8.1', '8.2' ]
        operating-system: [ 'ubuntu-latest' ]
        composer-args: [ '' ]

      fail-fast: false

    steps:
      - name: 'Checkout'
        uses: 'actions/checkout@v2'

      - name: 'Setup PHP cache environment'
        id: 'extcache'
        uses: 'shivammathur/cache-extensions@v1'
        with:
          php-version: '${{ matrix.php-version }}'
          extensions: '${{ env.extensions }}'
          key: '${{ env.cache-version }}'

      - name: 'Cache PHP extensions'
        uses: 'actions/cache@v2'
        with:
          path: '${{ steps.extcache.outputs.dir }}'
          key: '${{ steps.extcache.outputs.key }}'
          restore-keys: '${{ steps.extcache.outputs.key }}'

      - name: 'Install PHP'
        uses: 'shivammathur/setup-php@v2'
        with:
          php-version: '${{ matrix.php-version }}'
          extensions: '${{ env.extensions }}'
          tools: 'composer:${{ env.composer-version }}'

      - name: 'Setup problem matchers for PHP'
        run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'

      - name: 'Get Composer cache directory'
        id: 'composercache'
        run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'

      - name: 'Cache PHP dependencies'
        uses: 'actions/cache@v2'
        with:
          path: '${{ steps.composercache.outputs.dir }}'
          key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
          restore-keys: '${{ runner.os }}-composer-'

      - name: 'Install dependencies'
        run: '${{ env.composer-install }} ${{ matrix.composer-args }}'

      - name: 'Tests'
        run: 'vendor/bin/tester tests -C'

  tests_code_coverage:
    name: 'Tests with code coverage'
    runs-on: '${{ matrix.operating-system }}'

    strategy:
      matrix:
        php-version: [ '8.1', '8.2' ]
        operating-system: [ 'ubuntu-latest' ]
      fail-fast: false

    if: "github.event_name == 'push'"

    steps:
      - name: 'Checkout'
        uses: 'actions/checkout@v2'

      - name: 'Setup PHP cache environment'
        id: 'extcache'
        uses: 'shivammathur/cache-extensions@v1'
        with:
          php-version: '${{ matrix.php-version }}'
          extensions: '${{ env.extensions }}'
          key: '${{ env.cache-version }}'

      - name: 'Cache PHP extensions'
        uses: 'actions/cache@v2'
        with:
          path: '${{ steps.extcache.outputs.dir }}'
          key: '${{ steps.extcache.outputs.key }}'
          restore-keys: '${{ steps.extcache.outputs.key }}'

      - name: 'Install PHP'
        uses: 'shivammathur/setup-php@v2'
        with:
          php-version: '${{ matrix.php-version }}'
          extensions: '${{ env.extensions }}'
          tools: 'composer:${{ env.composer-version }}'

      - name: 'Setup problem matchers for PHP'
        run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'

      - name: 'Get Composer cache directory'
        id: 'composercache'
        run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'

      - name: 'Cache PHP dependencies'
        uses: 'actions/cache@v2'
        with:
          path: '${{ steps.composercache.outputs.dir }}'
          key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
          restore-keys: '${{ runner.os }}-composer-'

      - name: 'Install dependencies'
        run: '${{ env.composer-install }}'

      - name: 'Tests'
        run: vendor/bin/tester tests -C --coverage coverage.xml --coverage-src src

      - uses: codecov/codecov-action@v1
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          fail_ci_if_error: true