|
| 1 | +name: 'CI' |
| 2 | +on: # Build any PRs and main branch changes |
| 3 | + workflow_dispatch: # Allows to run the workflow manually from the Actions tab |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - edited |
| 8 | + - synchronize |
| 9 | + push: |
| 10 | + branches: [ master ] |
| 11 | + schedule: |
| 12 | + - cron: '0 0 1 * *' # Every month |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}" |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +env: |
| 19 | + TEST_OUTPUT_STYLE: pretty |
| 20 | + COMPOSER_OPTIONS: --optimize-autoloader |
| 21 | + CODACY_CACHE_PATH: ~/.cache/codacy |
| 22 | + CODACY_BIN: ~/.cache/codacy/codacy.sh |
| 23 | + |
| 24 | +jobs: |
| 25 | + tests: |
| 26 | + name: UTs & FTs - Symfony ${{ matrix.symfony-version }} |
| 27 | + runs-on: ubuntu-latest |
| 28 | + env: |
| 29 | + COVERAGE_TYPE: none |
| 30 | + strategy: |
| 31 | + fail-fast: true |
| 32 | + max-parallel: 4 |
| 33 | + matrix: |
| 34 | + include: |
| 35 | + # Bare minimum => Lowest versions allowed by composer config |
| 36 | + - symfony-version: '4.4' |
| 37 | + php-version: '8.0' |
| 38 | + composer-flag: --prefer-lowest |
| 39 | + # Up to date versions => Latest versions allowed by composer config |
| 40 | + - symfony-version: '5.4' |
| 41 | + php-version: '8.2' |
| 42 | + # Late symfony migration => Lowest symfony version with latest minor php version allowed by composer config |
| 43 | + - symfony-version: '4.4' |
| 44 | + php-version: '8.2' |
| 45 | + composer-flag: --prefer-lowest |
| 46 | + # Late php migration => Latest symfony version with lowest minor php version allowed by composer config |
| 47 | + - symfony-version: '5.4' |
| 48 | + php-version: '8.0' |
| 49 | + # Symfony 6.0 latest |
| 50 | + - symfony-version: '6.0' |
| 51 | + php-version: '8.2' |
| 52 | + # Symfony 6.0 lowest |
| 53 | + - symfony-version: '6.0' |
| 54 | + php-version: '8.0' |
| 55 | + composer-flag: --prefer-lowest |
| 56 | + steps: |
| 57 | + - name: Check out code |
| 58 | + uses: actions/checkout@v3 |
| 59 | + |
| 60 | + - name: Enable coverage |
| 61 | + if: ${{ matrix.php-version == '8.2' }} |
| 62 | + run: | |
| 63 | + echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV |
| 64 | + echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV |
| 65 | +
|
| 66 | + - name: Setup PHP ${{ matrix.php-version }} |
| 67 | + uses: shivammathur/setup-php@v2 |
| 68 | + with: |
| 69 | + php-version: '${{ matrix.php-version }}' |
| 70 | + tools: composer |
| 71 | + coverage: ${{ env.COVERAGE_TYPE }} |
| 72 | + env: |
| 73 | + # Always use latest available patch for the version |
| 74 | + update: true |
| 75 | + |
| 76 | + - name: Setup cache |
| 77 | + id: cache |
| 78 | + uses: actions/cache@v3 |
| 79 | + with: |
| 80 | + path: | |
| 81 | + ~/.composer |
| 82 | + ./vendor |
| 83 | + ${{ env.CODACY_CACHE_PATH }} |
| 84 | + # Clear the cache if composer json (as composer.lock is in the repo) has been updated |
| 85 | + key: tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }} |
| 86 | + |
| 87 | + - name: Download codacy binary |
| 88 | + if: steps.cache.outputs.cache-hit != 'true' |
| 89 | + run: | |
| 90 | + mkdir -p ${{ env.CODACY_CACHE_PATH }} \ |
| 91 | + && curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \ |
| 92 | + && chmod +x ${{ env.CODACY_BIN }} \ |
| 93 | + && ${{ env.CODACY_BIN }} download |
| 94 | +
|
| 95 | + - name: Build |
| 96 | + run: | |
| 97 | + SF_VERSION=${{ matrix.symfony-version }} |
| 98 | + # Issue with ParamterBag below 4.4.30 => https://github.com/symfony/symfony/commit/3eca446b21607ea1c7a865ece2dd8254c33679cc |
| 99 | + test '${{ matrix.symfony-version }}' = '4.4' && test '${{ matrix.php-version }}' = '8.2' && SF_VERSION=4.4.30 |
| 100 | + composer require -W ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-flag }} \ |
| 101 | + symfony/validator:^$SF_VERSION \ |
| 102 | + && composer update ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-flag }} \ |
| 103 | + && make build |
| 104 | +
|
| 105 | + - name: Tests |
| 106 | + run: make test-unit && make test-functional |
| 107 | + |
| 108 | + # Upload to codacy first as codecov action always remove coverage files despite move_coverage_to_trash at false |
| 109 | + # And only if it's not a PR from a fork => Can't work as codacy secret is not accessible in that context |
| 110 | + - name: Upload coverages to Codacy |
| 111 | + if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/php-jsonrpc-params-symfony-validator-sdk') && env.COVERAGE_TYPE == 'xdebug' }} |
| 112 | + run: ${{ env.CODACY_BIN }} report -r build/coverage-phpunit/unit.clover -r build/coverage-behat/clover.xml -r build/coverage-phpunit/functional.clover -t ${{ secrets.CODACY_PROJECT_TOKEN }} --partial |
| 113 | + |
| 114 | + # See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-params-symfony-validator-sdk |
| 115 | + - name: Upload unit tests coverage to codecov |
| 116 | + if: ${{ env.COVERAGE_TYPE == 'xdebug' }} |
| 117 | + uses: codecov/codecov-action@v3 |
| 118 | + with: |
| 119 | + file: "build/coverage-phpunit/unit.clover" |
| 120 | + name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" |
| 121 | + flags: "unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" |
| 122 | + fail_ci_if_error: true |
| 123 | + move_coverage_to_trash: false |
| 124 | + verbose: ${{ runner.debug == '1' }} |
| 125 | + |
| 126 | + - name: Upload functional tests coverage to codecov |
| 127 | + if: ${{ env.COVERAGE_TYPE == 'xdebug' }} |
| 128 | + uses: codecov/codecov-action@v3 |
| 129 | + with: |
| 130 | + files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover" |
| 131 | + name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}" |
| 132 | + flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}" |
| 133 | + fail_ci_if_error: true |
| 134 | + move_coverage_to_trash: false |
| 135 | + verbose: ${{ runner.debug == '1' }} |
| 136 | + |
| 137 | + static-checks: |
| 138 | + name: Static checks |
| 139 | + runs-on: ubuntu-latest |
| 140 | + steps: |
| 141 | + - uses: actions/checkout@v3 |
| 142 | + |
| 143 | + - name: Setup PHP 8.2 |
| 144 | + uses: shivammathur/setup-php@v2 |
| 145 | + with: |
| 146 | + php-version: 8.2 # Latest supported |
| 147 | + tools: composer |
| 148 | + coverage: none |
| 149 | + env: |
| 150 | + # Always use latest available patch for the version |
| 151 | + update: true |
| 152 | + |
| 153 | + - name: Setup cache |
| 154 | + id: cache |
| 155 | + uses: actions/cache@v3 |
| 156 | + with: |
| 157 | + path: | |
| 158 | + ~/.composer |
| 159 | + # Clear the cache if composer json (as composer.lock is in the repo) has been updated |
| 160 | + key: tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }} |
| 161 | + |
| 162 | + - name: Build |
| 163 | + run: make build |
| 164 | + |
| 165 | + - name: ComposerRequireChecker |
| 166 | + uses: docker://webfactory/composer-require-checker:4.5.0 |
| 167 | + |
| 168 | + - name: Dependencies check |
| 169 | + if: ${{ github.event_name == 'pull_request' }} |
| 170 | + uses: actions/dependency-review-action@v1 |
| 171 | + |
| 172 | + finalize-codacy-coverage-report: |
| 173 | + runs-on: ubuntu-latest |
| 174 | + name: Finalize Codacy coverage report |
| 175 | + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/php-jsonrpc-params-symfony-validator-sdk' }} |
| 176 | + needs: [ tests ] |
| 177 | + steps: |
| 178 | + - name: Setup cache |
| 179 | + id: cache |
| 180 | + uses: actions/cache@v3 |
| 181 | + with: |
| 182 | + path: | |
| 183 | + ${{ env.CODACY_CACHE_PATH }} |
| 184 | + key: codacy-final |
| 185 | + |
| 186 | + - name: Download codacy binary |
| 187 | + if: steps.cache.outputs.cache-hit != 'true' |
| 188 | + run: | |
| 189 | + mkdir -p ${{ env.CODACY_CACHE_PATH }} \ |
| 190 | + && curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \ |
| 191 | + && chmod +x ${{ env.CODACY_BIN }} \ |
| 192 | + && ${{ env.CODACY_BIN }} download |
| 193 | +
|
| 194 | + - name: Finalize reporting |
| 195 | + run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }} |
| 196 | + |
| 197 | + nightly-tests: |
| 198 | + name: Nightly - Symfony ${{ matrix.symfony-version }} |
| 199 | + runs-on: ubuntu-latest |
| 200 | + env: |
| 201 | + COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' |
| 202 | + continue-on-error: true |
| 203 | + needs: [ static-checks, tests ] |
| 204 | + strategy: |
| 205 | + fail-fast: false |
| 206 | + max-parallel: 4 |
| 207 | + matrix: |
| 208 | + php-version: |
| 209 | + - '8.3' # Current php dev version |
| 210 | + symfony-version: |
| 211 | + - '4.4' # Lowest LTS |
| 212 | + - '5.4' # Latest LTS |
| 213 | + - '6.0' # Current major version |
| 214 | + include: |
| 215 | + - symfony-version: '6.3' # Next symfony minor version to manage with latest supported PHP version |
| 216 | + php-version: '8.2' |
| 217 | + |
| 218 | + steps: |
| 219 | + - name: Check out code |
| 220 | + uses: actions/checkout@v3 |
| 221 | + |
| 222 | + - name: Setup PHP ${{ matrix.php-version }} |
| 223 | + uses: shivammathur/setup-php@v2 |
| 224 | + with: |
| 225 | + php-version: '${{ matrix.php-version }}' |
| 226 | + tools: composer |
| 227 | + coverage: none |
| 228 | + env: |
| 229 | + # Always use latest available patch for the version |
| 230 | + update: true |
| 231 | + |
| 232 | + - name: Setup cache |
| 233 | + id: cache |
| 234 | + uses: actions/cache@v3 |
| 235 | + with: |
| 236 | + path: | |
| 237 | + ~/.composer |
| 238 | + ./vendor |
| 239 | + # Clear the cache if composer json (as composer.lock is in the repo) has been updated |
| 240 | + key: tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }} |
| 241 | + |
| 242 | + - name: Build |
| 243 | + run: | |
| 244 | + composer config minimum-stability dev \ |
| 245 | + && composer require -W ${{ env.COMPOSER_OPTIONS }} \ |
| 246 | + symfony/validator:^${{ matrix.symfony-version }} \ |
| 247 | + && composer update ${{ env.COMPOSER_OPTIONS }} \ |
| 248 | + && make build |
| 249 | +
|
| 250 | + - name: Test |
| 251 | + run: make test-unit && make test-functional |
0 commit comments