|
| 1 | +name: 'CI-test' |
| 2 | + |
| 3 | +on: # Build any PRs and main branch changes |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - synchronize |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}" |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + debug-context: |
| 15 | + name: DEBUG - context |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - run: | |
| 19 | + echo '{' |
| 20 | + echo '"github.action": ${{ toJson(github.action) }},' |
| 21 | + echo '"github.action_path": ${{ toJson(github.action_path) }},' |
| 22 | + echo '"github.action_ref": ${{ toJson(github.action_ref) }},' |
| 23 | + echo '"github.action_repository": ${{ toJson(github.action_repository) }},' |
| 24 | + echo '"github.action_status": ${{ toJson(github.action_status) }},' |
| 25 | + echo '"github.actor": ${{ toJson(github.actor) }},' |
| 26 | + echo '"github.actor_id": ${{ toJson(github.actor_id) }},' |
| 27 | + echo '"github.base_ref": ${{ toJson(github.base_ref) }},' |
| 28 | + echo '"github.event": ${{ toJson(github.event) }},' |
| 29 | + echo '"github.event_name": ${{ toJson(github.event_name) }},' |
| 30 | + echo '"github.event_path": ${{ toJson(github.event_path) }},' |
| 31 | + echo '"github.head_ref": ${{ toJson(github.head_ref) }},' |
| 32 | + echo '"github.job": ${{ toJson(github.job) }},' |
| 33 | + echo '"github.path": ${{ toJson(github.path) }},' |
| 34 | + echo '"github.ref": ${{ toJson(github.ref) }},' |
| 35 | + echo '"github.ref_name": ${{ toJson(github.ref_name) }},' |
| 36 | + echo '"github.ref_protected": ${{ toJson(github.ref_protected) }},' |
| 37 | + echo '"github.ref_type": ${{ toJson(github.ref_type) }},' |
| 38 | + echo '"github.repository": ${{ toJson(github.repository) }},' |
| 39 | + echo '"github.repository_id": ${{ toJson(github.repository_id) }},' |
| 40 | + echo '"github.repository_owner": ${{ toJson(github.repository_owner) }},' |
| 41 | + echo '"github.repository_owner_id": ${{ toJson(github.repository_owner_id) }},' |
| 42 | + echo '"github.repositoryUrl": ${{ toJson(github.repositoryUrl) }},' |
| 43 | + echo '"github.run_id": ${{ toJson(github.run_id) }},' |
| 44 | + echo '"github.run_number": ${{ toJson(github.run_number) }},' |
| 45 | + echo '"github.run_attempt": ${{ toJson(github.run_attempt) }},' |
| 46 | + echo '"github.sha": ${{ toJson(github.sha) }},' |
| 47 | + echo '"github.triggering_actor": ${{ toJson(github.triggering_actor) }},' |
| 48 | + echo '"github.workflow": ${{ toJson(github.workflow) }},' |
| 49 | + echo '"github.workflow_ref": ${{ toJson(github.workflow_ref) }},' |
| 50 | + echo '"github.workflow_sha": ${{ toJson(github.workflow_sha) }},' |
| 51 | + echo '"github.workspace": ${{ toJson(github.workspace) }}' |
| 52 | + echo '}' |
| 53 | +
|
| 54 | +
|
| 55 | + tests: |
| 56 | + name: UTs & FTs - PHP ${{ matrix.php-version }} |
| 57 | + runs-on: ubuntu-latest |
| 58 | + env: |
| 59 | + COVERAGE_TYPE: xdebug |
| 60 | + COVERAGE_OUTPUT_STYLE: clover |
| 61 | + strategy: |
| 62 | + fail-fast: true |
| 63 | + max-parallel: 4 |
| 64 | + matrix: |
| 65 | + include: |
| 66 | + # Bare minimum => Lowest versions allowed by composer config |
| 67 | + - php-version: '8.0' |
| 68 | + composer-flag: --prefer-lowest |
| 69 | + # Up-to-date versions => Latest versions allowed by composer config |
| 70 | + - php-version: '8.2' |
| 71 | + steps: |
| 72 | + - name: Check out code |
| 73 | + uses: actions/checkout@v3 |
| 74 | + |
| 75 | +# @TODO Figure out if coverage for every version is actually useful or not |
| 76 | +# - name: Enable coverage |
| 77 | +# if: ${{ matrix.php-version == '8.2' }} |
| 78 | +# run: | |
| 79 | +# echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV |
| 80 | +# echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV |
| 81 | + |
| 82 | + - name: Setup PHP ${{ matrix.php-version }} |
| 83 | + uses: shivammathur/setup-php@v2 |
| 84 | + env: |
| 85 | + update: true # Always use latest available patch for the version |
| 86 | + fail-fast: true # step will fail if an extension or tool fails to set up |
| 87 | + with: |
| 88 | + php-version: '${{ matrix.php-version }}' |
| 89 | + tools: composer |
| 90 | + coverage: ${{ env.COVERAGE_TYPE }} |
| 91 | + |
| 92 | + - name: Setup cache |
| 93 | + id: cache |
| 94 | + uses: actions/cache@v3 |
| 95 | + with: |
| 96 | + path: | |
| 97 | + ~/.composer |
| 98 | + ./vendor |
| 99 | + # Clear the cache if composer json (as composer.lock is in the repo) has been updated |
| 100 | + key: tests-${{ matrix.php-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }} |
| 101 | + |
| 102 | + - name: Build |
| 103 | + run: | |
| 104 | + make build |
| 105 | +
|
| 106 | + - name: Tests |
| 107 | + run: make test-unit && make test-functional |
| 108 | + |
| 109 | + - name: Create "unit tests" reports directory |
| 110 | + if: ${{ env.COVERAGE_TYPE == 'xdebug' }} |
| 111 | + id: unit-tests-coverage-group |
| 112 | + uses: yoanm/temp-reports-group-workspace/.github/actions/create-action@improve |
| 113 | + with: |
| 114 | + name: unit-tests |
| 115 | + format: clover |
| 116 | + files: build/coverage-phpunit/unit.clover |
| 117 | + flags: | |
| 118 | + unit-tests |
| 119 | + php-${{ matrix.php-version }} |
| 120 | + path: build/coverage-groups |
| 121 | + |
| 122 | + - name: Create "functional tests" coverage group |
| 123 | + if: ${{ env.COVERAGE_TYPE == 'xdebug' }} |
| 124 | + id: functional-tests-coverage-group |
| 125 | + uses: yoanm/temp-reports-group-workspace/.github/actions/create-action@improve |
| 126 | + with: |
| 127 | + name: functional-tests |
| 128 | + format: clover |
| 129 | + files: | |
| 130 | + build/coverage-phpunit/functional.clover |
| 131 | + build/coverage-behat/clover.xml |
| 132 | + flags: | |
| 133 | + functional-tests |
| 134 | + php-${{ matrix.php-version }} |
| 135 | + path: build/coverage-groups |
| 136 | + |
| 137 | + - name: Upload coverage reports |
| 138 | + if: ${{ env.COVERAGE_TYPE == 'xdebug' }} |
| 139 | + uses: actions/upload-artifact@v4 |
| 140 | + with: |
| 141 | + name: coverage-groups-php${{ matrix.php-version }} |
| 142 | + path: build/coverage-groups |
| 143 | + if-no-files-found: error |
| 144 | + |
| 145 | + static-checks: |
| 146 | + name: Static checks |
| 147 | + runs-on: ubuntu-latest |
| 148 | + steps: |
| 149 | + - uses: actions/checkout@v3 |
| 150 | + |
| 151 | + - name: Setup PHP 8.2 |
| 152 | + uses: shivammathur/setup-php@v2 |
| 153 | + with: |
| 154 | + php-version: 8.2 # Latest supported |
| 155 | + tools: composer |
| 156 | + coverage: none |
| 157 | + env: |
| 158 | + # Always use latest available patch for the version |
| 159 | + update: true |
| 160 | + |
| 161 | + - name: Setup cache |
| 162 | + id: cache |
| 163 | + uses: actions/cache@v3 |
| 164 | + with: |
| 165 | + path: | |
| 166 | + ~/.composer |
| 167 | + # Clear the cache if composer json (as composer.lock is in the repo) has been updated |
| 168 | + key: tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }} |
| 169 | + |
| 170 | + - name: Build |
| 171 | + run: make build |
| 172 | + |
| 173 | + - name: ComposerRequireChecker |
| 174 | + uses: docker://webfactory/composer-require-checker:4.5.0 |
| 175 | + |
| 176 | + - name: Dependencies check |
| 177 | + if: ${{ github.event_name == 'pull_request' }} |
| 178 | + uses: actions/dependency-review-action@v1 |
| 179 | + |
| 180 | + nightly-tests: |
| 181 | + name: Nightly - PHP ${{ matrix.php-version }} |
| 182 | + runs-on: ubuntu-latest |
| 183 | + env: |
| 184 | + COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' |
| 185 | + continue-on-error: true |
| 186 | + needs: [ static-checks, tests ] |
| 187 | + strategy: |
| 188 | + fail-fast: false |
| 189 | + max-parallel: 4 |
| 190 | + matrix: |
| 191 | + php-version: |
| 192 | + - '8.3' # Current php dev version |
| 193 | + |
| 194 | + steps: |
| 195 | + - name: Check out code |
| 196 | + uses: actions/checkout@v3 |
| 197 | + |
| 198 | + - name: Setup PHP ${{ matrix.php-version }} |
| 199 | + uses: shivammathur/setup-php@v2 |
| 200 | + with: |
| 201 | + php-version: '${{ matrix.php-version }}' |
| 202 | + tools: composer |
| 203 | + coverage: none |
| 204 | + env: |
| 205 | + # Always use latest available patch for the version |
| 206 | + update: true |
| 207 | + |
| 208 | + - name: Setup cache |
| 209 | + id: cache |
| 210 | + uses: actions/cache@v3 |
| 211 | + with: |
| 212 | + path: | |
| 213 | + ~/.composer |
| 214 | + ./vendor |
| 215 | + # Clear the cache if composer json (as composer.lock is in the repo) has been updated |
| 216 | + key: tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }} |
| 217 | + |
| 218 | + - name: Build |
| 219 | + run: | |
| 220 | + make build |
| 221 | +
|
| 222 | + - name: Test |
| 223 | + run: make test-unit && make test-functional |
| 224 | + |
| 225 | + |
| 226 | + fetch-info: |
| 227 | + name: Fetch triggering workflow metadata |
| 228 | + needs: [tests, static-checks, nightly-tests] |
| 229 | + runs-on: ubuntu-latest |
| 230 | + permissions: |
| 231 | + contents: read |
| 232 | + checks: write # For the check run creation ! |
| 233 | + steps: |
| 234 | + - name: 'Check run ○' |
| 235 | + uses: yoanm/temp-reports-group-workspace/.github/actions/attach-check-run-to-triggering-workflow-action@improve |
| 236 | + with: |
| 237 | + name: 'Fetch coverage info' |
| 238 | + fails-on-triggering-workflow-failure: true |
| 239 | + |
| 240 | + - uses: yoanm/temp-reports-group-workspace/.github/actions/fetch-workflow-metadata-action@improve |
| 241 | + id: fetch-workflow-metadata |
| 242 | + outputs: |
| 243 | + commit-sha: ${{ steps.fetch-workflow-metadata.outputs.commit-sha }} |
| 244 | + run-id: ${{ steps.fetch-workflow-metadata.outputs.run-id }} |
| 245 | + |
| 246 | + codacy-uploader: |
| 247 | + name: Codacy |
| 248 | + needs: [ fetch-info ] |
| 249 | + uses: yoanm/temp-reports-group-workspace/.github/workflows/codacy-upload-from-artifacts.yml@improve |
| 250 | + permissions: |
| 251 | + contents: read |
| 252 | + checks: write # For the check run creation ! |
| 253 | + secrets: |
| 254 | + PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} |
| 255 | + with: |
| 256 | + artifacts-pattern: coverage-groups-* |
| 257 | + run-id: ${{ needs.fetch-info.outputs.run-id }} |
| 258 | + #override-commit: ${{ needs.fetch-info.outputs.commit-sha }} # Uploader action doesn't support it ! |
| 259 | + |
| 260 | + codecov-uploader: |
| 261 | + name: Codecov |
| 262 | + needs: [ fetch-info ] |
| 263 | + uses: yoanm/temp-reports-group-workspace/.github/workflows/codecov-upload-from-artifacts.yml@improve |
| 264 | + permissions: |
| 265 | + contents: read |
| 266 | + checks: write # For the check run creation ! |
| 267 | + secrets: |
| 268 | + TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 269 | + with: |
| 270 | + artifacts-pattern: coverage-groups-* |
| 271 | + run-id: ${{ needs.fetch-info.outputs.run-id }} |
| 272 | + override-commit: ${{ needs.fetch-info.outputs.commit-sha }} |
| 273 | + override-branch: ${{ needs.fetch-info.outputs.branch }} |
| 274 | + override-pr: ${{ needs.fetch-info.outputs.pr-number }} |
| 275 | + override-build: ${{ needs.fetch-info.outputs.run-id }} |
| 276 | + override-build-url: ${{ needs.fetch-info.outputs.run-url }} |
0 commit comments