Skip to content

Commit 66868d7

Browse files
authored
Make tests work on github (#15)
1 parent 23af232 commit 66868d7

File tree

6 files changed

+38
-32
lines changed

6 files changed

+38
-32
lines changed

.github/workflows/main.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
restore-keys: ${{ runner.os }}-composer-
3030
- name: composer install
3131
run: composer install --no-progress --prefer-dist --optimize-autoloader
32+
- run: sudo /etc/init.d/mysql start
3233
- name: phpunit
3334
run: php vendor/bin/phpunit
3435
- name: phpcs

bin/mysql_github.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
# Configure data locations
4+
LOG="$HOME/database_test.log"
5+
MYSQL="sudo mysql -uroot -proot"
6+
7+
exec 3>> "$LOG"
8+
9+
finish() {
10+
echo "### Cleaning Database $DBNAME" >&3
11+
echo "DROP DATABASE \`$DBNAME\`;" | $MYSQL >&3
12+
}
13+
14+
# Create the database
15+
DBNAME="$(date +%s%N)"
16+
echo "CREATE DATABASE \`$DBNAME\`;" | $MYSQL >&3
17+
18+
# PHP 7.3 compatibility, does not support caching_sha2_password, use mysql_native_password on a new user instead.
19+
echo "CREATE USER IF NOT EXISTS 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';" | $MYSQL >&3
20+
echo "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost';" | $MYSQL >&3
21+
echo "FLUSH PRIVILEGES;" | $MYSQL >&3
22+
23+
echo "### Trap Set" >&3
24+
trap finish EXIT
25+
26+
echo "driver: pdo_mysql, server_version: 5.6, host: localhost, dbname: ${DBNAME}, user: test, password: test"
27+
echo "### Connection params sent" >&3
28+
29+
# Wait on parent process before cleaning up the database
30+
while read -r DATA; do
31+
sleep .1
32+
done

bin/mysql_travis.sh

-26
This file was deleted.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"bin": [
2525
"bin/mysql_persistent.sh",
26-
"bin/mysql_travis.sh",
26+
"bin/mysql_github.sh",
2727
"bin/mysql_gitlab.sh"
2828
],
2929
"archive": {

src/MysqlPersistentConnection.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class MysqlPersistentConnection implements ConnectionInterface, UrlConnectionInt
2828
*/
2929
const CMD_PERSISTENT = __DIR__ . '/../bin/mysql_persistent.sh';
3030

31-
const CMD_TRAVIS = __DIR__ . '/../bin/mysql_travis.sh';
32-
3331
const CMD_GITLAB = __DIR__ . '/../bin/mysql_gitlab.sh';
3432

33+
const CMD_GITHUB = __DIR__ . '/../bin/mysql_github.sh';
34+
3535
/**
3636
* @var array
3737
*/
@@ -58,8 +58,8 @@ public function __construct()
5858
];
5959

6060
$cmd = self::CMD_PERSISTENT;
61-
if (getenv('TRAVIS')) {
62-
$cmd = self::CMD_TRAVIS;
61+
if (getenv('GITHUB_ACTION')) {
62+
$cmd = self::CMD_GITHUB;
6363
} elseif (getenv('GITLAB_CI')) {
6464
$cmd = self::CMD_GITLAB;
6565
}

test/MysqlPersistentConnectionTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ function ($database) {
7070
case 'mysql':
7171
case 'information_schema':
7272
case 'performance_schema':
73-
case 'travis':
7473
case 'sys':
7574
return false;
7675
default:

0 commit comments

Comments
 (0)