Skip to content
Open
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
46 changes: 46 additions & 0 deletions .github/actions/setup-php-grpc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Setup PHP with cached grpc extension
description: Installs PHP and grpc extension, building and caching grpc.so on first run.

inputs:
php-version:
required: true
description: PHP version, e.g. 7.2 / 8.2
grpc-version:
required: true
description: gRPC version for eWaterCycle/setup-grpc (must match what pecl will build)
cache-version:
required: true
description: Bump to invalidate cache manually

runs:
using: composite
steps:
- name: Setup PHP (without grpc, to resolve ext dir)
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}

- name: Resolve extension dir
shell: bash
run: echo "EXT_DIR=$(php-config --extension-dir)" >> "$GITHUB_ENV"

- name: Restore grpc.so cache
id: grpc-cache
uses: actions/cache@v3
with:
path: ${{ env.EXT_DIR }}/grpc.so
key: php-grpc-${{ inputs.php-version }}-${{ runner.os }}-grpc${{ inputs.grpc-version }}-${{ inputs.cache-version }}

- name: Install grpc extension (apt/pecl via setup-php)
if: steps.grpc-cache.outputs.cache-hit != 'true'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
extensions: grpc

- name: Enable grpc extension
shell: bash
run: |
INI_DIR=$(php -r 'echo PHP_CONFIG_FILE_SCAN_DIR;')
echo "extension=grpc.so" | sudo tee "$INI_DIR/20-grpc.ini"
php -m | grep -i grpc
16 changes: 7 additions & 9 deletions .github/workflows/sumplelinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ concurrency:
permissions:
contents: read

env:
GRPC_VERSION: '1.51.1'
CACHE_VERSION: 'v2'

jobs:
linter:
runs-on: ubuntu-latest
Expand All @@ -23,17 +27,11 @@ jobs:
- uses: actions/checkout@v3
name: Checkout

- uses: eWaterCycle/setup-grpc@v5
name: Setup gRPC
with:
grpc-version: 1.51.1

- uses: shivammathur/setup-php@v2
name: Setup PHP
id: php
- uses: ./.github/actions/setup-php-grpc
with:
extensions: grpc
php-version: ${{ matrix.php-versions }}
grpc-version: ${{ env.GRPC_VERSION }}
cache-version: ${{ env.CACHE_VERSION }}

- run: composer validate --strict
name: Validate composer.json and composer.lock
Expand Down
46 changes: 37 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,42 @@ concurrency:
permissions:
contents: read

env:
GRPC_VERSION: '1.51.1'
CACHE_VERSION: 'v2'

jobs:
prepare-grpc:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: [ '7.2', '7.4', '8.0', '8.2' ]
steps:
- name: Check cache exists
id: cache-lookup
uses: actions/cache/restore@v3
with:
path: grpc.so
key: php-grpc-${{ matrix.php-versions }}-${{ runner.os }}-grpc${{ env.GRPC_VERSION }}-${{ env.CACHE_VERSION }}
lookup-only: true

- name: Skip notice
if: steps.cache-lookup.outputs.cache-hit == 'true'
run: echo "SKIP, PHP CACHE EXISTS for PHP ${{ matrix.php-versions }}"

- uses: actions/checkout@v3
if: steps.cache-lookup.outputs.cache-hit != 'true'

- uses: ./.github/actions/setup-php-grpc
if: steps.cache-lookup.outputs.cache-hit != 'true'
with:
php-version: ${{ matrix.php-versions }}
grpc-version: ${{ env.GRPC_VERSION }}
cache-version: ${{ env.CACHE_VERSION }}

tests:
needs: prepare-grpc
services:
ydb:
image: cr.yandex/yc/yandex-docker-local-ydb:${{ matrix.ydb-versions }}
Expand All @@ -36,17 +70,11 @@ jobs:
- uses: actions/checkout@v3
name: Checkout

- uses: eWaterCycle/setup-grpc@v5
name: Setup gRPC
with:
grpc-version: 1.51.1

- uses: shivammathur/setup-php@v2
name: Setup PHP
id: php
- uses: ./.github/actions/setup-php-grpc
with:
extensions: grpc
php-version: ${{ matrix.php-versions }}
grpc-version: ${{ env.GRPC_VERSION }}
cache-version: ${{ env.CACHE_VERSION }}

- run: composer validate --strict
name: Validate composer.json and composer.lock
Expand Down
Loading