Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .ci/pgsql_fixtures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

echo "Configure PostgreSQL test database"

psql -U postgres -c 'create database phpdb_test;'
psql -U postgres -c "alter role postgres password 'postgres'"
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/.gitattributes export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/phpcs.xml export-ignore
/renovate.json export-ignore
/.laminas-ci.json export-ignore
/.laminas-ci/ export-ignore
/.ci/ export-ignore
/phpunit.xml.dist export-ignore
/test/ export-ignore
/clover.xml export-ignore
45 changes: 45 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Continuous Integration"

on:
pull_request:
push:
branches:
tags:

jobs:
matrix:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Gather CI configuration
id: matrix
uses: laminas/laminas-ci-matrix-action@v1

qa:
name: QA Checks
needs: [matrix]
runs-on: ${{ matrix.operatingSystem }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
steps:
- name: ${{ matrix.name }}
uses: laminas/laminas-continuous-integration-action@v1
with:
job: ${{ matrix.job }}
services:
postgres:
image: postgres
env:
POSTGRES_USER: 'gha'
POSTGRES_PASSWORD: 'password'
POSTGRES_DB: 'phpdb_test'
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 3
ports:
- 5432
15 changes: 15 additions & 0 deletions .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Automatic Releases"

on:
milestone:
types:
- "closed"

jobs:
release:
uses: laminas/workflow-automatic-releases/.github/workflows/release-on-milestone-closed.yml@1.x
secrets:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
ORGANIZATION_ADMIN_TOKEN: ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.phpcs-cache
/.phpstan-cache
/phpstan.neon
/.phpunit.cache
/.phpunit.result.cache
/phpunit.xml
/vendor/
/xdebug_filter.php
/clover.xml
12 changes: 12 additions & 0 deletions .laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"additional_checks": [
{
"name": "PhpStan",
"job": {
"php": "8.2",
"dependencies": "latest",
"command": "composer require --dev phpstan/phpstan && vendor/bin/phpstan analyse"
}
}
]
}
29 changes: 29 additions & 0 deletions .laminas-ci/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
requireCoverageMetadata="true"
colors="true">

<extensions>
<bootstrap class="PhpDbIntegrationTest\Adapter\Pgsql\Extension\ListenerExtension" />
</extensions>
<testsuites>
<testsuite name="unit test">
<directory>./test/unit</directory>
</testsuite>
<testsuite name="integration test">
<directory>./test/integration</directory>
</testsuite>
</testsuites>
<php>
<!-- Integration Test Variables -->
<env name="TESTS_PHPDB_ADAPTER_PGSQL" value="true" /><!-- todo: remove this env variable as its no longer needed-->
<env name="TESTS_PHPDB_ADAPTER_PGSQL_HOSTNAME" value="pgsql" />
<env name="TESTS_PHPDB_ADAPTER_PGSQL_USERNAME" value="gha" />
<env name="TESTS_PHPDB_ADAPTER_PGSQL_PASSWORD" value="password" />
<env name="TESTS_PHPDB_ADAPTER_PGSQL_DATABASE" value="phpdb_test" />
</php>
</phpunit>

17 changes: 17 additions & 0 deletions .laminas-ci/pre-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

WORKING_DIRECTORY=$2
JOB=$3
PHP_VERSION=$(echo "${JOB}" | jq -r '.php')


if [ ! -z "$GITHUB_BASE_REF" ] && [[ "$GITHUB_BASE_REF" =~ ^[0-9]+\.[0-9] ]]; then
readarray -td. TARGET_BRANCH_VERSION_PARTS <<<"${GITHUB_BASE_REF}.";
unset 'TARGET_BRANCH_VERSION_PARTS[-1]';
declare -a TARGET_BRANCH_VERSION_PARTS
MAJOR_OF_TARGET_BRANCH=${TARGET_BRANCH_VERSION_PARTS[0]}
MINOR_OF_TARGET_BRANCH=${TARGET_BRANCH_VERSION_PARTS[1]}

export COMPOSER_ROOT_VERISON="${MAJOR_OF_TARGET_BRANCH}.${MINOR_OF_TARGET_BRANCH}.99"
echo "Exported COMPOSER_ROOT_VERISON as ${COMPOSER_ROOT_VERISON}"
fi
22 changes: 22 additions & 0 deletions .laminas-ci/pre-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

TEST_USER=$1
WORKSPACE=$2
JOB=$3

COMMAND=$(echo "${JOB}" | jq -r '.command')

if [[ ! ${COMMAND} =~ phpunit ]]; then
exit 0
fi

PHP_VERSION=$(echo "${JOB}" | jq -r '.php')

# Install CI version of phpunit config
cp .laminas-ci/phpunit.xml phpunit.xml

# Install lsof (used in integration tests)
apt update -qq
apt install -yqq lsof
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# axleus-repo-template
Template repo for starting all new repo's
# phpdb-adapter-pgsql

PostgreSQL Adapter for PHPDb
7 changes: 7 additions & 0 deletions bin/install-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

composer validate && \
composer --ignore-platform-reqs install \
--no-ansi --no-progress --no-scripts \
--classmap-authoritative --no-interaction \
--quiet
33 changes: 33 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
services:
php:
build:
context: ./
dockerfile: docker/php/Dockerfile
args:
- PHP_VERSION=${PHP_VERSION:-8.3.19}
volumes:
- ./:/var/www/html
depends_on:
- postgresql

postgresql:
build:
context: ./
dockerfile: docker/databases/postgresql/Dockerfile
args:
- VERSION=${VERSION:-17.4}
- ALPINE_VERSION=${ALPINE_VERSION:-3.21}
ports:
- "5432:5432"
volumes:
- ./test/integration/TestFixtures/pgsql.sql:/docker-entrypoint-initdb.d/pgsql.sql
environment:
- POSTGRES_DB=${POSTGRES_DB:-phpdb_test}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
healthcheck:
test: ["CMD-SHELL", "sh -c 'pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-phpdb_test}'"]
interval: 30s
timeout: 60s
retries: 5
start_period: 80s
75 changes: 75 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "php-db/phpdb-adapter-pgsql",
"description": "PostgreSQL support for php-db",
"license": "BSD-3-Clause",
"keywords": [
"php-db",
"pgsql",
"db"
],
"homepage": "https://php-db.dev",
"support": {
"issues": "https://github.com/php-db/phpdb-adapter-pgsql/issues",
"source": "https://github.com/php-db/phpdb-adapter-pgsql",
"forum": "https://github.com/php-db/phpdb-adapter-pgsql/discussions"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true,
"platform": {
"php": "8.2.99"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
"laminas": {
"config-provider": "PhpDb\\Adapter\\Pgsql\\ConfigProvider"
}
},
"require": {
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
"php-db/phpdb": "^0.2.1"
},
"require-dev": {
"laminas/laminas-coding-standard": "^3.0.1",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^11.5.15"
},
"suggest": {
"ext-pdo": "*",
"ext-pdo_pgsql": "*",
"ext-pgsql": "*",
"laminas/laminas-servicemanager": "Laminas\\ServiceManager component"
},
"autoload": {
"psr-4": {
"PhpDb\\Adapter\\Pgsql\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"PhpDbTest\\Adapter\\Pgsql\\": "test/unit/",
"PhpDbIntegrationTest\\Adapter\\Pgsql\\": "test/integration/"
}
},
"scripts": {
"check": [
"@cs-check",
"@static-analysis",
"@test",
"@test-integration"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always --testsuite \"unit test\"",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"test-integration": "phpunit --colors=always --testsuite \"integration test\"",
"static-analysis": "vendor/bin/phpstan analyse --memory-limit=256M",
"sa-generate-baseline": "vendor/bin/phpstan analyse --memory-limit=256M --generate-baseline",
"upload-coverage": "coveralls -v"
}
}
Loading