|
| 1 | +# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions |
| 2 | + |
| 3 | +on: |
| 4 | + # Run on every commit. |
| 5 | + - push |
| 6 | + # Allow manually triggering the workflow. |
| 7 | + - workflow_dispatch |
| 8 | + |
| 9 | +# Cancels all previous workflow runs for the same branch that have not yet completed. |
| 10 | +concurrency: |
| 11 | + # The concurrency group contains the workflow name and the branch name. |
| 12 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +name: CI |
| 16 | + |
| 17 | +jobs: |
| 18 | + static-analysis: |
| 19 | + name: Static Analysis |
| 20 | + |
| 21 | + timeout-minutes: 5 |
| 22 | + |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + test-type: [phpcs, phpstan] |
| 29 | + |
| 30 | + env: |
| 31 | + COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v2 |
| 36 | + |
| 37 | + - name: Setup PHP |
| 38 | + uses: shivammathur/setup-php@v2 |
| 39 | + with: |
| 40 | + php-version: 8.1 |
| 41 | + # Colon means remove |
| 42 | + extensions: :apcu, :imagick |
| 43 | + coverage: none |
| 44 | + tools: none |
| 45 | + env: |
| 46 | + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + |
| 48 | + - name: Install composer dependencies |
| 49 | + run: composer update --no-interaction --no-ansi --no-progress --optimize-autoloader |
| 50 | + |
| 51 | + - name: Test with ${{ matrix.test-type }} |
| 52 | + run: composer test:${{ matrix.test-type }} |
| 53 | + |
| 54 | + tests: |
| 55 | + name: Tests |
| 56 | + |
| 57 | + timeout-minutes: 5 |
| 58 | + |
| 59 | + needs: static-analysis |
| 60 | + |
| 61 | + runs-on: ${{ matrix.os }} |
| 62 | + |
| 63 | + strategy: |
| 64 | + fail-fast: false |
| 65 | + matrix: |
| 66 | + os: [macos-latest, ubuntu-latest, windows-latest] |
| 67 | + test-type: [unit, integration] |
| 68 | + php-version: ['7.2', '7.3', '7.4', '8.0', '8.1'] |
| 69 | + dependencies: [lowest, highest] |
| 70 | + exclude: |
| 71 | + - test-type: unit |
| 72 | + dependencies: lowest |
| 73 | + os: macos-latest |
| 74 | + - test-type: unit |
| 75 | + dependencies: lowest |
| 76 | + os: windows-latest |
| 77 | + - test-type: integration |
| 78 | + os: macos-latest |
| 79 | + - test-type: integration |
| 80 | + os: windows-latest |
| 81 | + |
| 82 | + env: |
| 83 | + COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} |
| 84 | + |
| 85 | + steps: |
| 86 | + - name: Checkout |
| 87 | + uses: actions/checkout@v2 |
| 88 | + |
| 89 | + - name: Setup node |
| 90 | + if: matrix.test-type == 'integration' |
| 91 | + uses: actions/setup-node@v2 |
| 92 | + with: |
| 93 | + node-version: '16' |
| 94 | + |
| 95 | + - name: Install and run @stoplight/prism |
| 96 | + if: matrix.test-type == 'integration' |
| 97 | + run: | |
| 98 | + npm install -g @stoplight/prism-cli |
| 99 | + prism mock tests/openapi.yaml >artifacts/prism.log 2>&1 & |
| 100 | +
|
| 101 | + - name: Setup PHP |
| 102 | + uses: shivammathur/setup-php@v2 |
| 103 | + with: |
| 104 | + php-version: ${{ matrix.php-version }} |
| 105 | + coverage: none |
| 106 | + extensions: ctype, json, mbstring, simplexml, tokenizer, xmlwriter, :apcu, :imagick |
| 107 | + ini-values: memory_limit=-1, assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On |
| 108 | + tools: none |
| 109 | + |
| 110 | + - name: Install lowest dependencies with composer |
| 111 | + if: matrix.dependencies == 'lowest' |
| 112 | + run: composer update --no-interaction --no-ansi --no-progress --prefer-lowest --optimize-autoloader |
| 113 | + |
| 114 | + - name: Install highest dependencies with composer |
| 115 | + if: matrix.dependencies == 'highest' |
| 116 | + run: composer update --no-interaction --no-ansi --no-progress --optimize-autoloader |
| 117 | + |
| 118 | + - name: Test ${{ matrix.test-type }} with phpunit |
| 119 | + run: composer test:${{ matrix.test-type }} -- --testdox |
| 120 | + |
| 121 | + - name: Upload prism log |
| 122 | + if: matrix.test-type == 'integration' |
| 123 | + uses: actions/upload-artifact@v3 |
| 124 | + with: |
| 125 | + name: ${{ github.event.repository.name }}-prism.log |
| 126 | + path: artifacts/prism.log |
| 127 | + |
| 128 | + coverage: |
| 129 | + name: Coverage |
| 130 | + |
| 131 | + timeout-minutes: 5 |
| 132 | + |
| 133 | + needs: tests |
| 134 | + |
| 135 | + runs-on: ubuntu-latest |
| 136 | + |
| 137 | + env: |
| 138 | + COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} |
| 139 | + |
| 140 | + steps: |
| 141 | + - name: Checkout |
| 142 | + uses: actions/checkout@v2 |
| 143 | + |
| 144 | + - name: Setup node |
| 145 | + uses: actions/setup-node@v2 |
| 146 | + with: |
| 147 | + node-version: '16' |
| 148 | + |
| 149 | + - name: Install and run @stoplight/prism |
| 150 | + run: | |
| 151 | + npm install -g @stoplight/prism-cli |
| 152 | + prism mock tests/openapi.yaml & |
| 153 | +
|
| 154 | + - name: Setup PHP |
| 155 | + uses: shivammathur/setup-php@v2 |
| 156 | + with: |
| 157 | + php-version: 8.1 |
| 158 | + coverage: xdebug |
| 159 | + extensions: ctype, json, mbstring, simplexml, tokenizer, xmlwriter, :apcu, :imagick |
| 160 | + ini-values: memory_limit=-1, assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On |
| 161 | + tools: none |
| 162 | + |
| 163 | + - name: Install composer dependencies |
| 164 | + run: composer update --no-interaction --no-ansi --no-progress --optimize-autoloader |
| 165 | + |
| 166 | + - name: Test coverage with phpunit |
| 167 | + run: composer test:coverage |
| 168 | + |
| 169 | + - name: Upload code coverage results |
| 170 | + uses: actions/upload-artifact@v3 |
| 171 | + with: |
| 172 | + name: ${{ github.event.repository.name }}-coverage-report |
| 173 | + path: coverage/ |
| 174 | + |
| 175 | + - name: Upload artifacts |
| 176 | + uses: actions/upload-artifact@v3 |
| 177 | + with: |
| 178 | + name: ${{ github.event.repository.name }}-artifacts |
| 179 | + path: artifacts/ |
0 commit comments