|
| 1 | +# https://help.github.com/en/categories/automating-your-workflow-with-github-actions |
| 2 | +# https://github.com/sebastianbergmann/phpunit/blob/master/.github/workflows/ci.yml |
| 3 | + |
| 4 | +on: |
| 5 | + - pull_request |
| 6 | + - push |
| 7 | + |
| 8 | +name: "Continuous Integration" |
| 9 | + |
| 10 | +jobs: |
| 11 | + |
| 12 | + static-code-analysis: |
| 13 | + name: "Static Code Analysis" |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: "Checkout" |
| 19 | + uses: actions/checkout@v2 |
| 20 | + |
| 21 | + - name: "Install PHP" |
| 22 | + uses: shivammathur/setup-php@v2 |
| 23 | + with: |
| 24 | + php-version: "7.4" |
| 25 | + tools: pecl |
| 26 | + coverage: none |
| 27 | + extensions: ast, curl, json, simplexml, zlib |
| 28 | + |
| 29 | + - name: "Update dependencies with composer" |
| 30 | + run: composer update --no-interaction --no-ansi --no-progress --no-suggest |
| 31 | + |
| 32 | + - name: "phan env" |
| 33 | + run: | |
| 34 | + echo "PHAN_ALLOW_XDEBUG=0" >> $GITHUB_ENV |
| 35 | + echo "PHAN_DISABLE_XDEBUG_WARN=1" >> $GITHUB_ENV |
| 36 | +
|
| 37 | + - name: "Run phan" |
| 38 | + run: php vendor/bin/phan |
| 39 | + |
| 40 | + tests: |
| 41 | + name: "Unit Tests" |
| 42 | + |
| 43 | + runs-on: ${{ matrix.os }} |
| 44 | + |
| 45 | + strategy: |
| 46 | + fail-fast: false |
| 47 | + matrix: |
| 48 | + os: |
| 49 | + - ubuntu-latest |
| 50 | + - windows-latest |
| 51 | + php-version: |
| 52 | + - "7.4" |
| 53 | + - "8.0" |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: "Configure git to avoid issues with line endings" |
| 57 | + if: matrix.os == 'windows-latest' |
| 58 | + run: git config --global core.autocrlf false |
| 59 | + |
| 60 | + - name: "Checkout" |
| 61 | + uses: actions/checkout@v2 |
| 62 | + |
| 63 | + - name: "Fetch cacert.pem from curl.haxx.se" |
| 64 | + run: curl -o tests/cacert.pem https://curl.haxx.se/ca/cacert.pem |
| 65 | + |
| 66 | + - name: "Install PHP with extensions" |
| 67 | + uses: shivammathur/setup-php@v2 |
| 68 | + with: |
| 69 | + php-version: ${{ matrix.php-version }} |
| 70 | + coverage: pcov |
| 71 | + extensions: curl, json, simplexml, zlib |
| 72 | +# ini-values: |
| 73 | + |
| 74 | + - name: "Determine composer cache directory on Linux" |
| 75 | + if: matrix.os == 'ubuntu-latest' |
| 76 | + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV |
| 77 | + |
| 78 | + - name: "Determine composer cache directory on Windows" |
| 79 | + if: matrix.os == 'windows-latest' |
| 80 | + run: echo "COMPOSER_CACHE_DIR=%LOCALAPPDATA%\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 81 | + |
| 82 | + - name: "Cache dependencies installed with composer" |
| 83 | + uses: actions/cache@v2 |
| 84 | + with: |
| 85 | + path: ${{ env.COMPOSER_CACHE_DIR }} |
| 86 | + key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }} |
| 87 | + restore-keys: php${{ matrix.php-version }}-composer- |
| 88 | + |
| 89 | + - name: "Install dependencies with composer" |
| 90 | + run: composer update --no-ansi --no-interaction --no-progress --no-suggest |
| 91 | + |
| 92 | + - name: "Run tests with phpunit" |
| 93 | + run: php vendor/phpunit/phpunit/phpunit --configuration=phpunit.xml.dist |
| 94 | + |
| 95 | + - name: "Send code coverage report to Codecov.io" |
| 96 | + uses: codecov/codecov-action@v1 |
| 97 | + with: |
| 98 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments