Skip to content

Login CI

Login CI #4174

---
# Run login/logout tests
name: Login CI
on:
workflow_run:
workflows: [Pywikibot CI]
branches: [master]
types: [completed]
env:
PYWIKIBOT_TEST_RUNNING: 1
PYWIKIBOT_TEST_LOGOUT: 1
PYWIKIBOT_USERNAME: Pywikibot-test
jobs:
wait_for_all:
name: Wait for other workflows to finish
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Wait for all workflows to complete excluding this one
uses: kachick/[email protected]
with:
skip-same-workflow: true
skip-list: |
[
{
"workflowFile": "login_tests-ci.yml",
"jobName": "Wait for other workflows to finish"
}
]
warmup-delay: PT1M
minimum-interval: PT5M
run_tests:
name: Run Login/Logout Tests
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
needs: wait_for_all
timeout-minutes: 30
strategy:
fail-fast: false
max-parallel: 1
matrix:
python-version: [pypy3.8, pypy3.10, '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', 3.14-dev, 3.15-dev]
site: ['wikipedia:en', 'wikisource:zh', 'wikipedia:test']
include:
- python-version: '3.8'
site: false
family: wpbeta
code: en
os: ubuntu-22.04
- python-version: '3.8'
site: false
family: wpbeta
code: zh
os: ubuntu-22.04
- python-version: '3.9'
site: wsbeta:en
- python-version: '3.8'
site: wikidata:test
os: ubuntu-22.04
- python-version: '3.10'
site: wiktionary:ar
- python-version: '3.8'
site: wikidata:wikidata
os: ubuntu-22.04
- python-version: '3.9'
site: wowwiki:uk
- python-version: 3
site: wikipedia:de
os: macOS-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
if: "!endsWith(matrix.python-version, '-dev')"
with:
python-version: ${{ matrix.python-version }}
# use deadsnakes/action for development releases
- name: Set up development Python ${{ matrix.python-version }}
uses: deadsnakes/[email protected]
if: endsWith(matrix.python-version, '-dev')
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip --version
pip install "coverage == 7.6.1; python_version < '3.9'"
pip install "coverage >= 7.6.10; python_version > '3.8'"
pip install "tomli; python_version < '3.11'"
pip install mwparserfromhell
pip install packaging
pip install requests
- name: Generate family files
run: |
if [ ${{matrix.family || 0}} == wpbeta ]; then
python pwb.py generate_family_file http://${{matrix.code}}.wikipedia.beta.wmcloud.org/ wpbeta y
fi
if [ ${{matrix.site || 0}} == 'wsbeta:en' ]; then
python pwb.py generate_family_file http://en.wikisource.beta.wmcloud.org/ wsbeta n
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 "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: Login test with unittest
timeout-minutes: 2
run: |
python pwb.py version
coverage run -m unittest -vv tests/site_login_logout_tests.py
- name: Show coverage statistics
run: |
coverage combine || true
coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}