|
| 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 |
0 commit comments