-
Notifications
You must be signed in to change notification settings - Fork 13
147 lines (125 loc) · 3.62 KB
/
php.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Tests
on:
pull_request:
push:
branches:
- master
env:
php_version: '8.1'
jobs:
build:
name: Test Application
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
- uses: actions/checkout@v3
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache the vulnerability database to speed up security checks
uses: actions/cache@v3
id: cache-db
with:
path: ~/.symfony/cache
key: db
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install php dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress
- name: Archive application
working-directory: ../
run: |
tar -czf application.tar.gz --exclude=".git" -C ${{ github.workspace }} .
mv application.tar.gz ${{ github.workspace }}/
- name: Upload prepared application
uses: actions/upload-artifact@v3
with:
name: applicationArchive
path: application.tar.gz
if-no-files-found: error
retention-days: 1
php-cs-fixer:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download prepared application
uses: actions/download-artifact@v3
with:
name: applicationArchive
- name: Unpack application
run: tar -xzf application.tar.gz --strip=1
- name: Run cs fixer
run: composer php-cs-fixer
phpstan:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
needs: build
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
- name: Download prepared application
uses: actions/download-artifact@v3
with:
name: applicationArchive
- name: Unpack application
run: tar -xzf application.tar.gz --strip=1
- name: Run phpstan
run: composer phpstan
phpunit:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
needs: build
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
- name: Download prepared application
uses: actions/download-artifact@v3
with:
name: applicationArchive
- name: Unpack application
run: tar -xzf application.tar.gz --strip=1
- name: bootstrap test environment
run: composer bootstrap-test-environment
- name: Run test suite
run: composer phpunit
cleanup:
runs-on: ubuntu-latest
needs:
- build
- php-cs-fixer
- phpstan
- phpunit
if: ${{ always() }}
steps:
- name: Delete unecessary artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: applicationArchive
failOnError: false