wikimedia/pywikibot

View on GitHub
.github/workflows/doctest.yml

Summary

Maintainability
Test Coverage
name: Doctest CI
# Run Pywikibot doctests  with a variety of Python versions

on:
  push:
    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' }}
    timeout-minutes: 10

    strategy:
      fail-fast: false
      max-parallel: 17

      matrix:
        python-version: [ "pypy3.7", "pypy3.10", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-alpha - 3.13.0" ]
        os: [ windows-latest, macOS-latest, ubuntu-latest ]
        include:
          - python-version: "3.14-dev"
        exclude:
          - os: macOS-latest
            python-version: "pypy3.7"
          - os: macOS-latest
            python-version: "3.7"

    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/action@v3.1.0
      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
        pip install "importlib_metadata ; python_version < '3.8'"
        pip install mwparserfromhell
        pip install packaging
        pip install "PyMySQL >= 1.0.0"
        pip install pytest
        pip install "sseclient<0.0.23,>=0.0.18"
        pip install wikitextparser

    - name: Generate user files
      run: |
        python -Werror::UserWarning -m pwb generate_user_files -site:wikipedia:test -user:${{ env.PYWIKIBOT_USERNAME }} -v -debug;

    - name: doctest with pytest
      timeout-minutes: 5
      run: |
        python pwb.py version
        pytest --version
        coverage run -m pytest pywikibot --doctest-modules --ignore-glob="*gui.py" --ignore-glob="*memento.py"

    - name: Show coverage statistics
      run: |
        coverage report

    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v4
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}