Skip to content

Commit b677b33

Browse files
committed
Use Brigade for coverage
1 parent 6ed91c3 commit b677b33

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

brigade.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const { events, Job } = require('brigadier');
2+
3+
const coverage = (event, project) => {
4+
console.log(`===> Building ${ project.repo.cloneURL } ${ event.commit }`);
5+
6+
const job = new Job('coverage', 'php:rc-alpine');
7+
8+
job.tasks = [
9+
`set -xe`,
10+
`apk add --no-cache curl git openssl icu-libs zlib icu-dev zlib-dev $PHPIZE_DEPS`,
11+
`docker-php-ext-install intl zip`,
12+
`echo "memory_limit=-1" > $PHP_INI_DIR/conf.d/memory-limit.ini`,
13+
`curl -s -f -L -o /tmp/installer.php https://getcomposer.org/installer`,
14+
`curl -s -f -L -o /tmp/install.sig https://composer.github.io/installer.sig`,
15+
`php -r "
16+
\\$signature = trim(file_get_contents('/tmp/install.sig'));
17+
\\$hash = hash('SHA384', file_get_contents('/tmp/installer.php'));
18+
19+
if (hash_equals(\\$signature, \\$hash)) {
20+
echo 'Installer verified'.PHP_EOL;
21+
} else {
22+
unlink('/tmp/installer.php');
23+
echo 'Installer corrupt'.PHP_EOL;
24+
exit(1);
25+
}
26+
"`,
27+
`php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer`,
28+
`curl -s -f -L -o /usr/bin/phpcov https://phar.phpunit.de/phpcov.phar`,
29+
`curl -s -f -L -o /usr/bin/coveralls https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar`,
30+
`chmod 755 /usr/bin/phpcov /usr/bin/coveralls`,
31+
`cd /src/`,
32+
`mkdir -p build/logs build/cov`,
33+
`composer require --dev --no-update 'phpunit/php-code-coverage:^5.2.2'`,
34+
`composer update --prefer-dist --no-progress --no-suggest --ansi`,
35+
`phpdbg -qrr vendor/bin/phpunit --coverage-php build/cov/coverage-phpunit.cov`,
36+
`for f in $(find features -name '*.feature'); do FEATURE=\${f//\\//_} phpdbg -qrr vendor/bin/behat --format=progress --profile coverage $f || exit $?; done`,
37+
`phpdbg -qrr $(which phpcov) merge --clover build/logs/clover.xml build/cov;`,
38+
`coveralls -v`,
39+
];
40+
41+
job.env = {
42+
'COMPOSER_ALLOW_SUPERUSER': '1',
43+
'COVERALLS_RUN_LOCALLY': '1',
44+
'COVERALLS_REPO_TOKEN': project.secrets.coverallsToken,
45+
};
46+
47+
job.run();
48+
};
49+
50+
events.on('push', coverage);
51+
events.on('pull_request', coverage);

0 commit comments

Comments
 (0)