Skip to content

Commit a372bff

Browse files
committed
Add support for pcov
1 parent dd79888 commit a372bff

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ARG TARGETPLATFORM
55
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
66
RUN echo "Building for ${TARGETPLATFORM}"
77

8-
ADD root/ /
98
# Fix the original permissions of /tmp, the PHP default upload tmp dir.
9+
ADD root/tmp /tmp/
1010
RUN chmod 777 /tmp && chmod +t /tmp
1111

1212
# Install some packages that are useful within the images.
@@ -34,6 +34,10 @@ RUN /tmp/setup/php-extensions.sh
3434
RUN /tmp/setup/oci8-extension.sh
3535
ENV LD_LIBRARY_PATH /usr/local/instantclient
3636

37+
ADD root/usr /usr/
38+
39+
ENTRYPOINT ["moodle-docker-php-entrypoint"]
40+
3741
RUN mkdir /var/www/moodledata && chown www-data /var/www/moodledata && \
3842
mkdir /var/www/phpunitdata && chown www-data /var/www/phpunitdata && \
3943
mkdir /var/www/behatdata && chown www-data /var/www/behatdata && \

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ To faciliate testing and easy setup the following directories are created and ow
4141
* `/var/www/behatdata`
4242
* `/var/www/behatfaildumps`
4343

44+
## Configuration
45+
### PCov
46+
47+
pcov can be configured by setting the following environment variables when creating the container:
48+
49+
| Environment variable | Default value | Description |
50+
| --------------------- | ----------------------------------------------- | ----------------------------------------------------- |
51+
| `PCOV_ENABLED` | 0 (disabled) | Whether pcov is enabled |
52+
| `PCOV_DIRECTORY` | `/var/www/html` | Restrict collection to files under this path |
53+
| `PCOV_EXCLUDE` | See note | Exclude files under pcov.directory matching this PCRE |
54+
| `PCOV_INITIAL_MEMORY` | `65536` | Initial size of the arena |
55+
| `PCOV_INITIAL_FILES` | `1024` | Initial size of the tables |
56+
57+
The default value for pcov.exclude is intended to remove tests, coverage, vendor, and similar paths from code coverage:
58+
59+
~\/(tests|coverage|vendor|node_modules)\/~
60+
61+
See https://github.com/krakjoe/pcov#configuration for documentation on these options.
4462

4563
## See also
4664
This container is part of a set of containers for Moodle development, see also:

root/tmp/setup/php-extensions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ docker-php-ext-configure ldap
6464
docker-php-ext-install -j$(nproc) ldap
6565

6666
# APCu, igbinary, Memcached, MongoDB, Redis, Solr, uuid, XMLRPC (beta)
67-
pecl install apcu igbinary memcached mongodb redis solr uuid xmlrpc-beta
68-
docker-php-ext-enable apcu igbinary memcached mongodb redis solr uuid xmlrpc
67+
pecl install apcu igbinary memcached mongodb redis solr uuid xmlrpc-beta pcov
68+
docker-php-ext-enable apcu igbinary memcached mongodb redis solr uuid xmlrpc pcov
6969

7070
echo 'apc.enable_cli = On' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
7171

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# PCOV Configuration.
5+
PCOV_ENABLED="${PCOV_ENABLED:-0}"
6+
PCOV_EXCLUDE="${PCOV_EXCLUDE:-'~\/(tests|coverage|vendor|node_modules)\/~'}"
7+
PCOV_DIRECTORY="${PCOV_DIRECTORY:-'/var/www/html'}"
8+
PCOV_INITIAL_MEMORY="${PCOV_INITIAL_MEMORY:-65536}"
9+
PCOV_INITIAL_FILES="${PCOV_INITIAL_FILES:-1024}"
10+
11+
echo "pcov.enabled=${PCOV_ENABLED}" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
12+
echo "pcov.exclude=${PCOV_EXCLUDE}" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
13+
echo "pcov.directory=${PCOV_DIRECTORY}" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
14+
echo "pcov.initial.memory=${PCOV_INITIAL_MEMORY}" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
15+
echo "pcov.initial.files=${PCOV_INITIAL_FILES}" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
16+
17+
docker-php-entrypoint "$@"

0 commit comments

Comments
 (0)