-
Notifications
You must be signed in to change notification settings - Fork 0
359 lines (311 loc) · 13.1 KB
/
Copy pathcodeception-base.yml
File metadata and controls
359 lines (311 loc) · 13.1 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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
name: module-tests-base
on:
workflow_call:
inputs:
module-id:
description: Module ID.
required: true
type: string
humhub-branch:
description: Test against HumHub Branch.
required: false
default: develop
type: string
module-branch:
# Empty (default) checks out the ref that triggered the workflow.
description: Module branch to test instead of the triggering ref.
required: false
default: ''
type: string
os:
description: Os to test, separated by comma.
default: >-
['ubuntu-latest']
type: string
php:
description: PHP versions to test, separated by comma.
default: >-
['8.2', '8.3', '8.4']
type: string
extensions:
description: List of extensions to PHP.
default: curl, intl, pdo, pdo_mysql, zip, exif, fileinfo, mbstring, gd, ldap
type: string
databases:
# JSON list of {engine, version}. engine: mariadb | mysql.
# Validated: mariadb 11.8 (LTS, recommended) & 12.3 (LTS); mysql 8.4 (LTS) & 9.7 (LTS).
# Default runs MariaDB 11.8 only. Modules can override per-module to test more/other combinations (rare case).
description: Databases to test, JSON list of {engine, version} objects.
default: >-
[{"engine": "mariadb", "version": "11.8"}]
type: string
use-rest-module:
description: Activate REST API module for api tests.
default: false
type: boolean
rest-module-branch:
description: REST API Module Branch.
type: string
default: master
run-solr:
description: Run Apache Solr.
default: false
type: boolean
run-clamav:
description: Run virus scanner ClamAV.
default: false
type: boolean
additional-module-id:
description: Additional Module ID.
type: string
additional-module-repo:
description: Additional Module Repository.
type: string
default: humhub
additional-module-branch:
description: Additional Module Branch.
type: string
default: master
jobs:
check-compatibility:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check.outputs.skip }}
humhub_version: ${{ steps.humhub.outputs.version }}
env:
HUMHUB_BRANCH: ${{ inputs.humhub-branch }}
steps:
- name: Checkout HumHub Core
uses: actions/checkout@v4
with:
repository: humhub/humhub
ref: ${{ env.HUMHUB_BRANCH }}
- name: Get HumHub version
id: humhub
run: |
version=$(grep -oP "'version'\s*=>\s*'[^']+'" protected/humhub/config/common.php | sed -E "s/.*'([^']+)'.*/\1/")
echo "Found HumHub version: $version"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Checkout Module
uses: actions/checkout@v4
with:
ref: ${{ inputs.module-branch }}
path: protected/modules/${{ inputs.module-id }}
- name: Read module.json
id: module
run: |
min=$(jq -r '.humhub.minVersion' protected/modules/${{ inputs.module-id }}/module.json)
max=$(jq -r '.humhub.maxVersion // empty' protected/modules/${{ inputs.module-id }}/module.json)
echo "min=$min" >> $GITHUB_OUTPUT
echo "max=$max" >> $GITHUB_OUTPUT
- name: Check version compatibility
id: check
run: |
HUMHUB="${{ steps.humhub.outputs.version }}"
BRANCH="${{ env.HUMHUB_BRANCH }}"
MIN="${{ steps.module.outputs.min }}"
MAX="${{ steps.module.outputs.max }}"
echo "---------------------------------------------------"
echo " Checking HumHub compatibility (raw values)"
echo " - HumHub branch : $BRANCH"
echo " - HumHub version : $HUMHUB"
echo " - Module min : $MIN"
echo " - Module max : ${MAX:-∞}"
echo "---------------------------------------------------"
# Strip leading "v"
HUMHUB="${HUMHUB#v}"
# Remove "-master" / "-develop" suffixes (nur für Dev-Builds)
if [[ "$HUMHUB" =~ -master$ ]] || [[ "$HUMHUB" =~ -develop$ ]]; then
HUMHUB=$(echo "$HUMHUB" | sed -E 's/-(master|develop)$//')
fi
# Add Patch-Level if only major.minor
if [[ "$MIN" =~ ^[0-9]+\.[0-9]+$ ]]; then
MIN="${MIN}.0"
fi
# Normalize MAX (x.y.999)
if [[ "$MAX" =~ ^[0-9]+\.[0-9]+$ ]]; then
MAX="${MAX}.999"
fi
echo " Normalized values:"
echo " - HumHub version : $HUMHUB"
echo " - Module min : $MIN"
echo " - Module max : ${MAX:-∞}"
echo "---------------------------------------------------"
skip=false
reason=""
# Check minVersion
if dpkg --compare-versions "$HUMHUB" lt "$MIN"; then
skip=true
reason="HumHub $HUMHUB is lower than required minVersion $MIN"
else
echo "Comparison result: $HUMHUB >= $MIN"
fi
# Check maxVersion if set
if [ -n "$MAX" ]; then
if dpkg --compare-versions "$HUMHUB" gt "$MAX"; then
skip=true
reason="HumHub $HUMHUB is higher than allowed maxVersion $MAX"
else
echo "Comparison result: $HUMHUB <= $MAX"
fi
fi
echo "skip=$skip" >> $GITHUB_OUTPUT
echo "humhub=$HUMHUB" >> $GITHUB_OUTPUT
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
echo "min=$MIN" >> $GITHUB_OUTPUT
echo "max=$MAX" >> $GITHUB_OUTPUT
echo "reason=$reason" >> $GITHUB_OUTPUT
if [ "$skip" = true ]; then
echo "⚠️ Module NOT compatible!"
echo " Reason: $reason"
else
echo "✅ Module IS compatible with HumHub $HUMHUB ($BRANCH)"
fi
tests:
name: PHP ${{ matrix.php }}-${{ matrix.db.engine }}-${{ matrix.db.version }}-humhub-${{ inputs.humhub-branch }}${{ inputs.module-branch != '' && format('-module-{0}', inputs.module-branch) || '' }}
needs: check-compatibility
if: needs.check-compatibility.outputs.skip == 'false'
env:
module-id: ${{ inputs.module-id }}
extensions: ${{ inputs.extensions }}
key: cache-v1
HUMHUB_BRANCH: ${{ inputs.humhub-branch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJson(inputs.os) }}
php: ${{ fromJson(inputs.php) }}
db: ${{ fromJson(inputs.databases) }}
services:
db:
image: ${{ matrix.db.engine == 'mariadb' && format('mariadb:{0}', matrix.db.version) || format('mysql:{0}', matrix.db.version) }}
env:
MYSQL_DATABASE: humhub_test
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd="${{ matrix.db.engine == 'mariadb' && 'healthcheck.sh --connect --innodb_initialized' || 'mysqladmin ping' }}"
--health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Start Selenium
run: |
docker run --detach --net=host --shm-size="2g" selenium/standalone-chrome:108.0-20250123
- uses: actions/setup-node@v4
- name: Checkout HumHub Core
uses: actions/checkout@v4
with:
repository: humhub/humhub
ref: ${{ env.HUMHUB_BRANCH }}
- name: Checkout Module
uses: actions/checkout@v4
with:
ref: ${{ inputs.module-branch }}
path: protected/modules/${{ env.module-id }}
- name: Checkout Additional Module
if: ${{ inputs.additional-module-id }}
uses: actions/checkout@v4
with:
repository: ${{ inputs.additional-module-repo }}/${{ inputs.additional-module-id }}
ref: ${{ inputs.additional-module-branch }}
path: protected/modules/${{ inputs.additional-module-id }}
- name: Run Apache Solr
if: ${{ inputs.run-solr }}
run: |
docker run --name humhub_solr \
-d -p 127.0.0.1:8983:8983 \
-v ${GITHUB_WORKSPACE}/protected/modules/${{ env.module-id }}/resources/solr:/humhubcore_config/conf \
solr:9 solr-precreate humhubcore /humhubcore_config
- name: Run virus scanner ClamAV
if: ${{ inputs.run-clamav }}
run: |
docker run -d --name clamav \
-v ${GITHUB_WORKSPACE}/protected/modules/${{ env.module-id }}:/usr/local/share/clamav \
-p 3310:3310 clamav/clamav
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
ini-values: date.timezone='UTC'
- name: Determine composer cache directory
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache dependencies installed with composer
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-${{ matrix.dependencies }}-
- name: Install dependencies with composer
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Install npm dependencies
run: npm install
- name: Build production assets
run: grunt build-assets
- name: Run migrations
run: php protected/humhub/tests/codeception/bin/yii migrate/up --includeModuleMigrations=1 --interactive=0
- name: Run installer
run: php protected/humhub/tests/codeception/bin/yii installer/auto
- name: Checkout REST Module
if: ${{ inputs.use-rest-module }}
uses: actions/checkout@v4
with:
repository: 'humhub/rest'
ref: ${{ inputs.rest-module-branch }}
path: 'protected/modules/rest'
# This module should be activated on HumHubApiTestCest::_before()
# Don't to do it here because it has a requirement to Pretty URLs
# - name: Activate REST Module
# if: ${{ inputs.use-rest-module }}
# run: php protected/humhub/tests/codeception/bin/yii module/enable rest
- name: Rebuild search index
run: php protected/humhub/tests/codeception/bin/yii content-search/rebuild
- name: Build codeception core files
run: |
cd $GITHUB_WORKSPACE/protected/humhub/tests
php ../../vendor/bin/codecept build
- name: Run test server
run: |
# Temporary condition while branch "master" doesn't use pretty URLs on acceptance tests.
# The marker is grepped from the core's own test workflows; since humhub/humhub#8255
# the server command lives in php-test-base.yml, so check all php-test*.yml files —
# otherwise the server starts without the index-test.php router and acceptance
# requests are served by the production index.php (setup wizard instead of login).
if grep -qs ":8080 index-test.php" $GITHUB_WORKSPACE/.github/workflows/php-test*.yml
then
php --server 127.0.0.1:8080 index-test.php &>/tmp/phpserver.log &
else
php --server 127.0.0.1:8080 &>/tmp/phpserver.log &
fi
# - name: Setup chromedriver
# run: chromedriver --url-base=/wd/hub &
- name: Valdiate test server
run: sleep 5 && curl --fail --head http://127.0.0.1:8080/index-test.php
- name: Install module dependencies
if: ${{ hashFiles(format('{0}/protected/modules/{1}/composer.json', github.workspace, env.module-id)) != '' }}
run: |
cd $GITHUB_WORKSPACE/protected/modules/${{ env.module-id }}
composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Install module dependencies for the additional module
if: ${{ hashFiles(format('{0}/protected/modules/{1}/composer.json', github.workspace, inputs.additional-module-id)) != '' }}
run: |
cd $GITHUB_WORKSPACE/protected/modules/${{ inputs.additional-module-id }}
composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Run test suite
run: |
export HUMHUB_PATH=$GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE/protected/modules/${{ env.module-id }}/tests
php $GITHUB_WORKSPACE/protected/vendor/bin/codecept build
php $GITHUB_WORKSPACE/protected/vendor/bin/codecept run --env github
- name: Upload Codeception Output
if: failure()
uses: actions/upload-artifact@v4
with:
name: codeception-output
path: |
protected/modules/*/tests/codeception/_output/*
protected/runtime/logs/*