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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
61 changes: 61 additions & 0 deletions .github/workflows/job-pg-query-extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: PG Query Extension

on:
workflow_call:
secrets:
CODECOV_TOKEN:
required: false

jobs:
build:
name: Build and Test Extension
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4']

steps:
- uses: actions/checkout@v5

- name: Setup PHP Environment
uses: ./.github/actions/setup-php-env
with:
php-version: ${{ matrix.php }}
dependencies: locked
coverage: pcov
extensions: ':psr, bcmath, dom, hash, json, mbstring, xml, xmlwriter, xmlreader, zlib, protobuf'
tools: 'composer:v2, phpize, php-config'

- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential autoconf automake libtool protobuf-compiler libprotobuf-c-dev

- name: Build libpg_query and extension
working-directory: src/extension/pg-query-ext
run: |
make clean || true
make build

- name: Run extension tests
working-directory: src/extension/pg-query-ext
run: make test

- name: Install extension
working-directory: src/extension/pg-query-ext
run: |
EXT_DIR=$(php -r 'echo ini_get("extension_dir");')
sudo cp ext/modules/pg_query.so "$EXT_DIR/"
echo "extension=pg_query.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')"
php -m | grep pg_query

- name: Run pg-query library tests
run: composer test:lib:pg-query

- name: Upload to Codecov
uses: ./.github/actions/codecov-report
with:
token: ${{ secrets.CODECOV_TOKEN }}
php-version: ${{ matrix.php }}
dependencies: locked
5 changes: 5 additions & 0 deletions .github/workflows/monorepo-split.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
split_repository: 'snappy'
- local_path: 'src/lib/types'
split_repository: 'types'
- local_path: 'src/lib/pg-query'
split_repository: 'pg-query'

- local_path: 'src/adapter/etl-adapter-avro'
split_repository: 'etl-adapter-avro'
Expand Down Expand Up @@ -86,6 +88,9 @@ jobs:
- local_path: 'src/tools/homebrew'
split_repository: 'homebrew-flow'

- local_path: 'src/extension/pg-query-ext'
split_repository: 'pg-query-ext'

steps:
- uses: actions/checkout@v5

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
extension-tests:
uses: ./.github/workflows/job-extension-tests.yml

pg-query-extension:
uses: ./.github/workflows/job-pg-query-extension.yml
secrets: inherit

windows-tests:
uses: ./.github/workflows/job-windows-tests.yml

Expand Down
6 changes: 5 additions & 1 deletion .nix/pkgs/flow-php/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
php-lz4,
php-brotli,
php-zstd,
php-pg-query-ext,
with-pcov ? true,
with-xdebug ? false,
with-blackfire ? false
with-blackfire ? false,
with-pg-query-ext ? false
}:

let
Expand All @@ -22,13 +24,15 @@ let
(php-lz4.override { inherit php; })
(php-snappy.override { inherit php; })
(php-zstd.override { inherit php; })
protobuf
xmlreader
xmlwriter
zlib
]
++ (if with-xdebug then [xdebug] else [])
++ (if with-pcov then [pcov] else [])
++ (if with-blackfire then [blackfire] else [])
++ (if with-pg-query-ext then [(php-pg-query-ext.override { inherit php; })] else [])
);
in
flowPHP.buildEnv {
Expand Down
72 changes: 72 additions & 0 deletions .nix/pkgs/php-pg-query-ext/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
php,
lib,
stdenv,
fetchFromGitHub,
protobufc,
}:

let
libpg_query = stdenv.mkDerivation {
pname = "libpg_query";
version = "17-6.1.0";

src = fetchFromGitHub {
owner = "pganalyze";
repo = "libpg_query";
rev = "17-6.1.0";
hash = "sha256-UXba2WYyIO7RcFcNZeLL+Q9CwlloMZ5oFfHfL7+j4dU=";
};

buildPhase = ''
make -j$NIX_BUILD_CORES
'';

installPhase = ''
mkdir -p $out/lib $out/include
cp libpg_query.a $out/lib/
cp pg_query.h $out/include/
'';
};

extSrc = builtins.path {
path = ../../../src/extension/pg-query-ext/ext;
name = "pg-query-ext-src";
filter = path: type:
let baseName = baseNameOf path;
in !(
# Exclude build artifacts
baseName == "Makefile" ||
baseName == "configure" ||
baseName == "config.h" ||
baseName == "config.h.in" ||
baseName == "config.log" ||
baseName == "config.status" ||
baseName == "config.nice" ||
baseName == "configure.ac" ||
baseName == "libtool" ||
baseName == "run-tests.php" ||
baseName == "autom4te.cache" ||
baseName == "build" ||
baseName == "modules" ||
baseName == ".libs" ||
lib.hasSuffix ".lo" baseName ||
lib.hasSuffix ".la" baseName ||
lib.hasSuffix ".dep" baseName ||
lib.hasSuffix "~" baseName ||
lib.hasPrefix "Makefile" baseName
);
};
in
php.buildPecl {
pname = "pg_query";
version = "1.0.0";

src = extSrc;

buildInputs = [ protobufc libpg_query ];

configureFlags = [
"--with-pg-query=${libpg_query}"
];
}
19 changes: 17 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"doctrine/dbal": "^3.6 || ^4.0",
"elasticsearch/elasticsearch": "^7.6|^8.0",
"google/apiclient": "^2.13",
"google/protobuf": "^4.0",
"halaxa/json-machine": "^1.1",
"meilisearch/meilisearch-php": "^1.11",
"monolog/monolog": "^2.0||^3.0",
Expand Down Expand Up @@ -93,7 +94,8 @@
"flow-php/parquet-viewer": "self.version",
"flow-php/snappy": "self.version",
"flow-php/symfony-http-foundation-bridge": "self.version",
"flow-php/types": "self.version"
"flow-php/types": "self.version",
"flow-php/pg-query": "self.version"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down Expand Up @@ -130,6 +132,7 @@
"src/lib/parquet/src/Flow",
"src/lib/snappy/src/Flow",
"src/lib/types/src/Flow",
"src/lib/pg-query/src/Flow",
"src/tools/documentation/src/Flow"
],
"Flow\\Doctrine\\Bulk\\": [
Expand Down Expand Up @@ -167,7 +170,9 @@
"src/lib/parquet/src/Flow/Parquet/functions.php",
"src/lib/parquet/src/stubs.php",
"src/lib/snappy/polyfill.php",
"src/lib/types/src/Flow/Types/DSL/functions.php"
"src/lib/types/src/Flow/Types/DSL/functions.php",
"src/lib/pg-query/src/Flow/PgQuery/DSL/functions.php",
"src/lib/pg-query/src/stubs.php"
]
},
"autoload-dev": {
Expand Down Expand Up @@ -203,6 +208,7 @@
"src/lib/parquet/tests/Flow",
"src/lib/snappy/tests/Flow",
"src/lib/types/tests/Flow",
"src/lib/pg-query/tests/Flow",
"src/tools/documentation/tests/Flow"
],
"Flow\\Doctrine\\Bulk\\Tests\\": [
Expand Down Expand Up @@ -247,6 +253,7 @@
"@test:lib:filesystem",
"@test:lib:parquet",
"@test:lib:parquet-viewer",
"@test:lib:pg-query",
"@test:lib:snappy",
"@test:lib:types"
],
Expand Down Expand Up @@ -307,6 +314,9 @@
"test:lib:types": [
"tools/phpunit/vendor/bin/phpunit --testsuite=lib-types-unit --log-junit ./var/phpunit/logs/lib-types-unit.junit.xml --coverage-clover=./var/phpunit/coverage/clover/lib-types-unit.coverage.xml --coverage-html=./var/phpunit/coverage/html/lib-types-unit"
],
"test:lib:pg-query": [
"tools/phpunit/vendor/bin/phpunit --testsuite=lib-pg-query-unit --log-junit ./var/phpunit/logs/lib-pg-query-unit.junit.xml --coverage-clover=./var/phpunit/coverage/clover/lib-pg-query-unit.coverage.xml --coverage-html=./var/phpunit/coverage/html/lib-pg-query-unit"
],
"test:bridge:filesystem-azure": [
"tools/phpunit/vendor/bin/phpunit --testsuite=bridge-filesystem-azure-unit --log-junit ./var/phpunit/logs/bridge-filesystem-azure-unit.junit.xml --coverage-clover=./var/phpunit/coverage/clover/bridge-filesystem-azure-unit.coverage.xml --coverage-html=./var/phpunit/coverage/html/bridge-filesystem-azure-unit",
"tools/phpunit/vendor/bin/phpunit --testsuite=bridge-filesystem-azure-integration --log-junit ./var/phpunit/logs/bridge-filesystem-azure-integration.junit.xml --coverage-clover=./var/phpunit/coverage/clover/bridge-filesystem-azure-integration.coverage.xml --coverage-html=./var/phpunit/coverage/html/bridge-filesystem-azure-integration"
Expand Down Expand Up @@ -479,6 +489,11 @@
"thrift --gen php --out src/lib/parquet/src src/lib/parquet/src/Flow/Parquet/Resources/Thrift/parquet.thrift",
"@cs:php:fix"
],
"build:pg-query:protobuf": [
"rm -rf src/lib/pg-query/src/Flow/PgQuery/Protobuf",
"protoc --php_out=src/lib/pg-query/src --proto_path=src/lib/pg-query/resources/proto pg_query.proto",
"@cs:php:fix"
],
"pre-autoload-dump": [
"Google\\Task\\Composer::cleanup"
],
Expand Down
46 changes: 45 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading