Skip to content

Commit 6a6314c

Browse files
committed
fix: add CI environment variable support to MariaDB config and workflow
- Update examples/config.mariadb.php to check for DB_* environment variables (matching MSSQL pattern) and use them if available, falling back to local development defaults - Update GitHub Actions workflow to export DB_* variables for MariaDB examples (matching MSSQL pattern) to ensure examples use correct CI database settings - This fixes MariaDB example failures where examples/config.mariadb.php was loaded with local values instead of CI values
1 parent 8a2f86b commit 6a6314c

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ jobs:
9797
- name: Test MariaDB Examples
9898
run: |
9999
export PDODB_DRIVER=mariadb
100+
export DB_USER="testuser"
101+
export DB_PASS="testpass"
102+
export DB_HOST="127.0.0.1"
103+
export DB_PORT="3305"
104+
export DB_NAME="testdb"
100105
./scripts/test-examples.sh --verbose
101106
- name: Upload MariaDB coverage to Codecov
102107
uses: codecov/codecov-action@v4

examples/config.mariadb.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
11
<?php
22
/**
3-
* MySQL Database configuration for examples
3+
* MariaDB Database configuration for examples
4+
*
5+
* This config file checks for CI environment variables (DB_*) first,
6+
* then falls back to local development defaults.
47
*/
58

9+
// Check for CI environment variables first
10+
$dbUser = getenv('DB_USER');
11+
$dbPass = getenv('DB_PASS');
12+
$dbHost = getenv('DB_HOST');
13+
$dbPort = getenv('DB_PORT');
14+
$dbName = getenv('DB_NAME');
15+
$dbCharset = getenv('DB_CHARSET');
16+
17+
// If CI variables are set, use them
18+
if ($dbUser !== false && $dbPass !== false) {
19+
return [
20+
'driver' => 'mariadb',
21+
'host' => $dbHost !== false ? $dbHost : '127.0.0.1',
22+
'port' => $dbPort !== false ? (int)$dbPort : 3305,
23+
'username' => $dbUser,
24+
'password' => $dbPass,
25+
'dbname' => $dbName !== false ? $dbName : 'testdb',
26+
'charset' => $dbCharset !== false ? $dbCharset : 'utf8mb4',
27+
];
28+
}
29+
30+
// Fallback to local development defaults
631
return [
732
'driver' => 'mariadb',
833
'host' => '127.0.0.1',

0 commit comments

Comments
 (0)