Skip to content

Commit

Permalink
[6.x] Added a way to run the CI tests locally (#31551)
Browse files Browse the repository at this point in the history
* Added a way to run the CI tests locally

* Update test.sh

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
GrahamCampbell and taylorotwell authored Feb 21, 2020
1 parent 83e8e7b commit c1b6dae
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
CHANGELOG-* export-ignore
CODE_OF_CONDUCT.md export-ignore
CONTRIBUTING.md export-ignore
docker-compose.yml export-ignore
phpunit.xml.dist export-ignore
Empty file modified bin/release.sh
100644 → 100755
Empty file.
23 changes: 23 additions & 0 deletions bin/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

docker-compose down -t 0 &> /dev/null
docker-compose up -d

echo "Waiting for services to boot..."

if docker run -it --rm registry.gitlab.com/grahamcampbell/php:7.4-base -r "\$tries = 0; while (true) { try { \$tries++; if (\$tries > 30) { throw new RuntimeException('MySQL never became available'); } sleep(1); new PDO('mysql:host=docker.for.mac.localhost;dbname=forge', 'root', '', [PDO::ATTR_TIMEOUT => 3]); break; } catch (PDOException \$e) {} }"; then
if docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit \
--env CI=1 --env DB_HOST=docker.for.mac.localhost \
--env REDIS_HOST=docker.for.mac.localhost --env REDIS_PORT=6379 \
--env MEMCACHED_HOST=docker.for.mac.localhost --env MEMCACHED_PORT=11211 \
--rm registry.gitlab.com/grahamcampbell/php:7.4-base "$@"; then
docker-compose down -t 0
else
docker-compose down -t 0
exit 1
fi
else
docker-compose logs
docker-compose down -t 0 &> /dev/null
exit 1
fi
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3'
services:
memcached:
image: memcached:1.5-alpine
ports:
- "11211:11211"
restart: always
mysql:
image: mysql:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_ROOT_PASSWORD: ""
MYSQL_DATABASE: "forge"
ports:
- "3306:3306"
restart: always
redis:
image: redis:5.0-alpine
ports:
- "6379:6379"
restart: always

0 comments on commit c1b6dae

Please sign in to comment.