-
-
Notifications
You must be signed in to change notification settings - Fork 326
261 lines (224 loc) · 9.59 KB
/
run-tests.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: run-tests
on:
push:
branches:
- master
- fork6
pull_request: ~
workflow_dispatch: ~
jobs:
phpunit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.2, 8.3]
testsuite: ["functional", "unit", "installer"]
name: PHPUnit - ${{ matrix.testsuite }} (PHP ${{ matrix.php }})
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: forkcms
MYSQL_ROOT_PASSWORD: "kingtriton"
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP with coverage
if: ${{ matrix.php == '8.2' }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, bcmath, intl, gd, exif, iconv, imagick
coverage: PCOV
- name: Setup PHP without coverage
if: ${{ matrix.php != '8.2' }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, bcmath, intl, gd, exif, iconv, imagick
coverage: none
- name: Prepare test env
run: |
mysql -h 127.0.0.1 -uroot -pkingtriton -e 'create database forkcms_test'
- name: Install dependencies
env:
APP_ENV: test
run: composer install -o
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: 18 # current LTS
- run: npm install
- run: node_modules/.bin/webpack
- name: Install Fork CMS
run: cp src/Modules/Installer/tests/fork-cms-installation-configuration.yaml fork-cms-installation-configuration.yaml && bin/console forkcms:installer:install && sed -i 's/forkcms_test/forkcms/g' .env.local
env:
FORK_DATABASE_USER: root
FORK_DATABASE_PASSWORD: kingtriton
- name: Execute tests with coverage
if: ${{ matrix.php == '8.2' }}
run: bin/simple-phpunit --testsuite=${{ matrix.testsuite}} --coverage-clover=${{ matrix.testsuite}}.clover
env:
FORK_INSTALLATION_LOCALE_ENV_PATH: .env.local
APP_ENV: test
APP_SECRET: notsosecret
FORK_DATABASE_HOST: 127.0.0.1
FORK_DATABASE_PORT: 3306
FORK_DATABASE_NAME: forkcms_test
FORK_DATABASE_USER: root
FORK_DATABASE_PASSWORD: kingtriton
- name: Execute tests without coverage
if: ${{ matrix.php != '8.2' }}
run: bin/simple-phpunit --testsuite=${{ matrix.testsuite}}
env:
FORK_INSTALLATION_LOCALE_ENV_PATH: .env.local
APP_ENV: test
APP_SECRET: notsosecret
FORK_DATABASE_HOST: 127.0.0.1
FORK_DATABASE_PORT: 3306
FORK_DATABASE_NAME: forkcms_test
FORK_DATABASE_USER: root
FORK_DATABASE_PASSWORD: kingtriton
- name: Display error logs on failure
if: ${{ failure() }}
run: |
bin/console debug:dotenv
ls -alh
[ -r var/log/install/debug.log ] && cat var/log/install/debug.log
[ -r var/log/test/debug.log ] && cat var/log/test/debug.log
[ -r var/log/test_install/debug.log ] && cat var/log/test_install/debug.log
[ -r var/log/prod/debug.log ] && cat var/log/prod/debug.log
[ -r var/log/dev/debug.log ] && cat var/log/dev/debug.log
env:
FORK_INSTALLATION_LOCALE_ENV_PATH: .env.local
APP_ENV: test
- name: Upload Coverage report
uses: codecov/codecov-action@v1
if: ${{ matrix.php == '8.2' }}
with:
file: ${{ matrix.testsuite}}.clover
flags: ${{ matrix.testsuite}}
phpstan:
name: PHPStan - Static Code Analysis
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: forkcms
MYSQL_ROOT_PASSWORD: "kingtriton"
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, bcmath, intl, gd, exif, iconv, imagick
coverage: none
- name: Prepare test env
run: |
mysql -h 127.0.0.1 -uroot -pkingtriton -e 'create database forkcms_test'
- name: Install dependencies
run: composer install -o
env:
APP_ENV: dev
- name: Install Fork CMS
run: cp src/Modules/Installer/tests/fork-cms-installation-configuration.yaml fork-cms-installation-configuration.yaml && bin/console forkcms:installer:install && bin/console cache:clear
env:
APP_ENV: dev
APP_DEBUG: 1
- name: Run PHPStan
run: bin/phpstan analyze --error-format table src
php-code-sniffer:
name: PHP Code Sniffer
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, bcmath, intl, gd, exif, iconv, imagick
coverage: none
- name: Install dependencies
run: composer install -o
- name: Run PHP Codesniffer
run: bin/phpcs --standard=PSR12 --extensions=php --warning-severity=9 --exclude=Generic.Files.LineLength --report=full --ignore=*/tests/*,*/*.tpl.php "src"
frontend:
name: npm test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: 18 # current LTS
- run: npm install
- run: npm test
docker-test:
continue-on-error: true
name: Docker
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, bcmath, intl, gd, exif, iconv, imagick
coverage: none
# We need to have a vendor folder locally, as the whole root folder gets mounted as volume via docker-compose.
# Alternatively, you can define a named volume for the vendor folder path in docker-compose.
- name: Install dependencies
run: composer install -o
- name: Build Docker image
run: |
docker pull ghcr.io/forkcms/forkcms:latest || true
docker-compose build
- name: Start docker-compose stack
run: |
docker-compose up -d
docker run --rm --network=forkcms_default jwilder/dockerize -wait tcp://db6:3306 -timeout 300s
docker-compose ps "db6" | grep -q "Up"
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: 18 # current LTS
- run: npm install
- run: node_modules/.bin/webpack
- name: Test
run: |
curl -s -L -o /dev/null -w "%{http_code}" http://localhost:80 | grep -q '200'
curl -s -L http://localhost:80 | grep -q 'Install Fork CMS'
- name: Display error logs on failure
if: ${{ failure() }}
run: docker ps && docker-compose logs
- name: Cleanup
if: always()
run: docker-compose down -v