|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +env: |
| 8 | + COVERAGE: '1' |
| 9 | + php_extensions: 'json, iconv, intl, json, mbstring, opcache, openssl, pcntl, pcov, posix, redis, session, simplexml, sockets, tokenizer, xml, xmlwriter, zip' |
| 10 | + key: cache-v0.1 |
| 11 | + |
| 12 | +jobs: |
| 13 | + lint: |
| 14 | + runs-on: '${{ matrix.operating_system }}' |
| 15 | + timeout-minutes: 20 |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + operating_system: |
| 19 | + - ubuntu-latest |
| 20 | + php_versions: |
| 21 | + - '7.4' |
| 22 | + fail-fast: false |
| 23 | + env: |
| 24 | + PHP_CS_FIXER_FUTURE_MODE: '0' |
| 25 | + name: 'Lint PHP' |
| 26 | + steps: |
| 27 | + - name: 'Checkout' |
| 28 | + uses: actions/checkout@v2 |
| 29 | + - name: 'Setup cache environment' |
| 30 | + id: cache-env |
| 31 | + uses: shivammathur/cache-extensions@v1 |
| 32 | + with: |
| 33 | + php-version: '${{ matrix.php_versions }}' |
| 34 | + extensions: '${{ env.php_extensions }}' |
| 35 | + key: '${{ env.key }}' |
| 36 | + - name: 'Cache extensions' |
| 37 | + uses: actions/cache@v1 |
| 38 | + with: |
| 39 | + path: '${{ steps.cache-env.outputs.dir }}' |
| 40 | + key: '${{ steps.cache-env.outputs.key }}' |
| 41 | + restore-keys: '${{ steps.cache-env.outputs.key }}' |
| 42 | + - name: 'Setup PHP' |
| 43 | + uses: shivammathur/setup-php@v2 |
| 44 | + with: |
| 45 | + php-version: ${{ matrix.php_versions }} |
| 46 | + extensions: '${{ env.php_extensions }}' |
| 47 | + ini-values: memory_limit=-1 |
| 48 | + tools: pecl, composer |
| 49 | + coverage: none |
| 50 | + - name: 'Setup problem matchers for PHP (aka PHP error logs)' |
| 51 | + run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' |
| 52 | + - name: 'Setup problem matchers for PHPUnit' |
| 53 | + run: 'echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"' |
| 54 | + - name: 'Install PHP dependencies with Composer' |
| 55 | + run: | |
| 56 | + rm composer.lock |
| 57 | + composer install --prefer-dist --no-progress --no-suggest --optimize-autoloader |
| 58 | + working-directory: './' |
| 59 | + - name: 'Linting PHP source files' |
| 60 | + run: 'vendor/bin/ecs check --config=ecs.yml .' |
| 61 | + test: |
| 62 | + strategy: |
| 63 | + fail-fast: false |
| 64 | + matrix: |
| 65 | + experimental: |
| 66 | + - false |
| 67 | + operating_system: |
| 68 | + - ubuntu-latest |
| 69 | + redis_version: |
| 70 | + - '4.0' |
| 71 | + - '5.0' |
| 72 | + - '6.0' |
| 73 | + php_versions: |
| 74 | + - '7.3' |
| 75 | + - '7.4' |
| 76 | + include: |
| 77 | + - operating_system: ubuntu-latest |
| 78 | + redis_version: '6.0' |
| 79 | + php_versions: '8.0' |
| 80 | + experimental: true |
| 81 | + runs-on: '${{ matrix.operating_system }}' |
| 82 | + services: |
| 83 | + redis: |
| 84 | + image: redis:${{ matrix.redis_version }} |
| 85 | + ports: |
| 86 | + - 6379:6379 |
| 87 | + options: >- |
| 88 | + --health-cmd "redis-cli ping" |
| 89 | + --health-interval 10s |
| 90 | + --health-timeout 5s |
| 91 | + --health-retries 5 |
| 92 | + name: 'Test / PHP ${{ matrix.php_versions }} with Redis ${{ matrix.redis_version }}' |
| 93 | + continue-on-error: ${{ matrix.php_versions == '8.0' }} |
| 94 | + needs: |
| 95 | + - lint |
| 96 | + steps: |
| 97 | + - name: Checkout |
| 98 | + uses: actions/checkout@v2 |
| 99 | + with: |
| 100 | + fetch-depth: 1 |
| 101 | + - name: 'Setup cache environment' |
| 102 | + id: cache-env |
| 103 | + uses: shivammathur/cache-extensions@v1 |
| 104 | + with: |
| 105 | + php-version: ${{ matrix.php_versions }} |
| 106 | + extensions: ${{ env.php_extensions }} |
| 107 | + key: '${{ env.key }}' |
| 108 | + - name: 'Cache extensions' |
| 109 | + uses: actions/cache@v1 |
| 110 | + with: |
| 111 | + path: '${{ steps.cache-env.outputs.dir }}' |
| 112 | + key: '${{ steps.cache-env.outputs.key }}' |
| 113 | + restore-keys: '${{ steps.cache-env.outputs.key }}' |
| 114 | + - name: 'Setup PHP' |
| 115 | + uses: shivammathur/setup-php@v2 |
| 116 | + with: |
| 117 | + php-version: ${{ matrix.php_versions }} |
| 118 | + extensions: ${{ env.php_extensions }} |
| 119 | + ini-values: 'pcov.directory=src, date.timezone=UTC, upload_max_filesize=20M, post_max_size=20M, memory_limit=512M, short_open_tag=Off' |
| 120 | + coverage: pcov |
| 121 | + tools: 'phpunit' |
| 122 | + - name: Setup redis |
| 123 | + uses: shogo82148/actions-setup-redis@v1 |
| 124 | + with: |
| 125 | + redis-version: ${{ matrix.redis_version }} |
| 126 | + auto-start: "true" |
| 127 | + - name: 'Install PHP dependencies with Composer' |
| 128 | + run: | |
| 129 | + rm composer.lock |
| 130 | + composer install --prefer-dist --no-progress --no-suggest --optimize-autoloader |
| 131 | + working-directory: './' |
| 132 | + - name: 'Run Unit Tests with PHPUnit' |
| 133 | + continue-on-error: ${{ matrix.experimental }} |
| 134 | + env: |
| 135 | + REDIS_HOST: 127.0.0.1 |
| 136 | + REDIS_PORT: 6379 |
| 137 | + run: | |
| 138 | + ./vendor/bin/phpunit --verbose --stderr --configuration phpunit.github.xml --coverage-clover build/logs/clover.xml --coverage-text |
| 139 | + working-directory: './' |
| 140 | + - name: Upload coverage results to Coveralls |
| 141 | + continue-on-error: ${{ matrix.experimental }} |
| 142 | + env: |
| 143 | + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 144 | + COVERALLS_PARALLEL: true |
| 145 | + COVERALLS_FLAG_NAME: php-${{ matrix.php-versions }}-redis-${{ matrix.redis-version }} |
| 146 | + run: ./vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v |
| 147 | + coverage: |
| 148 | + needs: test |
| 149 | + runs-on: ubuntu-latest |
| 150 | + name: "Code coverage" |
| 151 | + steps: |
| 152 | + - name: Coveralls Finished |
| 153 | + uses: coverallsapp/github-action@v1.1.2 |
| 154 | + with: |
| 155 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 156 | + parallel-finished: true |
0 commit comments