|
| 1 | +version: 2 |
| 2 | + |
| 3 | +reusable-steps: |
| 4 | + - &clear-test-app-cache |
| 5 | + run: |
| 6 | + name: Clear test app cache |
| 7 | + command: tests/Fixtures/app/console cache:clear |
| 8 | + - &disable-php-memory-limit |
| 9 | + run: |
| 10 | + name: Disable PHP memory limit |
| 11 | + command: echo 'memory_limit=-1' | sudo tee -a /usr/local/etc/php/php.ini |
| 12 | + - &disable-xdebug-php-extension |
| 13 | + run: |
| 14 | + name: Disable Xdebug PHP extension |
| 15 | + command: sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini |
| 16 | + - &restore-composer-cache |
| 17 | + restore_cache: |
| 18 | + keys: |
| 19 | + - composer-cache-{{ .Revision }} |
| 20 | + - composer-cache-{{ .Branch }} |
| 21 | + - composer-cache |
| 22 | + - &restore-npm-cache |
| 23 | + restore_cache: |
| 24 | + keys: |
| 25 | + - npm-cache-{{ .Revision }} |
| 26 | + - npm-cache-{{ .Branch }} |
| 27 | + - npm-cache |
| 28 | + - &save-composer-cache-by-branch |
| 29 | + save_cache: |
| 30 | + paths: |
| 31 | + - ~/.composer/cache |
| 32 | + key: composer-cache-{{ .Branch }}-{{ .BuildNum }} |
| 33 | + - &save-composer-cache-by-revision |
| 34 | + save_cache: |
| 35 | + paths: |
| 36 | + - ~/.composer/cache |
| 37 | + key: composer-cache-{{ .Revision }}-{{ .BuildNum }} |
| 38 | + - &save-npm-cache-by-branch |
| 39 | + save_cache: |
| 40 | + paths: |
| 41 | + - ~/.npm |
| 42 | + key: npm-cache-{{ .Branch }}-{{ .BuildNum }} |
| 43 | + - &save-npm-cache-by-revision |
| 44 | + save_cache: |
| 45 | + paths: |
| 46 | + - ~/.npm |
| 47 | + key: npm-cache-{{ .Revision }}-{{ .BuildNum }} |
| 48 | + - &update-composer |
| 49 | + run: |
| 50 | + name: Update Composer |
| 51 | + command: composer self-update |
| 52 | + - &update-project-dependencies |
| 53 | + run: |
| 54 | + name: Update project dependencies |
| 55 | + command: composer update --prefer-dist --no-progress --no-suggest --ansi |
| 56 | + |
| 57 | +jobs: |
| 58 | + phpunit-php-7.2-coverage: |
| 59 | + docker: |
| 60 | + - image: circleci/php:7.2-node-browsers |
| 61 | + environment: |
| 62 | + SYMFONY_DEPRECATIONS_HELPER: weak_vendors |
| 63 | + APP_ENV: test |
| 64 | + parallelism: 2 |
| 65 | + working_directory: ~/api-platform/core |
| 66 | + steps: |
| 67 | + - checkout |
| 68 | + - *restore-composer-cache |
| 69 | + - *restore-npm-cache |
| 70 | + - *disable-xdebug-php-extension |
| 71 | + - *disable-php-memory-limit |
| 72 | + - *update-composer |
| 73 | + - *update-project-dependencies |
| 74 | + - *save-composer-cache-by-revision |
| 75 | + - *save-composer-cache-by-branch |
| 76 | + - *clear-test-app-cache |
| 77 | + - run: |
| 78 | + name: Run PHPUnit tests |
| 79 | + command: |- |
| 80 | + mkdir -p build/logs/tmp build/cov |
| 81 | + find tests -name '*Test.php' | circleci tests split --split-by=timings | parallel -j10% --rpl '{_} s/\//_/g;' \ |
| 82 | + phpdbg -qrr vendor/bin/phpunit --coverage-php build/cov/coverage-{_}.cov --log-junit build/logs/tmp/{_}.xml --colors=always {} |
| 83 | + - run: |
| 84 | + name: Merge PHPUnit test reports |
| 85 | + command: |- |
| 86 | + mkdir -p build/logs/phpunit |
| 87 | + npx junit-merge --out build/logs/phpunit/junit.xml --dir build/logs/tmp |
| 88 | + rm -r build/logs/tmp |
| 89 | + - store_test_results: |
| 90 | + path: build/logs |
| 91 | + - store_artifacts: |
| 92 | + path: build/logs/phpunit/junit.xml |
| 93 | + destination: build/logs/phpunit/junit.xml |
| 94 | + - persist_to_workspace: |
| 95 | + root: build |
| 96 | + paths: |
| 97 | + - cov |
| 98 | + - *save-npm-cache-by-revision |
| 99 | + - *save-npm-cache-by-branch |
| 100 | + |
| 101 | + behat-php-7.2-coverage: |
| 102 | + docker: |
| 103 | + - image: circleci/php:7.2-node-browsers |
| 104 | + environment: |
| 105 | + SYMFONY_DEPRECATIONS_HELPER: weak_vendors |
| 106 | + APP_ENV: test |
| 107 | + parallelism: 2 |
| 108 | + working_directory: ~/api-platform/core |
| 109 | + steps: |
| 110 | + - checkout |
| 111 | + - *restore-composer-cache |
| 112 | + - *restore-npm-cache |
| 113 | + - *disable-xdebug-php-extension |
| 114 | + - *disable-php-memory-limit |
| 115 | + - *update-composer |
| 116 | + - *update-project-dependencies |
| 117 | + - *save-composer-cache-by-revision |
| 118 | + - *save-composer-cache-by-branch |
| 119 | + - *clear-test-app-cache |
| 120 | + - run: |
| 121 | + name: Run Behat tests |
| 122 | + command: |- |
| 123 | + mkdir -p build/logs/tmp build/cov |
| 124 | + for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature' | circleci tests split --split-by=timings); do |
| 125 | + _f=${f//\//_} |
| 126 | + FEATURE="${_f}" phpdbg -qrr vendor/bin/behat --profile=coverage --suite=default --tags=~@postgres --format=progress --out=std --format=junit --out=build/logs/tmp/"${_f}" "$f" |
| 127 | + done |
| 128 | + - run: |
| 129 | + name: Merge Behat test reports |
| 130 | + command: |- |
| 131 | + mkdir -p build/logs/behat |
| 132 | + npx junit-merge --out build/logs/behat/junit.xml --dir build/logs/tmp --recursive |
| 133 | + rm -r build/logs/tmp |
| 134 | + - store_test_results: |
| 135 | + path: build/logs |
| 136 | + - store_artifacts: |
| 137 | + path: build/logs/behat/junit.xml |
| 138 | + destination: build/logs/behat/junit.xml |
| 139 | + - persist_to_workspace: |
| 140 | + root: build |
| 141 | + paths: |
| 142 | + - cov |
| 143 | + - *save-npm-cache-by-revision |
| 144 | + - *save-npm-cache-by-branch |
| 145 | + |
| 146 | + merge-and-upload-coverage: |
| 147 | + docker: |
| 148 | + - image: circleci/php:7.2-node-browsers |
| 149 | + working_directory: ~/api-platform/core |
| 150 | + steps: |
| 151 | + - checkout |
| 152 | + - *restore-npm-cache |
| 153 | + - *disable-xdebug-php-extension |
| 154 | + - *disable-php-memory-limit |
| 155 | + - run: |
| 156 | + name: Download phpcov |
| 157 | + command: wget https://phar.phpunit.de/phpcov.phar |
| 158 | + - attach_workspace: |
| 159 | + at: build |
| 160 | + - run: |
| 161 | + name: Merge code coverage reports |
| 162 | + command: |- |
| 163 | + mkdir -p build/logs |
| 164 | + phpdbg -qrr phpcov.phar merge --clover build/logs/clover.xml build/cov |
| 165 | + - store_artifacts: |
| 166 | + path: build/logs/clover.xml |
| 167 | + destination: build/logs/clover.xml |
| 168 | + - run: |
| 169 | + name: Upload code coverage report to Coveralls |
| 170 | + command: |- |
| 171 | + if [ ! -z "$COVERALLS_REPO_TOKEN" ]; then |
| 172 | + npx @cedx/coveralls build/logs/clover.xml |
| 173 | + else |
| 174 | + echo 'Skipped' |
| 175 | + fi |
| 176 | + - run: |
| 177 | + name: Upload code coverage report to Codecov |
| 178 | + command: npx codecov --file=build/logs/clover.xml --disable=gcov |
| 179 | + - *save-npm-cache-by-revision |
| 180 | + - *save-npm-cache-by-branch |
| 181 | + |
| 182 | +workflows: |
| 183 | + version: 2 |
| 184 | + test-with-coverage: |
| 185 | + jobs: |
| 186 | + - phpunit-php-7.2-coverage |
| 187 | + - behat-php-7.2-coverage |
| 188 | + - merge-and-upload-coverage: |
| 189 | + requires: |
| 190 | + - phpunit-php-7.2-coverage |
| 191 | + - behat-php-7.2-coverage |
0 commit comments