-
Notifications
You must be signed in to change notification settings - Fork 3
57 lines (49 loc) · 1.85 KB
/
phpunit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: PHPUnit Tests
on:
pull_request:
paths:
- 'src/**.php'
workflow_dispatch:
jobs:
phpunit_tests:
name: PHPUnit on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
steps:
- name: Checkout code
uses: actions/checkout@v4
# Attempt to restore cached Docker image tarball for the specific PHP version
- name: Restore Docker image cache
uses: actions/cache@v3
id: cache-docker
with:
path: qit-cli-tests-${{ matrix.php }}.tar
key: ${{ runner.os }}-qit-cli-tests-${{ matrix.php }}-${{ hashFiles('_build/docker/php/**') }}
# If not cached, build the Docker image for this specific PHP version
- name: Build Docker image if needed
if: steps.cache-docker.outputs.cache-hit != 'true'
run: |
docker build --build-arg CI=true --build-arg PHP_VERSION=${{ matrix.php }} -t qit-cli-tests:${{ matrix.php }} ./_build/docker/php
docker save qit-cli-tests:${{ matrix.php }} -o qit-cli-tests-${{ matrix.php }}.tar
# If image is cached, load it
- name: Load Docker image from cache
if: steps.cache-docker.outputs.cache-hit == 'true'
run: |
docker load -i qit-cli-tests-${{ matrix.php }}.tar
- name: Cache composer dependencies
uses: actions/cache@v3
id: cache-composer
with:
path: src/vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('src/composer.lock') }}
- name: Composer install
if: steps.cache-composer.outputs.cache-hit != 'true'
run: |
cd src
composer install --no-interaction --no-suggest --prefer-dist
- name: Run PHPUnit tests
env:
PHP_VERSION: ${{ matrix.php }}
run: make phpunit