Skip to content

Commit

Permalink
Version PHP build caches by image version
Browse files Browse the repository at this point in the history
we can't safely use `ubuntu-latest` because the build caches will break if they were built for 18.04 and used on 20.04, or vice versa. Instead, we pin the images (and caches) to a specific version.
  • Loading branch information
dktapps authored Feb 3, 2021
1 parent 4771e3d commit 96181f8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ on:
jobs:
build-php:
name: Prepare PHP
runs-on: ubuntu-latest
runs-on: ${{ matrix.image }}

strategy:
matrix:
image: [ubuntu-20.04]
php: [7.3.25, 7.4.13]

steps:
Expand All @@ -21,7 +22,7 @@ jobs:
uses: actions/cache@v2
with:
path: "./bin"
key: "php-build-generic-${{ matrix.php }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
key: "php-build-generic-${{ matrix.php }}-${{ matrix.image }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"

- name: Compile PHP
if: steps.php-build-cache.outputs.cache-hit != 'true'
Expand All @@ -30,11 +31,12 @@ jobs:
phpstan:
name: PHPStan analysis
needs: build-php
runs-on: ubuntu-latest
runs-on: ${{ matrix.image }}

strategy:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [7.3.25, 7.4.13]

steps:
Expand All @@ -45,7 +47,7 @@ jobs:
uses: actions/cache@v2
with:
path: "./bin"
key: "php-build-generic-${{ matrix.php }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
key: "php-build-generic-${{ matrix.php }}-${{ matrix.image }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"

- name: Kill build on PHP build cache miss (should never happen)
if: steps.php-build-cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -76,10 +78,11 @@ jobs:
phpunit:
name: PHPUnit tests
needs: build-php
runs-on: ubuntu-latest
runs-on: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [7.3.25, 7.4.13]

steps:
Expand All @@ -90,7 +93,7 @@ jobs:
uses: actions/cache@v2
with:
path: "./bin"
key: "php-build-generic-${{ matrix.php }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
key: "php-build-generic-${{ matrix.php }}-${{ matrix.image }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"

- name: Kill build on PHP build cache miss (should never happen)
if: steps.php-build-cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -121,10 +124,11 @@ jobs:
integration:
name: Integration tests
needs: build-php
runs-on: ubuntu-latest
runs-on: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [7.3.25, 7.4.13]

steps:
Expand All @@ -137,7 +141,7 @@ jobs:
uses: actions/cache@v2
with:
path: "./bin"
key: "php-build-generic-${{ matrix.php }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
key: "php-build-generic-${{ matrix.php }}-${{ matrix.image }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"

- name: Kill build on PHP build cache miss (should never happen)
if: steps.php-build-cache.outputs.cache-hit != 'true'
Expand Down

0 comments on commit 96181f8

Please sign in to comment.