Xqt submitted this change.

View Change

Approvals: Xqt: Verified; Looks good to me, approved
[tests] Add oauth tests to github action

also simplify login_tests-ci.yml

Bug: T296371
Change-Id: Ifde67a0c3ab09e130d718431684d86a54a662580
---
M .github/workflows/login_tests-ci.yml
A .github/workflows/oauth_tests-ci.yml
2 files changed, 135 insertions(+), 32 deletions(-)

diff --git a/.github/workflows/login_tests-ci.yml b/.github/workflows/login_tests-ci.yml
index 33b7581..7e405ac 100644
--- a/.github/workflows/login_tests-ci.yml
+++ b/.github/workflows/login_tests-ci.yml
@@ -1,8 +1,5 @@
-# This workflow will install Python dependencies, run Pywikibot tests
-# with a variety of Python versions. For more information see:
-# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
-
name: Login CI
+description: Run login/logout tests

on:
workflow_run:
@@ -20,7 +17,6 @@
build:
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
if: ${{ github.event.workflow_run.conclusion == 'success' }}
- continue-on-error: ${{ matrix.experimental || false }}
timeout-minutes: 2

strategy:
@@ -28,35 +24,33 @@
max-parallel: 1

matrix:
- python-version: ["pypy3.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
- site: ["wikipedia:en", "wikisource:zh"]
- test_prod_only: [true]
+ python-version: ["pypy3.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
+ site: ['wikipedia:en', 'wikisource:zh']
include:
- - python-version: "3.6"
+ - python-version: 3.6
site: False
family: wpbeta
code: en
- - python-version: "3.6"
+ - python-version: 3.6
site: False
family: wpbeta
code: zh
- - python-version: "3.8"
+ - python-version: 3.8
site: wsbeta:en
- - python-version: "3.7"
- site: "wikipedia:test"
- - 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"
- - python-version: "3.8"
- site: "wowwiki:uk"
- - python-version: "3.12"
- site: "wikipedia:test"
- - python-version: "3"
- site: "wikipedia:de"
+ - python-version: 3.7
+ site: wikipedia:test
+ - python-version: 3.7
+ site: wikidata:test
+ - python-version: 3.9
+ site: wiktionary:ar
+ - python-version: 3.6
+ site: wikidata:wikidata
+ - python-version: 3.8
+ site: wowwiki:uk
+ - python-version: 3.12
+ site: wikipedia:test
+ - python-version: 3
+ site: wikipedia:de
os: macOS-latest

steps:
@@ -86,7 +80,7 @@
pip install requests
pip install mwparserfromhell
pip install codecov
- pip install "coverage>=5.2.1"
+ pip install coverage
python -c "import setuptools; print('setuptools:', setuptools.__version__)"

- name: Generate family files
@@ -121,12 +115,9 @@

- name: Test with unittest
timeout-minutes: 1
- 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
coverage run -m unittest -vv tests/site_login_logout_tests.py
+
- name: Upload coverage to Codecov
- run: codecov
+ run: codecov
\ No newline at end of file
diff --git a/.github/workflows/oauth_tests-ci.yml b/.github/workflows/oauth_tests-ci.yml
new file mode 100644
index 0000000..03300c1
--- /dev/null
+++ b/.github/workflows/oauth_tests-ci.yml
@@ -0,0 +1,112 @@
+name: Oauth CI
+description: Run login tests using OAuth
+
+on:
+ workflow_run:
+ workflows: [ "Pywikibot CI" ]
+ branches: [ master ]
+ types:
+ - completed
+
+env:
+ PYWIKIBOT_TEST_RUNNING: 1
+ PYWIKIBOT_LOGIN_LOGOUT: 1
+ PYWIKIBOT_USERNAME: Pywikibot-oauth
+
+jobs:
+ build:
+ runs-on: ${{ matrix.os || 'ubuntu-latest' }}
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
+ timeout-minutes: 2
+
+ strategy:
+ fail-fast: false
+ max-parallel: 1
+
+ matrix:
+ python-version: ["pypy3.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
+ family: ['wikipedia']
+ code: ['test']
+ domain: ['test.wikipedia.org']
+ include:
+ - python-version: 3.6
+ family: wpbeta
+ code: en
+ domain: en.wikipedia.beta.wmflabs.org
+ - python-version: 3.11
+ family: wpbeta
+ code: zh
+ domain: zh.wikipedia.beta.wmflabs.org
+
+ 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.12' }}
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ # use deadsnakes/action until actions/setup-python supports Python 3.12
+ - name: Set up development Python ${{ matrix.python-version }}
+ uses: deadsnakes/action@v2.1.1
+ if: ${{ matrix.python-version == '3.12' }}
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - name: Get token name
+ env:
+ _oauth_token: OAUTH_TOKEN_${{ matrix.family }}_${{ matrix.code }}
+ uses: ASzc/change-string-case-action@v5
+ id: token
+ with:
+ string: ${{ env._oauth_token }}
+
+ - name: Split OAuth Token
+ uses: jungwinter/split@v2
+ id: split
+ with:
+ # msg: ${{ env._oauth_token_val }}
+ msg: ${{ secrets[format('{0}', steps.token.outputs.uppercase)] }}
+ separator: ":"
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip --version
+ pip install -U setuptools
+ pip install requests
+ pip install mwparserfromhell
+ pip install mwoauth
+ pip install codecov
+ pip install coverage
+ python -c "import setuptools; print('setuptools:', setuptools.__version__)"
+
+ - name: Generate family files
+ if: ${{ matrix.family == 'wpbeta' }}
+ run: |
+ python pwb.py generate_family_file http://${{matrix.code}}.wikipedia.beta.wmflabs.org/ wpbeta y
+
+ - name: Generate user files
+ run: |
+ python -Werror::UserWarning -m pwb generate_user_files -family:${{matrix.family}} -lang:${{matrix.code}} -user:${{ env.PYWIKIBOT_USERNAME }} -v -debug;
+ echo "authenticate['${{ matrix.domain }}'] = ('${{ steps.split.outputs._0 }}', '${{ steps.split.outputs._1 }}', '${{ steps.split.outputs._2 }}', '${{ steps.split.outputs._3 }}')" >> 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_OAUTHPWD }}')" > passwordfile
+
+ - name: Test with unittest
+ timeout-minutes: 1
+ run: |
+ python pwb.py version
+ coverage run -m unittest -vv tests/site_login_logout_tests.py
+
+ - name: Upload coverage to Codecov
+ run: codecov
\ No newline at end of file

To view, visit change 853502. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ifde67a0c3ab09e130d718431684d86a54a662580
Gerrit-Change-Number: 853502
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged