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
  •  
  •  
  •  
13 changes: 10 additions & 3 deletions .github/actions/setup-php/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ inputs:
required: false
default: ""
coverage:
description: "Coverage driver: none, pcov or xdebug"
description: "Coverage driver: none, turbocov or xdebug"
required: false
default: "none"

Expand Down Expand Up @@ -70,8 +70,15 @@ runs:
php-version: ${{ inputs.php-version }}
extensions: ${{ inputs.extensions }}
ini-values: ${{ inputs.ini-values }}
tools: ${{ inputs.tools }}
coverage: ${{ inputs.coverage }}
tools: ${{ inputs.coverage == 'turbocov' && (inputs.tools != '' && format('{0}, pie:1.6.1', inputs.tools) || 'pie:1.6.1') || inputs.tools }}
coverage: ${{ inputs.coverage == 'turbocov' && 'none' || inputs.coverage }}

- name: "Install Turbocov"
if: ${{ inputs.coverage == 'turbocov' }}
shell: bash
run: |
sudo pie install shipmonk/turbocov:0.1.2
php --ri turbocov

# setup-php must not fall back to the other build without a failure
- name: "Fail on a wrong thread safety"
Expand Down
28 changes: 17 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ jobs:
uses: "./.github/actions/setup-php"
with:
php-version: "${{ matrix.php-version }}"
coverage: ${{ matrix.coverage && 'pcov' || 'none' }}
coverage: ${{ matrix.coverage && 'turbocov' || 'none' }}
extensions: ':psr, apcu, bcmath, dom, hash, json, mbstring, xml, xmlwriter, xmlreader, zlib, curl, pgsql, grpc, protobuf, :redis'
ini-values: 'memory_limit=-1, post_max_size=32M, upload_max_filesize=32M, apc.enable_cli=1'
tools: 'composer:v2'
Expand Down Expand Up @@ -376,7 +376,7 @@ jobs:
uses: "./.github/actions/setup-php"
with:
php-version: "${{ matrix.php-version }}"
coverage: ${{ matrix.php-version == '8.5' && 'pcov' || 'none' }}
coverage: ${{ matrix.php-version == '8.5' && 'turbocov' || 'none' }}
extensions: ':psr, bcmath, dom, hash, json, mbstring, xml, xmlwriter, xmlreader, zlib, brotli, lz4, zstd, snappy-https://github.com/kjdev/[email protected], :redis'
ini-values: 'memory_limit=-1'
tools: 'composer:v2'
Expand Down Expand Up @@ -452,7 +452,7 @@ jobs:
uses: "./.github/actions/setup-php"
with:
php-version: "${{ matrix.php-version }}"
coverage: ${{ matrix.php-version == '8.5' && 'pcov' || 'none' }}
coverage: ${{ (matrix.phpunit-version == '13' && matrix.php-version == '8.6') && 'turbocov' || 'none' }}
extensions: ':psr, bcmath, dom, hash, json, mbstring, xml, xmlwriter, xmlreader, zlib, curl, pgsql, grpc, protobuf, :redis'
ini-values: 'memory_limit=-1'
tools: 'composer:v2'
Expand All @@ -479,21 +479,27 @@ jobs:
- *pg-query-enable

- name: "Install PHPUnit ${{ matrix.phpunit-version }}"
env:
PHPUNIT_VERSION: ${{ matrix.phpunit-version }}
run: |
composer config --working-dir=tools/phpunit --unset platform
composer config --working-dir=tools/phpunit --unset platform.php
if [ "$PHPUNIT_VERSION" != "13" ]; then
composer remove --working-dir=tools/phpunit --no-update --dev shipmonk/turbocov-phpunit
sed -i '/<coverage driver=/d' phpunit.xml.dist
fi
composer require --working-dir=tools/phpunit --no-interaction --no-progress -W \
"phpunit/phpunit:^${{ matrix.phpunit-version }}"
"phpunit/phpunit:^${PHPUNIT_VERSION}"

- name: "Show PHPUnit version"
run: tools/phpunit/vendor/bin/phpunit --version

- name: "Test"
run: just test --testsuite bridge-phpunit-postgresql-unit,bridge-phpunit-postgresql-integration,bridge-phpunit-telemetry-unit ${{ matrix.php-version == '8.5' && '--coverage-clover=./var/phpunit/coverage/clover/coverage.xml' || '' }}
run: just test --testsuite bridge-phpunit-postgresql-unit,bridge-phpunit-postgresql-integration,bridge-phpunit-telemetry-unit ${{ (matrix.phpunit-version == '13' && matrix.php-version == '8.6') && '--coverage-clover=./var/phpunit/coverage/clover/coverage.xml' || '' }}
env:
PGSQL_DATABASE_URL: pgsql://postgres:[email protected]:${{ job.services.postgres.ports['5432'] }}/postgres?serverVersion=18&charset=utf8

- name: Upload to Codecov
if: ${{ !cancelled() && matrix.php-version == '8.5' && matrix.phpunit-version == '11' }}
if: ${{ !cancelled() && matrix.phpunit-version == '13' && matrix.php-version == '8.6' }}
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
use_oidc: true
Expand Down Expand Up @@ -553,7 +559,7 @@ jobs:
uses: "./.github/actions/setup-php"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
coverage: "turbocov"
extensions: 'none, apcu, bcmath, ctype, curl, dom, filter, iconv, mbstring, openssl, pcntl, pgsql, phar, posix, simplexml, sodium, tokenizer, xml, xmlreader, xmlwriter, zip, zlib'
ini-values: 'memory_limit=-1, apc.enable_cli=1'
tools: 'composer:v2'
Expand Down Expand Up @@ -625,7 +631,7 @@ jobs:
extensions: ':psr, bcmath, dom, hash, json, mbstring, xml, xmlwriter, xmlreader, zlib, zstd, :redis'
ini-values: 'memory_limit=-1'
tools: 'composer:v2, php-config'
coverage: ${{ (matrix.php == '8.5' && matrix.ts == 'nts') && 'pcov' || 'none' }}
coverage: ${{ (matrix.php == '8.5' && matrix.ts == 'nts') && 'turbocov' || 'none' }}

- name: Install just
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
Expand Down Expand Up @@ -881,7 +887,7 @@ jobs:
extensions: ':psr, bcmath, dom, hash, json, mbstring, xml, xmlwriter, xmlreader, zlib, zstd, :redis'
ini-values: 'memory_limit=-1'
tools: 'composer:v2, php-config'
coverage: ${{ (matrix.php == '8.5' && matrix.ts == 'nts') && 'pcov' || 'none' }}
coverage: ${{ (matrix.php == '8.5' && matrix.ts == 'nts') && 'turbocov' || 'none' }}

- name: Install just
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
Expand Down Expand Up @@ -1358,7 +1364,7 @@ jobs:
uses: "./.github/actions/setup-php"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
coverage: "none"
extensions: ':psr, bcmath, dom, hash, json, mbstring, xml, xmlwriter, xmlreader, zlib, :redis'
ini-values: 'memory_limit=-1'
tools: 'composer:v2'
Expand Down
6 changes: 0 additions & 6 deletions .nix/php/lib/pcov.ini.dist

This file was deleted.

14 changes: 3 additions & 11 deletions .nix/pkgs/flow-php/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
php-lz4,
php-brotli,
php-zstd,
php-turbocov,
php-pg-query-ext,
php-arrow-ext,
php-flow-php-ext,
with-pcov ? true,
with-turbocov ? true,
with-xdebug ? false,
with-blackfire ? false,
with-php-benchmark ? false,
Expand Down Expand Up @@ -63,7 +64,7 @@ let
]
++ (if all ? opcache then [opcache] else [])
++ (if with-xdebug then [xdebug] else [])
++ (if with-pcov then [pcov] else [])
++ (if with-turbocov then [(php-turbocov.override { inherit php; })] else [])
++ (if with-blackfire then [blackfire] else [])
++ (if with-pg-query-ext then [(php-pg-query-ext.override { inherit php; })] else [])
++ (if with-arrow-ext then [(php-arrow-ext.override { inherit php; })] else [])
Expand Down Expand Up @@ -106,15 +107,6 @@ flowPHP.buildEnv {
else ""
)
+ "\n"
+ (
if with-pcov
then
if builtins.pathExists ./../../php/lib/pcov.ini
then builtins.readFile ./../../php/lib/pcov.ini
else builtins.readFile ./../../php/lib/pcov.ini.dist
else ""
)
+ "\n"
+ (
if with-php-benchmark || with-blackfire
then
Expand Down
19 changes: 19 additions & 0 deletions .nix/pkgs/php-turbocov/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
php,
fetchFromGitHub,
pcre2,
}:

php.buildPecl {
pname = "turbocov";
version = "0.1.2";

src = fetchFromGitHub {
owner = "shipmonk-rnd";
repo = "turbocov";
tag = "0.1.2";
hash = "sha256-Qjm9I8+98I9McwiSTDaczwsMMd+gAzVMQKkJTkH/whw=";
};

buildInputs = [ pcre2.dev ];
}
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ build: lint analyze test test-mutation
# Run PHPUnit. Extra arguments are forwarded (e.g. `just test --filter=foo`).
[positional-arguments]
test *args:
tools/phpunit/vendor/bin/phpunit "$@"
php -d turbocov.collect_paths=src tools/phpunit/vendor/bin/phpunit "$@"

# Run mutation testing with Infection.
[positional-arguments]
Expand Down
4 changes: 2 additions & 2 deletions documentation/contributing/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The defaults are in `phpbench.json.dist`:
- The remote executor. It isolates each iteration in its own process, and it is the only executor that measures
`mem_peak`.
- `revs=1`, because one end-to-end pipeline is one measurement.
- `iterations=3`, `warmup=1`, `opcache.enable_cli=1`, `pcov.enabled=0` and no `memory_limit`.
- `iterations=3`, `warmup=1`, `opcache.enable_cli=1` and no `memory_limit`.

## Row-count

Expand Down Expand Up @@ -129,7 +129,7 @@ hyperfine --runs 1 --prepare 'sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
- Give each engine the same N. DuckDB takes `SET threads TO N`, Polars `POLARS_MAX_THREADS=N`, Spark `local[N]`
and Flow N workers. The Flow coordinator process also uses CPU in addition to its N workers. Write this next to
each table.
- Time Flow in a `--arg with-php-benchmark true` shell, without pcov or blackfire.
- Time Flow in a `--arg with-php-benchmark true` shell, without Turbocov or blackfire.
- Spark starts a JVM for each submission. The warmup run takes this cost.
- DuckDB and Polars infer the column types from the CSV. Spark runs with `inferSchema=True`, which reads the file a
second time.
8 changes: 6 additions & 2 deletions documentation/contributing/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ cp .env.dist .env
> now comes from `.env.dist` / `.env`. An old `phpunit.xml` keeps the old bootstrap and environment, and it does not
> use the shared configuration.

For code coverage, install [pcov](https://pecl.php.net/package/pcov).
For code coverage, install [Turbocov](https://github.com/shipmonk-rnd/turbocov):

The tests pass without the pcov extension. Without it, you cannot run mutation tests.
```shell
pie install shipmonk/turbocov
```

Without it, the tests pass and you cannot run coverage or mutation tests.

Run `just --list` to see all available tasks.

Expand Down
17 changes: 7 additions & 10 deletions documentation/contributing/nix.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,16 @@ The nix shell has a predefined php.ini. If it is not sufficient for you, create

If that file is not there, the shell uses the default php.ini.dist from the same location.

## Pcov
## Turbocov

- `pcov`: necessary for code coverage
- `turbocov`: necessary for code coverage

To start the nix shell without the pcov extension, use the `--arg with-pcov false` flag:
To start the nix shell without the Turbocov extension, use the `--arg with-turbocov false` flag:

```shell

nix-shell --arg with-pcov false
nix-shell --arg with-turbocov false
```

To configure pcov, create a file `./.nix/php/lib/pcov.ini` with your pcov configuration.

## Xdebug

- `xdebug`: necessary for debugging
Expand Down Expand Up @@ -138,13 +135,13 @@ it.
## Benchmarking PHP

The default shell runs PHP with a development configuration. OPcache is off for the CLI, so the JIT is also off.
`zend.assertions` is `1`. pcov is loaded. To time Flow with a production configuration:
`zend.assertions` is `1`. Turbocov is loaded. To time Flow with a production configuration:

```shell
nix-shell --arg with-php-benchmark true
```

The flag removes pcov, xdebug and blackfire. If you combine the flag with one of them, the shell fails at evaluation.
The flag removes Turbocov, xdebug and blackfire. If you combine the flag with one of them, the shell fails at evaluation.
The flag appends `./.nix/php/lib/benchmark.ini.dist` to `php.ini`:

```ini
Expand All @@ -169,7 +166,7 @@ To change the PHP version, start the nix shell with the `--arg php-version 8.6`
nix-shell --arg php-version 8.6
```

On PHP 8.6 the shell starts without pcov and protobuf, because nixpkgs does not build them for PHP 8.6 yet.
On PHP 8.6 the shell starts without protobuf, because nixpkgs does not build it for PHP 8.6 yet.

> Usually, do not change the PHP version. Development must always use the lowest supported PHP version.
>
Expand Down
3 changes: 1 addition & 2 deletions phpbench.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"runner.php_config": {
"memory_limit": "-1",
"opcache.enable": "1",
"opcache.enable_cli": "1",
"pcov.enabled": "0"
"opcache.enable_cli": "1"
},
"report.generators": {
"flow-report": {
Expand Down
15 changes: 15 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,23 @@
<file>src/lib/azure-sdk/src/Flow/Azure/SDK/DSL/functions.php</file>
<file>src/bridge/telemetry/otlp/src/Flow/Bridge/Telemetry/OTLP/DSL/functions.php</file>
<file>src/bridge/postgresql/valinor/src/Flow/PostgreSql/Bridge/Valinor/DSL/functions.php</file>
<directory>src/**/**/vendor</directory>
<file>src/adapter/etl-adapter-postgresql/src/Flow/ETL/Adapter/PostgreSql/functions.php</file>
<file>src/bridge/monolog/telemetry/src/Flow/Bridge/Monolog/Telemetry/DSL/functions.php</file>
<file>src/bridge/phpunit/postgresql/src/Flow/Bridge/PHPUnit/PostgreSQL/DSL/functions.php</file>
<file>src/bridge/psr18/telemetry/src/Flow/Bridge/Psr18/Telemetry/DSL/functions.php</file>
<file>src/bridge/psr3/telemetry/src/Flow/Bridge/Psr3/Telemetry/DSL/functions.php</file>
<file>src/bridge/psr7/telemetry/src/Flow/Bridge/Psr7/Telemetry/DSL/functions.php</file>
<file>src/bridge/symfony/http-foundation-telemetry/src/Flow/Bridge/Symfony/HttpFoundationTelemetry/DSL/functions.php</file>
<file>src/bridge/symfony/telemetry-bundle/src/Flow/Bridge/Symfony/TelemetryBundle/DSL/functions.php</file>
<file>src/core/etl/src/Flow/Floe/DSL/functions.php</file>
<file>src/core/etl/src/Flow/Serializer/DSL/functions.php</file>
<file>src/lib/parquet/src/Flow/Parquet/Binary/functions.php</file>
<file>src/lib/parquet/src/Flow/Parquet/DSL/functions.php</file>
<file>src/lib/postgresql/src/Flow/PostgreSql/Migrations/DSL/functions.php</file>
</exclude>
</source>
<coverage driver="ShipMonk\Turbocov\TurbocovDriver"/>
<extensions>
<bootstrap class="Flow\Bridge\PHPUnit\Telemetry\TelemetryExtension">
<parameter name="service_name" value="flow-php-test-suite"/>
Expand Down
10 changes: 6 additions & 4 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
php-version ? 8.5,
with-blackfire ? false,
with-xdebug ? false,
with-pcov ? php-version != 8.6 && !with-blackfire && !with-php-benchmark,
with-turbocov ? !with-blackfire && !with-php-benchmark && !with-xdebug,
with-php-benchmark ? false,
with-duckdb ? false,
with-polars ? false,
Expand All @@ -22,7 +22,8 @@
assert (!(with-rust && with-arrow-ext)) || builtins.throw "Cannot use --arg with-rust true and --arg with-arrow-ext true together. Use: --arg with-arrow-ext false --arg with-rust true";
assert (!(with-rust && with-flow-php-ext)) || builtins.throw "Cannot use --arg with-rust true and --arg with-flow-php-ext true together. Use: --arg with-flow-php-ext false --arg with-rust true";
assert (!(with-c && with-pg-query-ext)) || builtins.throw "Cannot use --arg with-c true and --arg with-pg-query-ext true together. Use: --arg with-pg-query-ext false --arg with-c true";
assert (!(with-php-benchmark && with-pcov)) || builtins.throw "Cannot use --arg with-php-benchmark true and --arg with-pcov true together: pcov distorts timings.";
assert (!(with-php-benchmark && with-turbocov)) || builtins.throw "Cannot use --arg with-php-benchmark true and --arg with-turbocov true together: Turbocov distorts timings.";
assert (!(with-turbocov && with-xdebug)) || builtins.throw "Turbocov cannot run together with Xdebug";
assert (!(with-php-benchmark && with-xdebug)) || builtins.throw "Cannot use --arg with-php-benchmark true and --arg with-xdebug true together: xdebug distorts timings.";
assert (!(with-php-benchmark && with-blackfire)) || builtins.throw "Cannot use --arg with-php-benchmark true and --arg with-blackfire true together: time without the probe, profile with --arg with-blackfire true alone.";

Expand Down Expand Up @@ -59,6 +60,7 @@ let
throw "Unsupported php version, Flow supports 8.5 and 8.6";

php-brotli = pkgs.callPackage ./.nix/pkgs/php-brotli/package.nix { php = base-php; };
php-turbocov = pkgs.callPackage ./.nix/pkgs/php-turbocov/package.nix { php = base-php; };
php-snappy = pkgs.callPackage ./.nix/pkgs/php-snappy/package.nix { php = base-php; };
php-lz4 = pkgs.callPackage ./.nix/pkgs/php-lz4/package.nix { php = base-php; };
php-zstd = pkgs.callPackage ./.nix/pkgs/php-zstd/package.nix { php = base-php; };
Expand Down Expand Up @@ -101,8 +103,8 @@ let

php = pkgs.callPackage ./.nix/pkgs/flow-php/package.nix {
php = base-php;
inherit php-snappy php-lz4 php-brotli php-zstd php-pg-query-ext php-arrow-ext php-flow-php-ext
with-pcov with-xdebug with-blackfire with-php-benchmark with-pg-query-ext with-arrow-ext with-flow-php-ext with-grpc with-protobuf;
inherit php-snappy php-lz4 php-brotli php-zstd php-turbocov php-pg-query-ext php-arrow-ext php-flow-php-ext
with-turbocov with-xdebug with-blackfire with-php-benchmark with-pg-query-ext with-arrow-ext with-flow-php-ext with-grpc with-protobuf;
};

polars-python = pkgs.python3.withPackages (ps: [ ps.polars ps.pyarrow ]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function test_signal_stop(): void

public function test_using_pattern_path(): void
{
$this->expectExceptionMessage("AvroLoader path can't be pattern, given: /path/*/pattern.avro");
$this->expectExceptionMessageIsOrContains("AvroLoader path can't be pattern, given: /path/*/pattern.avro");

to_avro(path('/path/*/pattern.avro'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class ChartJSLoaderTest extends FlowTestCase
public function test_chartjs_output_path_on_a_mismatched_filesystem_throws(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Filesystem Flow\\Filesystem\\Local\\NativeLocalFilesystem serves "file://" paths, '
$this->expectExceptionMessageIsOrContains('Filesystem Flow\\Filesystem\\Local\\NativeLocalFilesystem serves "file://" paths, '
. 'given: "memory://chart.html".');

to_chartjs(bar_chart(ref('Date'), refs(ref('Revenue'))))->withOutputPath(path('memory://chart.html'));
Expand Down Expand Up @@ -65,7 +65,7 @@ public function test_closure_reports_the_removal_the_template_read_and_the_write
public function test_chartjs_output_path_without_an_extension_throws_at_build(): void
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Stream path must have an extension, given: ');
$this->expectExceptionMessageIsOrContains('Stream path must have an extension, given: ');

to_chartjs(bar_chart(ref('Date'), refs(ref('Revenue'))))->withOutputPath(path(__DIR__ . '/var/no-extension'));
}
Expand Down
Loading