Skip to content

Commit f7c9f2c

Browse files
[8.x] Improves internal ./bin/test script (#39404)
* Improves "test" script * Apply fixes from StyleCI * Reverts change regarding memcached Co-authored-by: Taylor Otwell <[email protected]>
1 parent d898cef commit f7c9f2c

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

bin/test.sh

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,50 @@
11
#!/usr/bin/env bash
22

3-
docker-compose down -t 0 &> /dev/null
3+
down=false
4+
php="8.0"
5+
6+
while true; do
7+
case "$1" in
8+
--down ) down=true; shift ;;
9+
--php ) php=$2; shift 2;;
10+
-- ) shift; break ;;
11+
* ) break ;;
12+
esac
13+
done
14+
15+
if $down; then
16+
docker-compose down -t 0
17+
18+
exit 0
19+
fi
20+
21+
echo "Ensuring docker is running"
22+
23+
if ! docker info > /dev/null 2>&1; then
24+
echo "Please start docker first."
25+
exit 1
26+
fi
27+
28+
echo "Ensuring services are running"
29+
430
docker-compose up -d
531

6-
echo "Waiting for services to boot ..."
32+
if docker run -it --rm "registry.gitlab.com/grahamcampbell/php:$php-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
33+
echo "Running tests"
734

8-
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
9-
if docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit \
35+
if docker run -it -w /data -v ${PWD}:/data:delegated \
36+
--user "www-data" --entrypoint vendor/bin/phpunit \
1037
--env CI=1 --env DB_HOST=docker.for.mac.localhost --env DB_USERNAME=root \
38+
--env DB_HOST=docker.for.mac.localhost --env DB_PORT=3306 \
39+
--env DYNAMODB_ENDPOINT=docker.for.mac.localhost:8000 --env DYNAMODB_CACHE_TABLE=cache --env AWS_ACCESS_KEY_ID=dummy --env AWS_SECRET_ACCESS_KEY=dummy \
1140
--env REDIS_HOST=docker.for.mac.localhost --env REDIS_PORT=6379 \
1241
--env MEMCACHED_HOST=docker.for.mac.localhost --env MEMCACHED_PORT=11211 \
13-
--rm registry.gitlab.com/grahamcampbell/php:7.4-base "$@"; then
14-
docker-compose down -t 0
42+
--rm "registry.gitlab.com/grahamcampbell/php:$php-base" "$@"; then
43+
exit 0
1544
else
16-
docker-compose down -t 0
1745
exit 1
1846
fi
1947
else
2048
docker-compose logs
21-
docker-compose down -t 0 &> /dev/null
2249
exit 1
2350
fi

docker-compose.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
version: '3'
22
services:
3+
dynamodb:
4+
image: amazon/dynamodb-local
5+
ports:
6+
- "8000:8000"
7+
command: ["-jar", "DynamoDBLocal.jar", "-sharedDb", "-inMemory"]
38
memcached:
49
image: memcached:1.6-alpine
510
ports:
611
- "11211:11211"
712
restart: always
813
mysql:
9-
image: mysql:5.7
14+
image: mysql/mysql-server:5.7
1015
environment:
1116
MYSQL_ALLOW_EMPTY_PASSWORD: 1
1217
MYSQL_ROOT_PASSWORD: ""
1318
MYSQL_DATABASE: "forge"
19+
MYSQL_ROOT_HOST: "%"
1420
ports:
1521
- "3306:3306"
1622
restart: always

tests/Filesystem/FilesystemTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class FilesystemTest extends TestCase
2121
*/
2222
public static function setUpTempDir()
2323
{
24-
self::$tempDir = __DIR__.'/tmp';
24+
self::$tempDir = sys_get_temp_dir().'/tmp';
2525
mkdir(self::$tempDir);
2626
}
2727

0 commit comments

Comments
 (0)