-
Notifications
You must be signed in to change notification settings - Fork 194
180 lines (163 loc) · 6.41 KB
/
pywikibot-ci.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
name: Pywikibot CI
# Run Pywikibot tests with a variety of Python versions
on:
push:
branches: [ master, stable ]
pull_request:
branches: [ master ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYWIKIBOT_TEST_RUNNING: 1
PYWIKIBOT_USERNAME: Pywikibot-test
jobs:
build:
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
continue-on-error: ${{ matrix.experimental || false }}
timeout-minutes: 100
strategy:
fail-fast: false
max-parallel: 17
matrix:
python-version: ["pypy3.7", "3.7", "3.8", "3.9", "3.10", "3.11"]
site: ['wikipedia:en', 'wikisource:zh']
test_prod_only: [true]
include:
# ubuntu-20.04 required for Python 3.6
- python-version: 3.7
site: wikipedia:test
- python-version: 3.6
site: False
family: wpbeta
code: en
os: ubuntu-20.04
- python-version: 3.6
site: False
family: wpbeta
code: zh
os: ubuntu-20.04
- python-version: 3.8
site: wsbeta:en
- python-version: 3.7
site: wikidata:test
- python-version: 3.9
site: wiktionary:ar
test_no_rc: true
- python-version: 3.6
site: wikidata:wikidata
os: ubuntu-20.04
- python-version: 3.8
site: wowwiki:uk
- python-version: 3
site: wikipedia:de
os: macOS-latest
- python-version: 3.6
site: wikipedia:en
test_prod_only: true
os: ubuntu-20.04
- python-version: 3.6
site: wikisource:zh
test_prod_only: true
os: ubuntu-20.04
- python-version: "3.12.0-alpha - 3.12.0" # 3.12 fails due to T337748
site: wikipedia:en
test_prod_only: true
experimental: true
- python-version: "3.12.0-alpha - 3.12.0" # 3.12 fails due to T337748
site: wikisource:zh
test_prod_only: true
experimental: true
- python-version: "3.13-dev"
site: wikipedia:test
experimental: true
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
if: ${{ matrix.python-version != '3.13-dev' }}
with:
python-version: ${{ matrix.python-version }}
# use deadsnakes/action until actions/setup-python supports Python 3.13
- name: Set up development Python ${{ matrix.python-version }}
uses: deadsnakes/[email protected]
if: ${{ matrix.python-version == '3.13-dev' }}
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip --version
pip install -U setuptools
if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install wikitextparser
python -c "import setuptools; print('setuptools:', setuptools.__version__)"
- name: Generate family files
run: |
if [ ${{matrix.family || 0}} == wpbeta ]; then
python pwb.py generate_family_file http://${{matrix.code}}.wikipedia.beta.wmflabs.org/ wpbeta y
fi
if [ ${{matrix.site || 0}} == 'wsbeta:en' ]; then
python pwb.py generate_family_file http://en.wikisource.beta.wmflabs.org/ wsbeta y
fi
- name: Generate user files
run: |
if [ ${{matrix.site}} != false ]; then
python -Werror::UserWarning -m pwb generate_user_files -site:${{matrix.site}} -user:${{ env.PYWIKIBOT_USERNAME }} -v -debug;
else
python -Werror::UserWarning -m pwb generate_user_files -family:${{matrix.family}} -lang:${{matrix.code}} -user:${{ env.PYWIKIBOT_USERNAME }} -v -debug;
fi
echo "usernames['wikipedia']['en'] = '${{ env.PYWIKIBOT_USERNAME }}'" >> user-config.py
echo "usernames['wikisource']['zh'] = '${{ env.PYWIKIBOT_USERNAME }}'" >> user-config.py
echo "usernames['wikipedia']['test'] = '${{ env.PYWIKIBOT_USERNAME }}'" >> user-config.py
echo "usernames['wikidata']['test'] = '${{ env.PYWIKIBOT_USERNAME }}'" >> user-config.py
echo "usernames['commons']['commons'] = '${{ env.PYWIKIBOT_USERNAME }}'" >> user-config.py
echo "usernames['meta']['meta'] = '${{ env.PYWIKIBOT_USERNAME }}'" >> user-config.py
echo "max_retries = 3" >> user-config.py
echo "noisysleep = float('inf')" >> user-config.py
echo "maximum_GET_length = 5000" >> user-config.py
echo "console_encoding = 'utf8'" >> user-config.py
echo "import os" >> user-config.py
echo "password_file = os.path.expanduser('passwordfile')" >> user-config.py
echo "('${{ env.PYWIKIBOT_USERNAME }}', '${{ secrets.PYWIKIBOT_USERPWD }}')" > passwordfile
- name: Test with unittest or pytest and coverage
if: ${{ matrix.python-version != '3.13-dev' }}
id: ci_test
continue-on-error: true
timeout-minutes: 90
env:
PYWIKIBOT_TEST_NO_RC:
${{ (matrix.site == 'wikisource:zh' || matrix.test_no_rc) && 1 || 0 }}
PYWIKIBOT_TEST_PROD_ONLY: ${{ matrix.test_prod_only && 1 || 0 }}
run: |
python pwb.py version
if [ ${{matrix.site || 0}} != 'wikipedia:test' ]; then
coverage run -m unittest discover -vv -p \"*_tests.py\";
else
pytest --cov=.;
fi
- name: Test with unittest without coverage due to T346862
if: ${{ matrix.python-version == '3.13-dev' }}
id: ci_test_no_cover
continue-on-error: true
timeout-minutes: 90
env:
PYWIKIBOT_TEST_NO_RC:
${{ (matrix.site == 'wikisource:zh' || matrix.test_no_rc) && 1 || 0 }}
PYWIKIBOT_TEST_PROD_ONLY: ${{ matrix.test_prod_only && 1 || 0 }}
run: |
python pwb.py version
python -m unittest discover -vv -p \"*_tests.py\";
- name: Show coverage statistics
if: ${{ matrix.python-version != '3.13-dev' }}
run: |
coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
- name: Check on failure
if: steps.ci_test.outcome == 'failure'
run: exit 1