forked from forkcms/forkcms
-
Notifications
You must be signed in to change notification settings - Fork 3
207 lines (176 loc) · 7.48 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
name: run-tests
on:
push:
branches:
- master
pull_request: ~
workflow_dispatch: ~
jobs:
phpunit:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.4, 8.0]
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 == '7.4' }}
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 != '7.4' }}
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'
mysql -h 127.0.0.1 -uroot -pkingtriton forkcms_test < tests/data/test_db.sql
cp app/config/parameters.yml.test app/config/parameters.yml
- name: Install dependencies
env:
FORK_ENV: test
run: composer install -o
- name: Execute tests with coverage
if: ${{ matrix.php == '7.4' }}
run: bin/simple-phpunit --testsuite=${{ matrix.testsuite}} --coverage-clover=${{ matrix.testsuite}}.clover
- name: Execute tests without coverage
if: ${{ matrix.php != '7.4' }}
run: bin/simple-phpunit --testsuite=${{ matrix.testsuite}}
- name: Display error logs on failure
if: ${{ failure() }}
run: cat var/logs/test.log
- name: Upload Coverage report
uses: codecov/codecov-action@v1
if: ${{ matrix.php == '7.4' }}
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: 7.4
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'
mysql -h 127.0.0.1 -uroot -pkingtriton forkcms_test < tests/data/test_db.sql
cp app/config/parameters.yml.test app/config/parameters.yml
- name: Install dependencies
run: composer install -o
env:
FORK_ENV: dev
- name: Run PHPStan
run: bin/phpstan analyze --error-format github 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: 7.4
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=psr2 --extensions=php --warning-severity=0 --ignore=src/Backend/Core/Js/ckfinder,src/Backend/Cache,src/Frontend/Cache,src/Backend/Core/Js/ckeditor --report=full "src"
frontend:
name: Yarn test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Node
uses: actions/setup-node@v2-beta
with:
node-version: 12 # current LTS
- run: yarn install
- run: yarn test
docker-test:
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: 7.4
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://db:3306 -timeout 300s
docker-compose ps "app" | grep -q "Up"
- 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