Skip to content

Commit

Permalink
ci: cache extensions (#223)
Browse files Browse the repository at this point in the history
Try caching the PHP extensions since they take a long time to
build. We try this both in the lint job and test job.

We also temporarily reduce the number of versions under test in
order to increase velocity.
  • Loading branch information
malandis authored Oct 17, 2024
1 parent 0cde7a4 commit 2c44adb
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions .github/workflows/on-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
jobs:
lint:
runs-on: ubuntu-24.04
env:
php-version: 8.0
extensions: grpc, protobuf

steps:
- uses: actions/checkout@v4
Expand All @@ -29,11 +32,30 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set cache key
id: cache-key
run: echo "key=php-${{ env.php-version }}" >> $GITHUB_OUTPUT

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ env.php-version }}
extensions: ${{ env.extensions }}
key: ${{ steps.cache-key.outputs.key }}

- name: Cache extensions
uses: actions/cache@v4
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: grpc, protobuf
php-version: ${{ env.php-version }}
extensions: ${{ env.extensions }}
tools: composer

- name: Install dependencies
Expand All @@ -47,20 +69,41 @@ jobs:
max-parallel: 1
fail-fast: true
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
php-version: ['7.4', '8.4']
#php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] # TODO: Uncomment to test all PHP versions
runs-on: ubuntu-24.04

env:
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
extensions: grpc, protobuf

steps:
- uses: actions/checkout@v4

- name: Set cache key
id: cache-key
run: echo "key=php-${{ matrix.php-version }}" >> $GITHUB_OUTPUT

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ env.extensions }}
key: ${{ steps.cache-key.outputs.key }}

- name: Cache extensions
uses: actions/cache@v4
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: grpc, protobuf
extensions: ${{ env.extensions }}
tools: composer

- name: Install dependencies
Expand Down

0 comments on commit 2c44adb

Please sign in to comment.