-
Notifications
You must be signed in to change notification settings - Fork 3
322 lines (301 loc) · 14.6 KB
/
extension-test.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
# If you see this message on 'femiwiki/.github' repository, please keep in mind that all changes of
# this workflow file is for being copied to other repositories. If you see this message on any other
# repositories, DO NOT EDIT this file itself. You should edit
# https://github.com/femiwiki/.github/blob/main/workflow-templates/.github/workflows/extension-test.yml
# Instead of this.
name: Quibble and Phan
on:
push:
branches:
- '*'
tags-ignore:
- '*.*'
pull_request:
env:
DOCKER_REGISTRY: docker-registry.wikimedia.org
DOCKER_ORG: releng
QUIBBLE_DOCKER_IMAGE: quibble-buster-php81
# There is no quibble-buster-php81-coverage yet
COVERAGE_DOCKER_IMAGE: quibble-buster-php74-coverage
PHAN_DOCKER_IMAGE: mediawiki-phan-php81
jobs:
test:
strategy:
fail-fast: false
matrix:
stage:
- phan
- coverage
- phpunit-unit
- phpunit
- phpunit-standalone
- npm-test
- composer-test
- selenium
# - qunit
# - api-testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# /home/runner/cache/ Cache
# /home/runner/src/ Mediawiki installation
# /home/runner/src/<TYPE>s/<EXTENSION_NAME>/ Clone of the extension repository
# /home/runner/docker-images/ Docker images which exported with docker-save command
# $GITHUB_WORKSPACE/.github/workflows/dependencies Dependency extensions and skins
- name: Set up
run: |
if [ -e skin.json ]; then
echo "TYPE=skin" >> $GITHUB_ENV
echo "EXTENSION_NAME=$(cat skin.json |
python3 -c 'import json;import sys;print(json.loads("".join(sys.stdin.readlines()))["name"])')" >> $GITHUB_ENV
else
echo "TYPE=extension" >> $GITHUB_ENV
echo "EXTENSION_NAME=$(cat extension.json |
python3 -c 'import json;import sys;print(json.loads("".join(sys.stdin.readlines()))["name"])')" >> $GITHUB_ENV
fi
# Export the target version of MediaWiki
# An example of GITHUB_REF: refs/heads/feature-branch-1
BRANCH_NAME=$(echo "$GITHUB_REF" | cut -d'/' -f3 | cut -d'-' -f1)
BASE_BRANCH_NAME=$(echo "$GITHUB_BASE_REF" | cut -d'/' -f3)
if [[ "$BRANCH_NAME" =~ ^(master|REL[0-9]+_[0-9]+)$ ]]; then
# branch name starts with the version (ex: master-new-feature, REL1_34-bug-fix)
export MEDIAWIKI_VERSION="$BRANCH_NAME"
elif [ "$GITHUB_EVENT_NAME" == 'pull_request' ] && [[ "$BASE_BRANCH_NAME" =~ ^(master|REL[0-9]+_[0-9]+)$ ]]; then
export MEDIAWIKI_VERSION="$BASE_BRANCH_NAME"
else
export MEDIAWIKI_VERSION=master
fi
echo MEDIAWIKI_VERSION="${MEDIAWIKI_VERSION}" >> $GITHUB_ENV
# Get the latest docker tag (Ref: https://github.com/thcipriani/dockerregistry)
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)"
echo "QUIBBLE_DOCKER_LATEST_TAG=${QUIBBLE_DOCKER_LATEST_TAG}" >> $GITHUB_ENV
if [ "${{ matrix.stage }}" == 'phan' ]; then
echo "PHAN_DOCKER_LATEST_TAG=$(curl -sL "https://${DOCKER_REGISTRY}/v2/${DOCKER_ORG}/${PHAN_DOCKER_IMAGE}/tags/list" |
python3 -c 'import json;print("\n".join(json.loads(input())["tags"]))' |
grep -v latest | sort -Vr | head -1)" >> $GITHUB_ENV
elif [ "${{ matrix.stage }}" == 'coverage' ]; then
echo "COVERAGE_DOCKER_LATEST_TAG=$(curl -sL "https://${DOCKER_REGISTRY}/v2/${DOCKER_ORG}/${COVERAGE_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 ]; 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/femiwiki/.github/main/scripts/resolve_dependencies.py -o rd.py
echo "DEPENDENCIES=$(python3 rd.py)" >> $GITHUB_ENV
fi
- name: Cache quibble docker image
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
run: |
if [ -f /home/runner/docker-images/"${QUIBBLE_DOCKER_IMAGE}" ]; then
docker load -i /home/runner/docker-images/"${QUIBBLE_DOCKER_IMAGE}"
else
docker pull "${DOCKER_REGISTRY}/${DOCKER_ORG}/${QUIBBLE_DOCKER_IMAGE}:${QUIBBLE_DOCKER_LATEST_TAG}"
fi
- name: Cache quibble coverage docker image
if: matrix.stage == 'coverage'
uses: actions/cache@v3
with:
path: /home/runner/docker-images/${{ env.COVERAGE_DOCKER_IMAGE }}
key: ${{ env.COVERAGE_DOCKER_IMAGE }}:${{ env.COVERAGE_DOCKER_LATEST_TAG }}
- name: Cache phan docker image
if: matrix.stage == 'phan'
uses: actions/cache@v3
with:
path: /home/runner/docker-images/${{ env.PHAN_DOCKER_IMAGE }}
key: ${{ env.PHAN_DOCKER_IMAGE }}:${{ env.PHAN_DOCKER_LATEST_TAG }}
- name: Load or pull quibble coverage docker image
if: matrix.stage == 'coverage'
run: |
if [ -f /home/runner/docker-images/"${COVERAGE_DOCKER_IMAGE}" ]; then
docker load -i /home/runner/docker-images/"${COVERAGE_DOCKER_IMAGE}"
else
docker pull "${DOCKER_REGISTRY}/${DOCKER_ORG}/${COVERAGE_DOCKER_IMAGE}:${COVERAGE_DOCKER_LATEST_TAG}"
fi
- name: Load or pull phan docker image
if: matrix.stage == 'phan'
run: |
if [ -f /home/runner/docker-images/"${PHAN_DOCKER_IMAGE}" ]; then
docker load -i /home/runner/docker-images/"${PHAN_DOCKER_IMAGE}"
else
docker pull "${DOCKER_REGISTRY}/${DOCKER_ORG}/${PHAN_DOCKER_IMAGE}:${PHAN_DOCKER_LATEST_TAG}"
fi
- name: Cache MediaWiki installation
uses: actions/cache@v3
with:
path: /home/runner/src
key: ${{ runner.os }}-${{ env.MEDIAWIKI_VERSION }}-${{ hashFiles('.github/workflows/dependencies') }}
- 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
if [ "$dep" = 'mediawiki/extensions/Wikibase' ]; then
git clone -b "${MEDIAWIKI_VERSION}" --depth 1 "https://gerrit.wikimedia.org/r/${dep}" src/"$(echo $dep | cut -d'/' -f2,3)"
cd src/"$(echo $dep | cut -d'/' -f2,3)"
# https://gerrit.wikimedia.org/r/q/I2037cd8bb5d568021472e048900649028b5dcc62
git apply << 'EOF'
diff --git a/.gitmodules b/.gitmodules
index df41c768af..e9926d6ddd 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -3,13 +3,13 @@
url = https://gerrit.wikimedia.org/r/data-values/value-view
[submodule "view/lib/wikibase-serialization"]
path = view/lib/wikibase-serialization
- url = https://phabricator.wikimedia.org/source/wikibase-serialization.git
+ url = https://github.com/wmde/WikibaseSerializationJavaScript.git
[submodule "view/lib/wikibase-data-values"]
path = view/lib/wikibase-data-values
- url = https://phabricator.wikimedia.org/source/datavalues-javascript.git
+ url = https://github.com/wmde/DataValuesJavaScript.git
[submodule "view/lib/wikibase-data-model"]
path = view/lib/wikibase-data-model
- url = https://phabricator.wikimedia.org/source/wikibase-data-model.git
+ url = https://github.com/wmde/WikibaseDataModelJavaScript.git
[submodule "view/lib/wikibase-termbox"]
path = view/lib/wikibase-termbox
url = https://gerrit.wikimedia.org/r/wikibase/termbox
EOF
git submodule update --init
cd -
elif [ "$dep" = 'mediawiki/extensions/WikibaseLexeme' ]; then
git clone -b "${MEDIAWIKI_VERSION}" --depth 1 "https://gerrit.wikimedia.org/r/${dep}" src/"$(echo $dep | cut -d'/' -f2,3)"
cd src/"$(echo $dep | cut -d'/' -f2,3)"
# https://gerrit.wikimedia.org/r/q/I2037cd8bb5d568021472e048900649028b5dcc62
git apply << 'EOF'
diff --git a/.gitmodules b/.gitmodules
index 51ab4cd..97dff70 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
[submodule "resources/special/new-lexeme"]
path = resources/special/new-lexeme
- url = https://phabricator.wikimedia.org/diffusion/NLSP/new-lexeme-special-page.git
+ url = https://github.com/wmde/new-lexeme-special-page.git
EOF
git submodule update --init
cd -
else
git clone --recurse-submodules -b "${MEDIAWIKI_VERSION}" --depth 1 "https://gerrit.wikimedia.org/r/${dep}" src/"$(echo $dep | cut -d'/' -f2,3)"
fi
done
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: '7.4'
- name: Composer install
if: ${{ matrix.stage == 'phan' }}
run: |
composer install --prefer-dist --no-progress --no-interaction # $GITHUB_WORKSPACE
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
- name: Run npm because Quibble is not compatible with yarn.
run: |
if [ -f yarn.lock ]; then
npm install
fi
- name: Main Test
run: |
cd /home/runner
# Move our repository
mkdir -p cache cover src/skins src/extensions
sudo cp -r "${GITHUB_WORKSPACE}" "src/${{ env.TYPE }}s/${{ env.EXTENSION_NAME }}"
chmod 777 src cache cover
# https://github.com/femiwiki/.github/issues/3
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 \
--entrypoint quibble-with-supervisord \
-e "ZUUL_PROJECT=mediawiki/${{ env.TYPE }}s/${{ env.EXTENSION_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=${{ env.TYPE }}s/${{ env.EXTENSION_NAME }}" \
-v "$(pwd)"/src:/mediawiki \
"${DOCKER_REGISTRY}/${DOCKER_ORG}/${PHAN_DOCKER_IMAGE}:${PHAN_DOCKER_LATEST_TAG}" \
--color
elif [ "${{ matrix.stage }}" == 'coverage' ]; then
if [ -d tests/phpunit ]; then
# MW1.35+ requires PHP7.3 but quibble-coverage is not.
if [ "${MEDIAWIKI_VERSION}" == 'master' ]; then
if [ "${TYPE}" == 'skin' ]; then
COMMEND=mwskin-phpunit-coverage
else
COMMEND=mwext-phpunit-coverage
fi
docker run \
--entrypoint quibble-with-supervisord \
-e "ZUUL_PROJECT=mediawiki/${{ env.TYPE }}s/${{ env.EXTENSION_NAME }}" \
-v "$(pwd)"/cache:/cache \
-v "$(pwd)"/src:/workspace/src \
-v "$(pwd)"/cover:/workspace/cover \
"${DOCKER_REGISTRY}/${DOCKER_ORG}/${COVERAGE_DOCKER_IMAGE}:${COVERAGE_DOCKER_LATEST_TAG}" \
--skip-zuul \
--skip-deps \
-c "${COMMEND}"
fi
fi
else
docker run \
--entrypoint quibble-with-supervisord \
-e "ZUUL_PROJECT=mediawiki/${{ env.TYPE }}s/${{ env.EXTENSION_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 \
--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/${{ env.TYPE }}s/${{ env.EXTENSION_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/${QUIBBLE_DOCKER_IMAGE}" \
"${DOCKER_REGISTRY}/${DOCKER_ORG}/${QUIBBLE_DOCKER_IMAGE}:${QUIBBLE_DOCKER_LATEST_TAG}"
if [ -n "$PHAN_DOCKER_LATEST_TAG" ]; then
docker save -o "$(pwd)/docker-images/${PHAN_DOCKER_IMAGE}" \
"${DOCKER_REGISTRY}/${DOCKER_ORG}/${PHAN_DOCKER_IMAGE}:${PHAN_DOCKER_LATEST_TAG}"
elif [ -n "$COVERAGE_DOCKER_LATEST_TAG" ]; then
docker save -o "$(pwd)/docker-images/${COVERAGE_DOCKER_IMAGE}" \
"${DOCKER_REGISTRY}/${DOCKER_ORG}/${COVERAGE_DOCKER_IMAGE}:${COVERAGE_DOCKER_LATEST_TAG}"
fi