|
1 | 1 | ######################################################################## |
2 | | -# This pipeline is executed on PHP 7.4: |
3 | | -# - required for development |
4 | | -# - required to run Rector, to generate the PHP 7.1-compatible code for production |
| 2 | +# TravisCI configuration for GraphQLAPI/graphql-api-for-wp |
5 | 3 | # |
6 | | -# It uses the Build Environment "Xenial", because it has PHP 7.1 preinstalled, |
7 | | -# so we can switch from the global PHP 7.4 to local PHP 7.1 through `phpenv` |
| 4 | +# There are 1+3 jobs. |
8 | 5 | # |
9 | | -# There are 2 parallel executions, with env variable: |
10 | | -# 1. DOWNGRADE_CODE="true" |
11 | | -# 2. DOWNGRADE_CODE="false" |
12 | | -# |
13 | | -# When DOWNGRADE_CODE is "false", it is the standard testing pipeline: |
14 | | -# Execute PHPCS, PHPUnit and PHPStan to check there are no issues, and generate report. |
15 | | -# |
16 | | -# When DOWNGRADE_CODE is "true", it tests the conversion of the PHP code version 7.4 to 7.1: |
17 | | -# - Run Rector to downgrade the code |
18 | | -# - Run PHPStan. If it exits with no errors, then downgrading the code works well. |
19 | | -######################################################################## |
20 | | -dist: xenial |
21 | | -language: php |
| 6 | +# 1. PHPUnit on PHP 7.4 required for development |
| 7 | +# 2. PHPCS on PHP 7.4 |
| 8 | +# 3. PHPStan on PHP 7.4 |
| 9 | +# 4. Run Rector to generate the PHP 7.1-compatible code for production |
| 10 | +# then PHPStan on PHP 7.1 |
| 11 | +######################################################################## |
22 | 12 |
|
23 | | -jobs: |
24 | | - include: |
25 | | - - php: 7.4 |
26 | | - env: DOWNGRADE_CODE=false |
27 | | - - php: 7.4 |
28 | | - env: DOWNGRADE_CODE=true |
| 13 | +language: php |
| 14 | +os: |
| 15 | + - linux |
| 16 | +dist: bionic |
29 | 17 |
|
30 | | -## Cache composer |
31 | 18 | cache: |
32 | 19 | directories: |
33 | | - - $HOME/.composer/cache |
| 20 | + - "${HOME}/.composer/cache" |
| 21 | + |
| 22 | +php: |
| 23 | + - 7.4 |
| 24 | + |
| 25 | +jobs: |
| 26 | + include: |
| 27 | + # FIXME TravisCI should run the default job |
| 28 | + - name: "Tests" |
| 29 | + script: |
| 30 | + - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover |
| 31 | + - name: "PHPCS" |
| 32 | + script: |
| 33 | + - vendor/bin/phpcs -n --standard=PSR2 src/ |
| 34 | + after_script: skip |
| 35 | + - name: "PHPStan" |
| 36 | + script: |
| 37 | + - vendor/bin/phpstan analyse -c phpstan.neon.dist src/ |
| 38 | + after_script: skip |
| 39 | + - name: "Downgraded code" |
| 40 | + script: |
| 41 | + - vendor/bin/rector process |
| 42 | + - phpenv local 7.1 |
| 43 | + - php --version |
| 44 | + - vendor/bin/phpstan analyse -c phpstan.neon.dist src/ |
| 45 | + after_script: skip |
34 | 46 |
|
35 | | -before_script: |
36 | | - - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist |
37 | | - # Downgrade the code to PHP 7.1 via Rector |
38 | | - - if [[ "$DOWNGRADE_CODE" == "true" ]]; then vendor/bin/rector process; fi |
| 47 | +install: |
| 48 | + - travis_retry composer update --no-interaction --prefer-dist |
39 | 49 |
|
40 | 50 | script: |
41 | | - # Tests only on PHP 7.4 |
42 | | - - if [[ "$DOWNGRADE_CODE" != "true" ]]; then vendor/bin/phpcs -n --standard=psr2 src/; fi |
43 | | - - if [[ "$DOWNGRADE_CODE" != "true" ]]; then vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover; fi |
44 | | - # Switch to PHP 7.1 to test if downgraded code works, then up again to 7.4 |
45 | | - - if [[ "$DOWNGRADE_CODE" == "true" ]]; then phpenv local 7.1; fi |
46 | | - - if [[ "$DOWNGRADE_CODE" == "true" ]]; then php --version; fi |
47 | | - - vendor/bin/phpstan analyse -c phpstan.neon.dist src |
48 | | - - if [[ "$DOWNGRADE_CODE" == "true" ]]; then phpenv local 7.4; fi |
49 | | - - if [[ "$DOWNGRADE_CODE" == "true" ]]; then php --version; fi |
| 51 | + - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover |
50 | 52 |
|
51 | 53 | after_script: |
52 | 54 | - wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover |
|
0 commit comments