yiisoft/yii2

View on GitHub
.github/workflows/build.yml

Summary

Maintainability
Test Coverage
name: build

on: [push, pull_request]

env:
  DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi"
  PHPUNIT_EXCLUDE_GROUP: db,wincache,xcache,zenddata
  XDEBUG_MODE: coverage, develop

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  phpunit:
    name: PHP ${{ matrix.php }}

    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        include:
          - php: 7.3
            extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
            coverage: none
          - php: 7.4
            extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
            coverage: xdebug
          - php: 8.0
            extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
            coverage: none
          - php: 8.1
            extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
            coverage: none
          - php: 8.2
            extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
            coverage: none
          - php: 8.3
            extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
            coverage: none
            os: ubuntu-latest
          - php: 8.4
            extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
            coverage: none
            os: ubuntu-latest

    steps:
      - name: Generate french locale.
        run: sudo locale-gen fr_FR.UTF-8

      - name: Checkout.
        uses: actions/checkout@v4

      - name: Install PHP.
        uses: shivammathur/setup-php@v2
        with:
          coverage: ${{ matrix.coverage }}
          extensions: ${{ matrix.extensions }}
          ini-values: apc.enabled=1,apc.shm_size=32M,apc.enable_cli=1, date.timezone='UTC', session.save_path="${{ runner.temp }}"
          php-version: ${{ matrix.php }}
          tools: pecl

      - name: Install Memcached.
        uses: niden/actions-memcached@v7

      - name: Install dependencies.
        if: matrix.php != '8.4'
        run: composer update $DEFAULT_COMPOSER_FLAGS

      - name: Install dependencies with PHP 8.4.
        if: matrix.php == '8.4'
        run: composer update $DEFAULT_COMPOSER_FLAGS --ignore-platform-reqs

      - name: Run tests with PHPUnit and generate coverage.
        if: matrix.php == '7.4'
        run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP --coverage-clover=coverage.xml --colors=always

      - name: Run tests with PHPUnit.
        if: matrix.php != '7.4'
        run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP --colors=always

      - name: Upload coverage to Codecov.
        if: matrix.php == '7.4'
        uses: codecov/codecov-action@v3
        with:
          file: ./coverage.xml