forked from Universal-Omega/DynamicPageList3
-
Notifications
You must be signed in to change notification settings - Fork 0
322 lines (283 loc) · 12.5 KB
/
mediawiki-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
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
name: Quibble and Phan
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
name: "${{ matrix.mw }} | PHP ${{ matrix.php }} (${{ matrix.stage }})"
strategy:
matrix:
include:
# Latest stable MediaWiki - PHP 7.4 (phan)
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
stage: phan
# Latest MediaWiki master - PHP 7.4 (phan)
- mw: 'master'
php: 7.4
php-docker: 74
experimental: true
stage: phan
# Latest MediaWiki master - PHP 7.4 (coverage)
- mw: 'master'
php: 7.4
php-docker: 74
experimental: false
stage: coverage
# Latest stable MediaWiki - PHP 7.4 (phpunit-unit)
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
stage: phpunit-unit
# Latest MediaWiki master - PHP 7.4 (phpunit-unit)
- mw: 'master'
php: 7.4
php-docker: 74
experimental: false
stage: phpunit-unit
# Latest stable MediaWiki - PHP 7.4 (phpunit)
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
stage: phpunit
# Latest MediaWiki master - PHP 7.4 (phpunit)
- mw: 'master'
php: 7.4
php-docker: 74
experimental: false
stage: phpunit
# Latest MediaWiki master - PHP 8.1 (phpunit)
- mw: 'master'
php: 8.1
php-docker: 81
experimental: false
stage: phpunit
# Latest stable MediaWiki - PHP 7.4 (selenium)
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
stage: selenium
# Latest MediaWiki master - PHP 7.4 (selenium)
- mw: 'master'
php: 7.4
php-docker: 74
experimental: false
stage: selenium
# Latest stable MediaWiki - PHP 7.4 (qunit)
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
stage: qunit
# Latest MediaWiki master - PHP 7.4 (qunit)
- mw: 'master'
php: 7.4
php-docker: 74
experimental: false
stage: qunit
# Latest stable MediaWiki - PHP 7.4 (composer-test)
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
stage: composer-test
runs-on: ubuntu-latest
env:
DOCKER_REGISTRY: docker-registry.wikimedia.org
DOCKER_ORG: releng
QUIBBLE_DOCKER_IMAGE: quibble-buster-php${{ matrix.php-docker }}
COVERAGE_DOCKER_IMAGE: quibble-buster-php${{ matrix.php-docker }}-coverage
PHAN_DOCKER_IMAGE: mediawiki-phan-php${{ matrix.php-docker }}
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
# /home/runner/cache/ Cache
# /home/runner/src/ Mediawiki installation
# /home/runner/src/extensions/EXTENSION_NAME/ Clone of the extension repository
# /home/runner/docker-images/ Docker images which exported with docker-save command
# $GITHUB_WORKSPACE/.github/workflows/dependencies Necessary dependencies - YAML syntax
# $GITHUB_WORKSPACE/.github/workflows/globals.php Add global configuration options for MediaWiki
- name: Set up
run: |
echo MEDIAWIKI_VERSION="${{ matrix.mw }}" >> $GITHUB_ENV
if [ "${{ matrix.stage }}" == 'phan' ]; then
export DOCKER_IMAGE="${PHAN_DOCKER_IMAGE}"
elif [ "${{ matrix.stage }}" == coverage ]; then
export DOCKER_IMAGE="${COVERAGE_DOCKER_IMAGE}"
else
export DOCKER_IMAGE="${QUIBBLE_DOCKER_IMAGE}"
fi
echo "DOCKER_IMAGE=${DOCKER_IMAGE}" >> $GITHUB_ENV
# Get the latest docker tag (Ref: https://github.com/thcipriani/dockerregistry)
DOCKER_LATEST_TAG="$(curl -sL "https://${DOCKER_REGISTRY}/v2/${DOCKER_ORG}/${DOCKER_IMAGE}/tags/list" |
python3 -c 'import json;print("\n".join(json.loads(input())["tags"]))' |
grep -v latest | sort -Vr | head -1)"
echo "DOCKER_LATEST_TAG=${DOCKER_LATEST_TAG}" >> $GITHUB_ENV
if [ "${{ matrix.stage }}" == 'phan' ] || [ "${{ matrix.stage }}" == 'coverage' ]; then
echo "QUIBBLE_DOCKER_LATEST_TAG=$(curl -sL "https://${DOCKER_REGISTRY}/v2/${DOCKER_ORG}/${QUIBBLE_DOCKER_IMAGE}/tags/list" |
python3 -c 'import json;print("\n".join(json.loads(input())["tags"]))' |
grep -v latest | sort -Vr | head -1)" >> $GITHUB_ENV
fi
# Resolve dependencies
if [ -e .github/workflows/dependencies ] && [ "${{ matrix.stage }}" == 'phan' ]; then
cd .github/workflows
curl -sL https://raw.githubusercontent.com/wikimedia/integration-config/master/zuul/parameter_functions.py -o pf.py
curl -sL https://raw.githubusercontent.com/Universal-Omega/scripts/master/mediawiki/resolve_dependencies.py -o rd.py
echo "DEPENDENCIES=$(python3 rd.py)" >> $GITHUB_ENV
fi
- name: Cache docker image
uses: actions/cache@v3
with:
path: /home/runner/docker-images/${{ env.DOCKER_IMAGE }}
key: ${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_LATEST_TAG }}
- name: Load or pull docker image
run: |
docker load -i /home/runner/docker-images/"${DOCKER_IMAGE}" || \
docker pull "${DOCKER_REGISTRY}/${DOCKER_ORG}/${DOCKER_IMAGE}:${DOCKER_LATEST_TAG}"
- name: Cache quibble docker image
if: ${{ matrix.stage == 'coverage' || matrix.stage == 'phan' }}
uses: actions/cache@v3
with:
path: /home/runner/docker-images/${{ env.QUIBBLE_DOCKER_IMAGE }}
key: ${{ env.QUIBBLE_DOCKER_IMAGE }}:${{ env.QUIBBLE_DOCKER_LATEST_TAG }}
- name: Load or pull quibble docker image
if: ${{ matrix.stage == 'coverage' || matrix.stage == 'phan' }}
run: |
docker load -i /home/runner/docker-images/"${QUIBBLE_DOCKER_IMAGE}" || \
docker pull "${DOCKER_REGISTRY}/${DOCKER_ORG}/${QUIBBLE_DOCKER_IMAGE}:${QUIBBLE_DOCKER_LATEST_TAG}"
- name: Download MediaWiki and extensions
run: |
cd /home/runner
if [ ! -d src ]; then
git clone -b "${MEDIAWIKI_VERSION}" --depth 1 https://gerrit.wikimedia.org/r/mediawiki/core src
git clone --recurse-submodules -b "${MEDIAWIKI_VERSION}" --depth 1 https://gerrit.wikimedia.org/r/mediawiki/skins/Vector src/skins/Vector
for dep in $DEPENDENCIES; do
dependency=$(echo $dep | cut -d'|' -f1)
repository=$(echo $dep | cut -sd'|' -f2)
branch=$(echo $dep | rev | cut -sd'|' -f1 | rev)
if [ $repository == $branch ]; then
repository=""
fi
git clone --recurse-submodules -b "${branch:-${MEDIAWIKI_VERSION}}" --depth 1 "${repository:-https://gerrit.wikimedia.org/r/${dependency}}" src/"$(echo $dependency | cut -d'/' -f2,3)"
done
fi
if [ -e "$GITHUB_WORKSPACE"/.github/workflows/globals.php ]; then
echo 'require_once __DIR__ . "/../extensions/${{ github.event.repository.name }}/.github/workflows/globals.php";' >> src/includes/DevelopmentSettings.php
fi
git -C src/ log -n 1 --format="%H"
- name: Cache dependencies (composer and npm)
uses: actions/cache@v3
with:
path: /home/runner/cache
key: ${{ runner.os }}-${{ env.MEDIAWIKI_VERSION }}-${{ hashFiles('**/*.lock') }}
- name: Setup PHP Action
if: ${{ matrix.stage == 'phan' }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
- name: Composer install
if: ${{ matrix.stage == 'phan' }}
run: |
if [ -e composer.json ]; then
composer install --prefer-dist --no-progress --no-interaction
fi
- name: Fix PHPCS violations
continue-on-error: true
if: ${{ github.event_name == 'pull_request' && matrix.stage == 'composer-test' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ -e composer.json ]; then
composer install --prefer-dist --no-progress --no-interaction
composer fix
rm composer.lock
if ! git diff --exit-code --quiet; then
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git checkout -b ${GITHUB_HEAD_REF}
git add .
git commit -am "CI: lint code to MediaWiki standards" -m "Check commit and GitHub actions for more details"
git pull origin ${GITHUB_HEAD_REF} --rebase
git push --set-upstream origin ${GITHUB_HEAD_REF}
else
echo "No changes to commit"
fi
fi
- name: Main Test
continue-on-error: ${{ matrix.experimental }}
run: |
cd /home/runner
# Move our extension
sudo cp -r "${GITHUB_WORKSPACE}" src/extensions/
mkdir -p cache cover
chmod 777 src cache cover
sudo chown -R nobody:nogroup src cache
sudo chown $(id -u):$(id -g) src cache
# Composer install
if [ "${{ matrix.stage }}" == 'phan' ] || [ "${{ matrix.stage }}" == 'coverage' ]; then
docker run \
-e ZUUL_PROJECT=mediawiki/extensions/"${{ github.event.repository.name }}" \
-v "$(pwd)"/cache:/cache \
-v "$(pwd)"/src:/workspace/src \
"${DOCKER_REGISTRY}/${DOCKER_ORG}/${QUIBBLE_DOCKER_IMAGE}:${QUIBBLE_DOCKER_LATEST_TAG}" \
--skip-zuul \
--packages-source composer \
--skip-install \
--skip all \
$DEPENDENCIES
fi
if [ "${{ matrix.stage }}" == 'phan' ]; then
docker run \
-e THING_SUBNAME=extensions/"${{ github.event.repository.name }}" \
-v "$(pwd)"/src:/mediawiki \
"${DOCKER_REGISTRY}/${DOCKER_ORG}/${DOCKER_IMAGE}:${DOCKER_LATEST_TAG}" \
--color
elif [ "${{ matrix.stage }}" == 'coverage' ] && [ -d src/extensions/"${{ github.event.repository.name }}"/tests/phpunit ]; then
docker run \
--entrypoint quibble-with-supervisord \
-e ZUUL_PROJECT=mediawiki/extensions/"${{ github.event.repository.name }}" \
-v "$(pwd)"/cache:/cache \
-v "$(pwd)"/src:/workspace/src \
-v "$(pwd)"/cover:/workspace/cover \
"${DOCKER_REGISTRY}/${DOCKER_ORG}/${DOCKER_IMAGE}:${DOCKER_LATEST_TAG}" \
--skip-zuul \
--skip-deps \
-c mwext-phpunit-coverage
elif [ "${{ matrix.stage }}" != 'coverage' ]; then
docker run \
--entrypoint quibble-with-supervisord \
-e ZUUL_PROJECT=mediawiki/extensions/"${{ github.event.repository.name }}" \
-v "$(pwd)"/cache:/cache \
-v "$(pwd)"/src:/workspace/src \
"${DOCKER_REGISTRY}/${DOCKER_ORG}/${DOCKER_IMAGE}:${DOCKER_LATEST_TAG}" \
--skip-zuul \
--packages-source composer \
--run "${{ matrix.stage }}" \
$DEPENDENCIES
fi
- name: Upload coverage to Codecov
if: ${{ matrix.stage == 'coverage' }}
uses: codecov/codecov-action@v3
with:
directory: /home/runner/cover
- name: Tear down
run: |
cd /home/runner
sudo rm -rf src/extensions/"${{ github.event.repository.name }}"
# See https://doc.wikimedia.org/quibble/index.html#remove-localsettings-php-between-runs
rm "$(pwd)"/src/LocalSettings.php || true
mkdir -p docker-images
docker save -o "$(pwd)/docker-images/${DOCKER_IMAGE}" \
"${DOCKER_REGISTRY}/${DOCKER_ORG}/${DOCKER_IMAGE}:${DOCKER_LATEST_TAG}"