8000 Add test automation. · jarnovanleeuwen/laravel-dock@c4e102f · GitHub
[go: up one dir, main page]

Skip to content

Commit c4e102f

Browse files
Add test automation.
1 parent aff9fd4 commit c4e102f

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

build/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ COPY ./config/supervisor/ /etc/supervisor/
3838
COPY --from=composer /usr/bin/composer /usr/bin/composer
3939

4040
# Custom entrypoint to run the app as scheduler or queue worker
41-
COPY ./build/docker-entrypoint /usr/local/bin/
41+
COPY ./build/docker-entrypoint /usr/local/bin/
4242
CMD ["/usr/local/bin/docker-entrypoint"]
4343

4444

@@ -53,12 +53,15 @@ USER webdev
5353

5454
# Copy existing application directory contents and change
5555
# ownership of the application files so that they are not
56-
# writable by Apache's www-user.
56+
# writable by Apache's www-user
5757
COPY --chown=webdev:webdev $SRC ./
5858

5959
# Set proper permissions + install dependencies using Composer
6060
RUN chmod -R 777 bootstrap/cache storage \
6161
&& composer install --no-interaction --no-plugins --prefer-dist --ansi
6262

63+
# Add test script for automated testing
64+
COPY ./build/run_tests.sh /usr/local/bin/run_tests
65+
6366
# Switch default user back to root
6467
USER root

build/docker-compose.test.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: '3.7'
2+
3+
# Docker Network
4+
networks:
5+
network:
6+
driver: bridge
7+
8+
services:
9+
# Apache + PHP
10+
sut:
11+
build:
12+
context: ../
13+
dockerfile: build/Dockerfile
14+
environment:
15+
- CONTAINER_ROLE=app
16+
- DB_HOST=db
17+
- DB_PORT=3306
18+
- DB_DATABASE=laraveldock
19+
- DB_USERNAME=root
20+
- DB_PASSWORD=root
21+
- REDIS_HOST=redis
22+
- REDIS_PORT=6379
23+
- REDIS_PASSWORD=
24+
command: run_tests
25+
depends_on:
26+
- db
27+
- redis
28+
networks:
29+
- network
30+
31+
# MySQL
32+
db:
33+
image: mysql:5.7
34+
command: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
35+
environment:
36+
- MYSQL_ROOT_PASSWORD=root
37+
- MYSQL_DATABASE=laraveldock
38+
networks:
39+
- network
40+
41+
# Redis
42+
redis:
43+
image: redis:5.0
44+
command: ["redis-server", "--appendonly", "yes"]
45+
networks:
46+
- network

build/run_tests.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
echo -n "Waiting for MySQL.."
4+
5+
while ! mysql --protocol TCP -h"${DB_HOST}" -u"${DB_USERNAME}" -p"${DB_PASSWORD}" -e"show databases;" > /dev/null 2>&1; do
6+
echo -n .
7+
sleep 1
8+
((counter++))
9+
10+
if [ $counter -gt 45 ]; then
11+
>&2 echo "failed"
12+
exit 1
13+
fi
14+
done
15+
16+
echo "OK"
17+
18+
php artisan migrate --force
19+
20+
vendor/bin/phpunit

src/phpunit.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
</filter>
2525
<php>
2626
<env name="APP_ENV" value="testing"/>
27+
<env name="APP_KEY" value="testtesttesttesttesttesttesttest"/>
2728
<env name="BCRYPT_ROUNDS" value="4"/>
28-
<env name="CACHE_DRIVER" value="array"/>
29+
<env name="CACHE_DRIVER" value="redis"/>
2930
<env name="MAIL_DRIVER" value="array"/>
3031
<env name="QUEUE_CONNECTION" < 3F1A span class="pl-e">value="sync"/>
3132
<env name="SESSION_DRIVER" value="array"/>

0 commit comments

Comments
 (0)
0