-
Notifications
You must be signed in to change notification settings - Fork 3
315 lines (271 loc) · 9.66 KB
/
Copy pathtests.yml
File metadata and controls
315 lines (271 loc) · 9.66 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
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
phpunit-tests:
name: PHPUnit Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ojs_ci
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout OJS
uses: actions/checkout@v4
with:
repository: pkp/ojs
ref: stable-3_5_0
path: ojs
submodules: recursive
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, xml, pdo_mysql, intl, zip, bcmath, curl, gd
coverage: xdebug
- name: Install PKP dependencies
working-directory: ojs/lib/pkp
run: composer install --no-interaction --no-progress --optimize-autoloader
- name: Checkout plugin
uses: actions/checkout@v4
with:
path: ojs/plugins/generic/codecheck
- name: Install plugin dependencies
working-directory: ojs/plugins/generic/codecheck
run: composer install --no-interaction || true
- name: Create .env file
working-directory: ojs/plugins/generic/codecheck
run: |
cat > .env << EOF
GITHUB_TOKEN=${{ secrets.CODECHECK_GITHUB_TOKEN }}
GITHUB_OWNER=${{ secrets.CODECHECK_GITHUB_OWNER }}
GITHUB_REPO=${{ secrets.CODECHECK_GITHUB_REPO }}
EOF
- name: Setup OJS database
working-directory: ojs
run: |
mysql -h 127.0.0.1 -u root -proot -e "CREATE DATABASE IF NOT EXISTS ojs_ci;"
cp config.TEMPLATE.inc.php config.inc.php
sed -i 's/username = .*/username = root/' config.inc.php
sed -i 's/password = .*/password = root/' config.inc.php
sed -i 's/name = .*/name = ojs_ci/' config.inc.php
sed -i 's/host = .*/host = 127.0.0.1/' config.inc.php
- name: Create MySQL socket symlink
run: |
sudo mkdir -p /tmp
sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock || true
- name: Run PHPUnit tests
working-directory: ojs/plugins/generic/codecheck/tests
run: sh runTests.sh
- name: Run PHPUnit tests with coverage
working-directory: ojs/plugins/generic/codecheck/tests
run: sh runTests.sh --coverage-report=true
- name: Upload coverage report
if: success()
uses: actions/upload-artifact@v4
with:
name: phpunit-coverage
path: ojs/plugins/generic/codecheck/tests/results/
if-no-files-found: ignore
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: phpunit-logs
path: |
ojs/plugins/generic/codecheck/tests/*.log
ojs/plugins/generic/codecheck/tests/*.xml
if-no-files-found: ignore
component-tests:
name: Cypress Component Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run component tests
run: npm run test:component
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
path: cypress/screenshots
if-no-files-found: ignore
e2e-tests:
name: Cypress E2E Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ojs_dump
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout OJS
uses: actions/checkout@v4
with:
repository: pkp/ojs
ref: stable-3_5_0
path: ojs
submodules: recursive
- name: Checkout plugin
uses: actions/checkout@v4
with:
path: ojs/plugins/generic/codecheck
- name: Checkout PKP datasets
uses: actions/checkout@v4
with:
repository: pkp/datasets
path: datasets
- name: Copy test data into datasets directory
run: |
mkdir -p datasets/ojs
cp -r ojs/plugins/generic/codecheck/testData/stable-3_5_0-codecheck datasets/ojs/
- name: Prepare OJS files and public directories
run: |
mkdir -p ojs/files
mkdir -p ojs/public
- name: Import test database
working-directory: ojs
env:
DBTYPE: MySQL
DBTYPE_SYMBOLIC: mysql
DBUSERNAME: root
DBPASSWORD: root
DBNAME: ojs_dump
DBHOST: 127.0.0.1
APP: ojs
BRANCH: stable-3_5_0-codecheck
run: |
mysql -h 127.0.0.1 -u root -proot ojs_dump < ../datasets/ojs/stable-3_5_0-codecheck/mysql/database.sql
- name: Load test files
working-directory: ojs
env:
DBTYPE: MySQL
DBTYPE_SYMBOLIC: mysql
DBUSERNAME: root
DBPASSWORD: root
DBNAME: ojs_dump
DBHOST: 127.0.0.1
APP: ojs
BRANCH: stable-3_5_0-codecheck
run: bash ../datasets/tools/loadfiles.sh
- name: Patch config.inc.php for CI environment
working-directory: ojs
run: |
sed -i 's/host = localhost/host = 127.0.0.1/' config.inc.php
sed -i 's/name = ojs$/name = ojs_dump/' config.inc.php
sed -i 's|files_dir = .*|files_dir = /home/runner/work/ojs-codecheck/ojs-codecheck/ojs/files|' config.inc.php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, xml, pdo_mysql, intl, zip, bcmath, curl, gd
- name: Install PKP dependencies
working-directory: ojs/lib/pkp
run: composer install --no-interaction --no-progress --optimize-autoloader
- name: Build OJS frontend assets
working-directory: ojs
run: |
npm install
npm run build
- name: Install plugin composer dependencies
working-directory: ojs/plugins/generic/codecheck
run: composer install --no-interaction || true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: ojs/plugins/generic/codecheck/package-lock.json
- name: Install plugin npm dependencies
working-directory: ojs/plugins/generic/codecheck
run: npm ci
- name: Build plugin frontend assets
working-directory: ojs/plugins/generic/codecheck
run: npm run build
- name: Configure Apache for OJS
run: |
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install -y apache2 libapache2-mod-php8.2
sudo a2enmod rewrite php8.2 alias
sudo bash -c 'cat > /etc/apache2/mods-available/mpm_prefork.conf << EOF
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 50
MaxConnectionsPerChild 0
</IfModule>
EOF'
sudo bash -c 'cat > /etc/apache2/sites-available/ojs.conf << EOF
<VirtualHost *:8888>
DocumentRoot /home/runner/work/ojs-codecheck/ojs-codecheck
Alias /ojs /home/runner/work/ojs-codecheck/ojs-codecheck/ojs
<Directory /home/runner/work/ojs-codecheck/ojs-codecheck>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /home/runner/work/ojs-codecheck/ojs-codecheck/ojs>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
EOF'
sudo a2ensite ojs
sudo a2dissite 000-default
sudo sed -i 's/Listen 80/Listen 8888/' /etc/apache2/ports.conf
sudo systemctl restart apache2
- name: Prepare OJS cache directories
run: |
sudo chmod o+x /home/runner
sudo chmod o+x /home/runner/work
sudo chmod o+x /home/runner/work/ojs-codecheck
sudo chmod o+x /home/runner/work/ojs-codecheck/ojs-codecheck
mkdir -p ojs/cache/opcache
sudo chown -R www-data:www-data ojs/cache
sudo chown -R www-data:www-data ojs/public
sudo chown -R www-data:www-data ojs/files
- name: Wait for OJS to be ready
run: sleep 10
- name: Run Cypress E2E tests
working-directory: ojs/plugins/generic/codecheck
run: npm run test:e2e
env:
CYPRESS_BASE_URL: http://localhost:8888/ojs
- name: Upload E2E screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-screenshots
path: ojs/plugins/generic/codecheck/cypress/screenshots
if-no-files-found: ignore
- name: Upload E2E videos
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-videos
path: ojs/plugins/generic/codecheck/cypress/videos
if-no-files-found: ignore