Skip to content

Commit 3cc3684

Browse files
committed
Isolate gRPC tests
1 parent 4d94537 commit 3cc3684

File tree

6 files changed

+142
-92
lines changed

6 files changed

+142
-92
lines changed

.github/workflows/emulator-tests.yml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,43 +32,27 @@ jobs:
3232
runs-on: ubuntu-latest
3333

3434
env:
35-
php-version: '8.4'
36-
extensions: grpc
37-
key: cache-v1
35+
php-version: '8.5'
3836

3937
steps:
4038
- name: Checkout code
4139
uses: actions/checkout@v6
4240
with:
4341
ref: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.sha) || github.sha }}
4442

45-
- name: Setup cache environment
46-
id: extcache
47-
uses: shivammathur/cache-extensions@v1
48-
with:
49-
php-version: ${{ env.php-version }}
50-
extensions: ${{ env.extensions }}
51-
key: ${{ env.key }}
52-
53-
- name: Cache extensions
54-
uses: actions/cache@v5.0.3
55-
with:
56-
path: ${{ steps.extcache.outputs.dir }}
57-
key: ${{ steps.extcache.outputs.key }}
58-
restore-keys: ${{ steps.extcache.outputs.key }}
59-
6043
- name: Setup PHP
6144
uses: shivammathur/setup-php@v2
6245
with:
6346
php-version: ${{ env.php-version }}
64-
extensions: ${{ env.extensions }}
6547
tools: composer, pecl
6648
coverage: xdebug
6749

6850
- name: Setup problem matchers for PHP
6951
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
7052

7153
- uses: "ramsey/composer-install@v3"
54+
with:
55+
composer-options: "--ignore-platform-req=ext-grpc"
7256

7357
- name: Setup Problem Matchers for PHPUnit
7458
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
@@ -97,7 +81,7 @@ jobs:
9781
FIREBASE_DATABASE_EMULATOR_HOST: localhost:9100
9882
FIREBASE_AUTH_EMULATOR_HOST: localhost:9099
9983
XDEBUG_MODE: coverage
100-
run: firebase emulators:exec --only auth,database --project beste-firebase 'XDEBUG_MODE=coverage vendor/bin/phpunit --group=emulator --coverage-clover=coverage.xml --log-junit=test-report.xml'
84+
run: firebase emulators:exec --only auth,database --project beste-firebase 'XDEBUG_MODE=coverage vendor/bin/phpunit --group=emulator --exclude-group grpc --coverage-clover=coverage.xml --log-junit=test-report.xml'
10185

10286
- name: Upload test results to Codecov
10387
if: ${{ !cancelled() }}

.github/workflows/grpc-tests.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: gRPC Tests
2+
3+
on:
4+
# TEMPORARY: Use pull_request to run gRPC tests in this PR. Revert to pull_request_target before merging.
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
paths:
8+
- 'src/**'
9+
- 'tests/**'
10+
- '.github/workflows/grpc-tests.yml'
11+
- 'composer.json'
12+
- 'phpstan.neon.dist'
13+
push:
14+
branches: ['8.x']
15+
paths:
16+
- 'src/**'
17+
- 'tests/**'
18+
- '.github/workflows/grpc-tests.yml'
19+
- 'composer.json'
20+
- 'phpstan.neon.dist'
21+
workflow_dispatch:
22+
23+
permissions:
24+
contents: read
25+
26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
28+
cancel-in-progress: true
29+
30+
jobs:
31+
grpc-tests:
32+
name: gRPC Tests (PHP 8.5)
33+
runs-on: ubuntu-latest
34+
# Non-blocking while the gRPC extension is broken/unstable on PHP 8.5.
35+
# See https://github.com/shivammathur/setup-php/issues/1041.
36+
# Remove this once upstream releases a stable extension and tests pass.
37+
continue-on-error: true
38+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
39+
40+
env:
41+
key: cache-grpc
42+
php-version: 8.5
43+
extensions: grpc
44+
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v6
48+
with:
49+
ref: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.sha) || github.sha }}
50+
51+
- name: Setup cache environment
52+
id: extcache
53+
uses: shivammathur/cache-extensions@v1
54+
with:
55+
php-version: ${{ env.php-version }}
56+
extensions: ${{ env.extensions }}
57+
key: ${{ env.key }}
58+
59+
- name: Cache extensions
60+
uses: actions/cache@v5.0.2
61+
with:
62+
path: ${{ steps.extcache.outputs.dir }}
63+
key: ${{ steps.extcache.outputs.key }}
64+
restore-keys: ${{ steps.extcache.outputs.key }}
65+
66+
- name: Setup PHP
67+
uses: shivammathur/setup-php@v2
68+
with:
69+
php-version: ${{ env.php-version }}
70+
extensions: ${{ env.extensions }}
71+
ini-values: grpc.grpc_verbosity=error, grpc.grpc_trace=
72+
tools: composer, pecl
73+
coverage: xdebug
74+
75+
- name: Setup problem matchers for PHP
76+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
77+
78+
- name: Verify gRPC extension
79+
id: grpc
80+
run: php -m | grep -i '^grpc$'
81+
82+
- uses: "ramsey/composer-install@v3"
83+
id: composer
84+
if: ${{ steps.grpc.outcome == 'success' }}
85+
86+
- name: Setup Problem Matchers for PHPUnit
87+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
88+
89+
- name: Run gRPC Tests
90+
id: grpc-tests
91+
if: ${{ steps.grpc.outcome == 'success' }}
92+
env:
93+
GOOGLE_APPLICATION_CREDENTIALS: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
94+
TEST_FIREBASE_APP_ID: ${{secrets.TEST_FIREBASE_APP_ID}}
95+
TEST_FIREBASE_RTDB_URI: ${{secrets.TEST_FIREBASE_RTDB_URI}}
96+
TEST_FIREBASE_TENANT_ID: ${{secrets.TEST_FIREBASE_TENANT_ID}}
97+
TEST_REGISTRATION_TOKENS: ${{secrets.TEST_REGISTRATION_TOKENS}}
98+
XDEBUG_MODE: coverage
99+
run: vendor/bin/phpunit --testsuite=integration --group grpc --coverage-clover=coverage.xml --log-junit=test-report.xml --testdox
100+
101+
- name: Summarize gRPC failures
102+
if: ${{ always() && (steps.grpc.outcome == 'failure' || steps.grpc-tests.outcome == 'failure') }}
103+
run: |
104+
echo "::notice::gRPC tests are non-blocking due to missing/broken gRPC on PHP 8.5."
105+
{
106+
echo "### gRPC tests are non-blocking"
107+
echo
108+
echo "gRPC extension was not available or gRPC tests failed (likely due to missing/broken gRPC on PHP 8.5)."
109+
echo "See https://github.com/shivammathur/setup-php/issues/1041."
110+
} >> "$GITHUB_STEP_SUMMARY"
111+
112+
- name: Upload test results to Codecov
113+
if: ${{ !cancelled() && steps.grpc.outcome == 'success' }}
114+
uses: codecov/codecov-action@v5
115+
with:
116+
token: ${{ secrets.CODECOV_TOKEN }}
117+
flags: grpc
118+
report_type: test_results
119+
fail_ci_if_error: false
120+
121+
- name: Upload coverage to Codecov
122+
if: ${{ !cancelled() && steps.grpc.outcome == 'success' }}
123+
uses: codecov/codecov-action@v5
124+
with:
125+
token: ${{ secrets.CODECOV_TOKEN }}
126+
files: ./coverage.xml
127+
flags: grpc
128+
fail_ci_if_error: false

.github/workflows/integration-tests.yml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,43 +32,27 @@ jobs:
3232
runs-on: ubuntu-latest
3333

3434
env:
35-
php-version: '8.4'
36-
extensions: grpc
37-
key: cache-v1
35+
php-version: '8.5'
3836

3937
steps:
4038
- name: Checkout code
4139
uses: actions/checkout@v6
4240
with:
4341
ref: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.sha) || github.sha }}
4442

45-
- name: Setup cache environment
46-
id: extcache
47-
uses: shivammathur/cache-extensions@v1
48-
with:
49-
php-version: ${{ env.php-version }}
50-
extensions: ${{ env.extensions }}
51-
key: ${{ env.key }}
52-
53-
- name: Cache extensions
54-
uses: actions/cache@v5.0.3
55-
with:
56-
path: ${{ steps.extcache.outputs.dir }}
57-
key: ${{ steps.extcache.outputs.key }}
58-
restore-keys: ${{ steps.extcache.outputs.key }}
59-
6043
- name: Setup PHP
6144
uses: shivammathur/setup-php@v2
6245
with:
6346
php-version: ${{ env.php-version }}
64-
extensions: ${{ env.extensions }}
6547
tools: composer, pecl
6648
coverage: xdebug
6749

6850
- name: Setup problem matchers for PHP
6951
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
7052

7153
- uses: "ramsey/composer-install@v3"
54+
with:
55+
composer-options: "--ignore-platform-req=ext-grpc"
7256

7357
- name: Setup Problem Matchers for PHPUnit
7458
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
@@ -81,7 +65,7 @@ jobs:
8165
TEST_FIREBASE_TENANT_ID: ${{secrets.TEST_FIREBASE_TENANT_ID}}
8266
TEST_REGISTRATION_TOKENS: ${{secrets.TEST_REGISTRATION_TOKENS}}
8367
XDEBUG_MODE: coverage
84-
run: vendor/bin/phpunit --testsuite=integration --coverage-clover=coverage.xml --log-junit=test-report.xml --testdox
68+
run: vendor/bin/phpunit --testsuite=integration --exclude-group grpc --coverage-clover=coverage.xml --log-junit=test-report.xml --testdox
8569

8670
- name: Upload test results to Codecov
8771
if: ${{ !cancelled() }}

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,40 +38,20 @@ jobs:
3838
- "8.4"
3939
- "8.5"
4040

41-
env:
42-
extensions: grpc
43-
key: cache-v1
44-
4541
steps:
4642
- name: Checkout code
4743
uses: actions/checkout@v6
4844

49-
- name: Setup cache environment
50-
id: extcache
51-
uses: shivammathur/cache-extensions@v1
52-
with:
53-
php-version: ${{ matrix.php }}
54-
extensions: ${{ env.extensions }}
55-
key: ${{ env.key }}
56-
57-
- name: Cache extensions
58-
uses: actions/cache@v5.0.3
59-
with:
60-
path: ${{ steps.extcache.outputs.dir }}
61-
key: ${{ steps.extcache.outputs.key }}
62-
restore-keys: ${{ steps.extcache.outputs.key }}
63-
6445
- name: Setup PHP
6546
uses: shivammathur/setup-php@v2
6647
with:
6748
php-version: ${{ matrix.php }}
68-
extensions: ${{ env.extensions }}
6949
tools: composer, pecl
7050
coverage: none
7151

7252
- uses: "ramsey/composer-install@v3"
7353
with:
74-
composer-options: "${{ matrix.composer-options }}"
54+
composer-options: "--ignore-platform-req=ext-grpc"
7555

7656
- name: Setup problem matchers for PHP
7757
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

.github/workflows/tests.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,40 +41,20 @@ jobs:
4141
- "lowest"
4242
- "highest"
4343

44-
env:
45-
extensions: grpc
46-
key: cache-v1
47-
4844
steps:
4945
- name: Checkout code
5046
uses: actions/checkout@v6
5147

52-
- name: Setup cache environment
53-
id: extcache
54-
uses: shivammathur/cache-extensions@v1
55-
with:
56-
php-version: ${{ matrix.php }}
57-
extensions: ${{ env.extensions }}
58-
key: ${{ env.key }}
59-
60-
- name: Cache extensions
61-
uses: actions/cache@v5.0.3
62-
with:
63-
path: ${{ steps.extcache.outputs.dir }}
64-
key: ${{ steps.extcache.outputs.key }}
65-
restore-keys: ${{ steps.extcache.outputs.key }}
66-
6748
- name: Setup PHP
6849
uses: shivammathur/setup-php@v2
6950
with:
7051
php-version: ${{ matrix.php }}
71-
extensions: ${{ env.extensions }}
7252
tools: composer, pecl
7353
coverage: xdebug
7454

7555
- uses: "ramsey/composer-install@v3"
7656
with:
77-
composer-options: "${{ matrix.composer-options }}"
57+
composer-options: "--ignore-platform-req=ext-grpc"
7858
dependency-versions: "${{ matrix.dependencies }}"
7959

8060
- name: Setup problem matchers for PHP

tests/Integration/Factory/FirestoreTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
use Exception;
88
use Kreait\Firebase\Tests\IntegrationTestCase;
99
use Kreait\Firebase\Util;
10+
use PHPUnit\Framework\Attributes\Group;
11+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1012

1113
/**
1214
* @internal
1315
*/
16+
#[Group('grpc')]
17+
#[RequiresPhpExtension('grpc')]
1418
final class FirestoreTest extends IntegrationTestCase
1519
{
1620
/**
@@ -19,11 +23,6 @@ final class FirestoreTest extends IntegrationTestCase
1923
*/
2024
public function testItUsesTheDefaultDatabaseByDefault(): void
2125
{
22-
// @see https://github.com/grpc/grpc/issues/38184
23-
// @see https://github.com/googleapis/gax-php/issues/584
24-
// @see https://www.php.net/manual/en/info.configuration.php#ini.zend.reserved-stack-size
25-
$this->markTestSkipped('Skipped because of an infinite recursion with certain PHP/gRPC versions.');
26-
// @phpstan-ignore deadCode.unreachable
2726
$collection = __FUNCTION__;
2827
$documentName = __FUNCTION__.self::randomString();
2928

@@ -42,11 +41,6 @@ public function testItUsesTheDefaultDatabaseByDefault(): void
4241

4342
public function testItCannotConnectToAnUnknownDatabase(): void
4443
{
45-
// @see https://github.com/grpc/grpc/issues/38184
46-
// @see https://github.com/googleapis/gax-php/issues/584
47-
// @see https://www.php.net/manual/en/info.configuration.php#ini.zend.reserved-stack-size
48-
$this->markTestSkipped('Skipped because of an infinite recursion with certain PHP/gRPC versions.');
49-
// @phpstan-ignore deadCode.unreachable
5044
$name = self::randomString();
5145

5246
$database = self::$factory->createFirestore($name)->database();

0 commit comments

Comments
 (0)