Skip to content

Commit 9a2a468

Browse files
committed
prelim tooling setup and configuration which is probably not working yet
Signed-off-by: Joey Smith <jsmith@webinertia.net> Signed-off-by: Joey Smith <jsmith@webinertia.net>
1 parent bc056e0 commit 9a2a468

File tree

16 files changed

+5916
-7
lines changed

16 files changed

+5916
-7
lines changed

.ci/mysql_fixtures.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
echo "Configure MySQL test database"
4+
5+
mysql --user=root --password=Password123 -e "create database laminasdb_test;"

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
/.laminas-ci.json export-ignore
77
/phpunit.xml.dist export-ignore
88
/test/ export-ignore
9-
/clover.xml export-ignore
9+
/clover.xml export-ignore
10+
/vendor/

.laminas-ci/mysql_permissions.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CREATE USER 'gha'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
2+
GRANT ALL PRIVILEGES ON *.* TO 'gha'@'%';
3+
FLUSH PRIVILEGES;

.laminas-ci/phpunit.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
bootstrap="vendor/autoload.php"
6+
colors="true">
7+
<coverage processUncoveredFiles="true">
8+
<include>
9+
<directory suffix=".php">./src</directory>
10+
</include>
11+
</coverage>
12+
13+
<testsuites>
14+
<testsuite name="unit test">
15+
<directory>./test/unit</directory>
16+
</testsuite>
17+
<testsuite name="integration test">
18+
<directory>./test/integration</directory>
19+
</testsuite>
20+
</testsuites>
21+
22+
<listeners>
23+
<listener class="LaminasIntegrationTest\Db\IntegrationTestListener" file="./test/integration/IntegrationTestListener.php"/>
24+
</listeners>
25+
26+
<php>
27+
<!-- Integration Test Variables -->
28+
<env name="TESTS_LAMINAS_DB_ADAPTER_DRIVER_MYSQL" value="true" />
29+
<env name="TESTS_LAMINAS_DB_ADAPTER_DRIVER_MYSQL_HOSTNAME" value="mysql" />
30+
<env name="TESTS_LAMINAS_DB_ADAPTER_DRIVER_MYSQL_USERNAME" value="gha" />
31+
<env name="TESTS_LAMINAS_DB_ADAPTER_DRIVER_MYSQL_PASSWORD" value="password" />
32+
<env name="TESTS_LAMINAS_DB_ADAPTER_DRIVER_MYSQL_DATABASE" value="laminasdb_test" />
33+
</php>
34+
</phpunit>
35+

.laminas-ci/pre-install.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
WORKING_DIRECTORY=$2
4+
JOB=$3
5+
PHP_VERSION=$(echo "${JOB}" | jq -r '.php')
6+
7+
8+
if [ ! -z "$GITHUB_BASE_REF" ] && [[ "$GITHUB_BASE_REF" =~ ^[0-9]+\.[0-9] ]]; then
9+
readarray -td. TARGET_BRANCH_VERSION_PARTS <<<"${GITHUB_BASE_REF}.";
10+
unset 'TARGET_BRANCH_VERSION_PARTS[-1]';
11+
declare -a TARGET_BRANCH_VERSION_PARTS
12+
MAJOR_OF_TARGET_BRANCH=${TARGET_BRANCH_VERSION_PARTS[0]}
13+
MINOR_OF_TARGET_BRANCH=${TARGET_BRANCH_VERSION_PARTS[1]}
14+
15+
export COMPOSER_ROOT_VERISON="${MAJOR_OF_TARGET_BRANCH}.${MINOR_OF_TARGET_BRANCH}.99"
16+
echo "Exported COMPOSER_ROOT_VERISON as ${COMPOSER_ROOT_VERISON}"
17+
fi

.laminas-ci/pre-run.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
TEST_USER=$1
6+
WORKSPACE=$2
7+
JOB=$3
8+
9+
COMMAND=$(echo "${JOB}" | jq -r '.command')
10+
11+
if [[ ! ${COMMAND} =~ phpunit ]]; then
12+
exit 0
13+
fi
14+
15+
PHP_VERSION=$(echo "${JOB}" | jq -r '.php')
16+
17+
# Install CI version of phpunit config
18+
cp .laminas-ci/phpunit.xml phpunit.xml
19+
20+
# Install lsof (used in integration tests)
21+
apt update -qq
22+
apt install -yqq lsof

.psr-container.php.stub

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* File named as .stub to avoid duplicate declaration of the interface in consuming projects
4+
*/
5+
declare(strict_types=1);
6+
7+
namespace Psr\Container {
8+
/**
9+
* Provides automatic type inference for Psalm when retrieving a service from a container using a FQCN
10+
*/
11+
interface ContainerInterface
12+
{
13+
/** @param string|class-string $id */
14+
public function has(string $id): bool;
15+
16+
/**
17+
* @template T of object
18+
* @psalm-param string|class-string<T> $id
19+
* @psalm-return ($id is class-string ? T : mixed)
20+
*/
21+
public function get(string $id): mixed;
22+
}
23+
}

bin/install-deps.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
/usr/bin/composer validate && \
4+
/usr/bin/composer --ignore-platform-reqs install \
5+
--no-ansi --no-progress --no-scripts \
6+
--classmap-authoritative --no-interaction \
7+
--quiet

compose.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
services:
2+
php:
3+
build:
4+
context: ./
5+
dockerfile: docker/php/Dockerfile
6+
args:
7+
- PHP_VERSION=${PHP_VERSION:-8.3.19}
8+
volumes:
9+
- ./:/var/www/html
10+
depends_on:
11+
- mysql
12+
- postgresql
13+
14+
mysql:
15+
build:
16+
context: ./
17+
dockerfile: docker/databases/mysql/Dockerfile
18+
args:
19+
- VERSION=${MYSQL_VERSION:-8.0.41}
20+
ports:
21+
- "3306:3306"
22+
environment:
23+
- MYSQL_DATABASE=${MYSQL_DATABASE:-laminasdb_test}
24+
- MYSQL_USER=${MYSQL_USER:-user}
25+
- MYSQL_PASSWORD=${MYSQL_PASSWORD:-password}
26+
- MYSQL_RANDOM_ROOT_PASSWORD=${MYSQL_RANDOM_ROOT_PASSWORD:-yes}
27+
volumes:
28+
- ./test/integration/TestFixtures/mysql.sql:/docker-entrypoint-initdb.d/mysql.sql
29+
healthcheck:
30+
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
31+
timeout: 20s
32+
retries: 10

composer.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"keywords": [
66
"laminas",
77
"mysql",
8+
"mysqli",
9+
"pdo",
810
"db"
911
],
1012
"homepage": "https://github.com/axleus/laminas-db-mysql/discussions",
@@ -26,13 +28,18 @@
2628
},
2729
"extra": {
2830
"laminas": {
29-
"component": "Laminas\\Db\\Mysql",
31+
"component": "Laminas\\Db\\Mysql\\Adapter",
3032
"config-provider": "Laminas\\Db\\Mysql\\ConfigProvider"
3133
}
3234
},
35+
"repositories": [
36+
{
37+
"type": "vcs",
38+
"url": "https://github.com/axleus/laminas-db"
39+
}
40+
],
3341
"require": {
34-
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
35-
"laminas/laminas-db": "3.0.x"
42+
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0"
3643
},
3744
"require-dev": {
3845
"ext-mysqli": "*",
@@ -73,8 +80,5 @@
7380
"test-integration": "phpunit --colors=always --testsuite \"integration test\"",
7481
"static-analysis": "psalm --shepherd --stats",
7582
"upload-coverage": "coveralls -v"
76-
},
77-
"conflict": {
78-
"laminas/laminas-db": "*"
7983
}
8084
}

0 commit comments

Comments
 (0)