Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit be8e59e

Browse files
Hidde Boomsmanicoschoenmaker
Hidde Boomsma
authored andcommittedApr 19, 2018
add gitlab support (#6)
1 parent 06a05d5 commit be8e59e

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed
 

‎bin/mysql_gitlab.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
# Configure data locations
4+
LOG="pages/${CI_BUILD_NAME}_database_test.log"
5+
MYSQL="mysql -h${MYSQL_HOST} -P3306 -uroot -p${MYSQL_ROOT_PASSWORD}"
6+
exec 3>> "$LOG"
7+
8+
finish() {
9+
echo "### Cleaning Database $DBNAME" >&3
10+
echo "DROP DATABASE \`$DBNAME\`;" | $MYSQL >&3
11+
}
12+
13+
# Create the database
14+
DBNAME="$(date +%s%N)"
15+
echo "CREATE DATABASE \`$DBNAME\`;" | $MYSQL >&3
16+
17+
echo "### Trap Set" >&3
18+
trap finish EXIT
19+
20+
echo "driver: pdo_mysql, host: mariadb, port: 3306, dbname: ${DBNAME}, user: root, password: ${MYSQL_ROOT_PASSWORD}"
21+
echo "### Connection params sent" >&3
22+
23+
# Wait on parent process before cleaning up the database
24+
while read -r _; do
25+
sleep .1
26+
done

‎composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
},
2424
"bin": [
2525
"bin/mysql_persistent.sh",
26-
"bin/mysql_travis.sh"
26+
"bin/mysql_travis.sh",
27+
"bin/mysql_gitlab.sh"
2728
],
2829
"archive": {
2930
"exclude": [

‎src/MysqlPersistentConnection.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class MysqlPersistentConnection implements ConnectionInterface
2828

2929
const CMD_TRAVIS = __DIR__ . '/../bin/mysql_travis.sh';
3030

31+
const CMD_GITLAB = __DIR__ . '/../bin/mysql_gitlab.sh';
32+
3133
/**
3234
* @var array
3335
*/
@@ -53,7 +55,13 @@ public function __construct()
5355
1 => ['pipe', 'w'], // stdout is a pipe that the child will write to
5456
];
5557

56-
$cmd = getenv('TRAVIS') ? self::CMD_TRAVIS : self::CMD_PERSISTENT;
58+
$cmd = self::CMD_PERSISTENT;
59+
if (getenv('TRAVIS')) {
60+
$cmd = self::CMD_TRAVIS;
61+
} elseif (getenv('GITLAB_CI')) {
62+
$cmd = self::CMD_GITLAB;
63+
}
64+
5765
$this->process = proc_open($cmd, $descriptor_spec, $pipes);
5866
$data = fread($pipes[1], 1024);
5967

0 commit comments

Comments
 (0)
Please sign in to comment.