Skip to content

Commit 7798b18

Browse files
authored
Make unit tests build faster by basing the image off base-php instead of the full app image (#1280)
Re-architect the test-php image to be built off the base-php image for faster building and execution of unit tests. This should get unit tests running in under 1 minute without all the UI building happening in the full app image (not necessary for PHP unit tests) Utilizes docker layer caching action
1 parent 39437e7 commit 7798b18

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v2
17+
- uses: satackey/action-docker-layer-caching@v0.0.11
1718

1819
- name: Run unit tests
1920
working-directory: ./docker/

docker/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ else
2222
endif
2323

2424
.PHONY: unit-tests
25-
unit-tests: build
25+
unit-tests:
2626
docker-compose build test-php
2727
docker-compose run test-php
2828

docker/test-php/Dockerfile

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
1-
FROM lf-app:latest
1+
FROM sillsdev/web-languageforge:base-php
22

3+
4+
# ----- LINES BELOW COPIED FROM APP DOCKERFILE ----------
5+
WORKDIR /var/www/html
6+
COPY src/composer.json src/composer.lock /var/www/html/
7+
ENV COMPOSER_ALLOW_SUPERUSER=1
8+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* \
9+
&& install-php-extensions @composer && composer install
10+
11+
# uncomment if you want xdebug in your local image
12+
#RUN install-php-extensions xdebug
13+
#COPY docker/app/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d
14+
15+
RUN mv $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini
16+
COPY --from=sillsdev/web-languageforge:wait-latest /wait /wait
17+
18+
# copy src files into image
19+
COPY src /var/www/html/
20+
RUN ln -s /var/www/html /var/www/src
21+
22+
# ensure correct write permissions for assets folders,
23+
RUN chown -R www-data:www-data /var/www/html/assets /var/www/html/cache \
24+
&& chmod -R g+ws /var/www/html/assets /var/www/html/cache
25+
26+
# patch exception handling from Symfony to actually show exceptions instead of swallowing them
27+
COPY docker/app/symfony-exceptions.patch /
28+
RUN patch -p4 -i /symfony-exceptions.patch
29+
30+
# -------- END COPY FROM APP DOCKERFILE --------------
31+
32+
33+
# PHP test specific lines
334
COPY test /var/www/test/
435
COPY docker/test-php/run.sh /run.sh
536

docker/test-php/run.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
22

33
cd /var/www/
4-
echo "##teamcity[importData type='junit' path='PhpUnitTests.xml']"
54
src/vendor/bin/phpunit --configuration test/php/phpunit.xml --log-junit PhpUnitTests.xml

0 commit comments

Comments
 (0)