-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (85 loc) · 3.76 KB
/
Copy pathtest.yml
File metadata and controls
97 lines (85 loc) · 3.76 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Test
on:
pull_request:
push:
branches:
- main
- '[0-9]+.x'
jobs:
php:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- PHP_VERSION: '7.1'
RUN_PHPSTAN: 'false'
RUN_PSALM: 'false'
- PHP_VERSION: '7.2'
RUN_PHPSTAN: 'true'
RUN_PSALM: 'false'
- PHP_VERSION: '7.3'
RUN_PHPSTAN: 'false'
RUN_PSALM: 'false'
- PHP_VERSION: '7.4'
RUN_PHPSTAN: 'false'
RUN_PSALM: 'false'
- PHP_VERSION: '8.0'
RUN_PHPSTAN: 'true'
RUN_PSALM: 'true'
- PHP_VERSION: '8.1'
RUN_PHPSTAN: 'false'
RUN_PSALM: 'false'
- PHP_VERSION: '8.2'
RUN_PHPSTAN: 'false'
RUN_PSALM: 'false'
- PHP_VERSION: '8.3'
RUN_PHPSTAN: 'false'
RUN_PSALM: 'false'
- PHP_VERSION: '8.4'
RUN_PHPSTAN: 'false'
RUN_PSALM: 'false'
- PHP_VERSION: '8.5'
RUN_PHPSTAN: 'true'
RUN_PSALM: 'false'
steps:
- uses: actions/checkout@v6
- name: Cache Docker Image
id: docker-cache-image
uses: actions/cache@v5
with:
path: /tmp/docker-cache-image.tar
key: docker-cache-image:${{ matrix.PHP_VERSION }}
- name: Load Docker Image
if: steps.docker-cache-image.outputs.cache-hit == 'true'
run: docker load --input /tmp/docker-cache-image.tar
- name: Build Docker Image
if: steps.docker-cache-image.outputs.cache-hit != 'true'
run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' .
- name: Cache Composer Cache Dir
uses: actions/cache@v5
with:
path: /tmp/composer-cache-dir
key: composer-cache-dir:${{ matrix.PHP_VERSION }}
restore-keys: |
composer-cache-dir:
- name: Install Composer Dependencies
run: |
if [ "${{ matrix.RUN_PHPSTAN }}" != "true" ]; then
docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-dir:/.composer-cache-dir' 'test:${{ matrix.PHP_VERSION }}' composer remove --dev phpstan/phpstan --no-update --no-interaction
fi
if [ "${{ matrix.RUN_PSALM }}" != "true" ]; then
docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-dir:/.composer-cache-dir' 'test:${{ matrix.PHP_VERSION }}' composer remove --dev vimeo/psalm --no-update --no-interaction
fi
docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-dir:/.composer-cache-dir' 'test:${{ matrix.PHP_VERSION }}' composer install --no-interaction --no-progress --prefer-dist ${{ matrix.COMPOSER_EXTRA_ARGS }}
- name: Run Unit Test
run: |
docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=1' ./vendor/bin/phpunit
- name: Run PHPStan
if: ${{ matrix.RUN_PHPSTAN == 'true' }}
run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --no-interaction
- name: Run psalm
if: ${{ matrix.RUN_PSALM == 'true' }}
run: mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v "$HOME/.cache/psalm:/.cache/psalm" 'test:${{ matrix.PHP_VERSION }}' php ./vendor/bin/psalm --no-cache
- name: Export Docker Image
if: steps.docker-cache-image.outputs.cache-hit != 'true'
run: docker save --output /tmp/docker-cache-image.tar 'test:${{ matrix.PHP_VERSION }}'