Skip to content

Commit 420423d

Browse files
committed
fixup
1 parent b703af1 commit 420423d

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

.github/workflows/test.Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ARG PHP_VERSION=latest
2+
ARG CODE_COVERAGE=false
23
FROM php:${PHP_VERSION}-cli-alpine
34

45
WORKDIR /workdir
@@ -8,3 +9,13 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
89
ENV COMPOSER_ALLOW_SUPERUSER=1
910
ENV COMPOSER_HTACCESS_PROTECT=0
1011
ENV COMPOSER_CACHE_DIR=/.composer
12+
13+
# install PHP extension pcov
14+
RUN if [[ "${CODE_COVERAGE}" == "true" ]] ; \
15+
then apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
16+
&& mkdir -p /usr/src/php/ext/pcov && curl -fsSL https://pecl.php.net/get/pcov | tar xvz -C /usr/src/php/ext/pcov --strip 1 \
17+
&& docker-php-ext-install pcov \
18+
&& docker-php-ext-enable pcov \
19+
&& rm -Rf /usr/src/php/ext/pcov \
20+
&& apk del --no-cache .build-deps
21+

.github/workflows/test.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@ jobs:
6767
uses: actions/cache@v2
6868
with:
6969
path: /tmp/docker-image.tar
70-
key: cache-docker-image-test:${{ matrix.PHP_VERSION }}
70+
key: cache-docker-image-test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}
7171

7272
- name: Load Docker Image
7373
if: steps.cache-docker-image.outputs.cache-hit == 'true'
7474
run: docker load --input /tmp/docker-image.tar
7575

7676
- name: Build Docker Image
7777
if: steps.cache-docker-image.outputs.cache-hit != 'true'
78-
run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' .
78+
run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' --build-arg 'CODE_COVERAGE=${{ matrix.CODE_COVERAGE }}' .
7979

8080
- name: Cache Composer Cache Files
8181
uses: actions/cache@v2
8282
with:
8383
path: /tmp/composer-cache-files
84-
key: cache-composer-cache-files-${{ matrix.PHP_VERSION }}
84+
key: cache-composer-cache-files-${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}
8585
restore-keys: |
8686
cache-composer-cache-files-
8787
@@ -95,12 +95,7 @@ jobs:
9595
- name: Run Unit Test
9696
run: |
9797
if [ "${{ matrix.CODE_COVERAGE }}" == "true" ]; then
98-
docker run --rm -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' \
99-
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
100-
&& mkdir -p /usr/src/php/ext/pcov && curl -fsSL https://pecl.php.net/get/pcov | tar xvz -C /usr/src/php/ext/pcov --strip 1 \
101-
&& docker-php-ext-install pcov \
102-
&& docker-php-ext-enable pcov \
103-
&& php -d 'zend.assertions=1' -d 'pcov.enabled=1' ./vendor/bin/phpunit --coverage-clover=.clover.xml
98+
docker run --rm -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}-pcov' php -d 'zend.assertions=1' -d 'pcov.enabled=1' ./vendor/bin/phpunit --coverage-clover=.clover.xml
10499
else
105100
docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=1' ./vendor/bin/phpunit
106101
fi
@@ -114,16 +109,16 @@ jobs:
114109

115110
- name: Run PHPStan
116111
if: ${{ matrix.RUN_PHPSTAN }}
117-
run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --level max src/ tests/
112+
run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --level max src/ tests/
118113

119114
- name: Run psalm
120115
if: ${{ matrix.RUN_PSALM }}
121-
run: mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v "$HOME/.cache/psalm:/.cache/psalm" 'test:${{ matrix.PHP_VERSION }}' php ./vendor/bin/psalm
116+
run: mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v "$HOME/.cache/psalm:/.cache/psalm" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' php ./vendor/bin/psalm
122117

123118
- name: Run benchmark
124119
if: ${{ matrix.RUN_BENCHMARK }}
125-
run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=none
120+
run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=none
126121

127122
- name: Export Docker Image
128123
if: steps.cache-docker-image.outputs.cache-hit != 'true'
129-
run: docker save --output /tmp/docker-image.tar 'test:${{ matrix.PHP_VERSION }}'
124+
run: docker save --output /tmp/docker-image.tar 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}'

0 commit comments

Comments
 (0)