jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/855036 )
Change subject: [test] Improvements for oauth_tests-ci.yml ......................................................................
[test] Improvements for oauth_tests-ci.yml
- use PYWIKIBOT_TEST_OAUTH as environment variable instead of OAUTH_TOKEN_<site>_<code> within oauth_tests-ci.yml - update tests/README.rst - always run oauth_tests-ci - cancel job if new job was started - run tests on windows and macOS - use actions/setup-python because 3.12 is available now
Change-Id: Ia912326678b0c71fe63574f2347fe8cfb604ff2f --- M .github/workflows/oauth_tests-ci.yml M tests/README.rst M tests/oauth_tests.py 3 files changed, 26 insertions(+), 21 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/.github/workflows/oauth_tests-ci.yml b/.github/workflows/oauth_tests-ci.yml index 658ada7..d04b23d 100644 --- a/.github/workflows/oauth_tests-ci.yml +++ b/.github/workflows/oauth_tests-ci.yml @@ -2,16 +2,17 @@ # Run login tests using OAuth
on: - workflow_run: - workflows: [ "Pywikibot CI" ] + push: branches: [ master ] - types: - - completed + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true
env: PYWIKIBOT_TEST_RUNNING: 1 - PYWIKIBOT_LOGIN_LOGOUT: 1 PYWIKIBOT_USERNAME: Pywikibot-oauth + PYWIKIBOT_LOGIN_LOGOUT: 1
jobs: build: @@ -20,19 +21,24 @@
strategy: fail-fast: false - max-parallel: 8 + max-parallel: 15
matrix: - python-version: ["pypy3.7", "3.12", "3.11", "3.10", "3.9", "3.8", "3.7", "3.6"] + os: [ "windows-latest", "macOS-latest", "ubuntu-latest" ] + python-version: ["pypy3.7", "3.11", "3.10", "3.9", "3.8", "3.7", "3.6"] family: ['wikipedia'] code: ['test'] domain: ['test.wikipedia.org'] include: + - python-version: "3.12.0-alpha - 3.12.0" + family: wikipedia + code: test + domain: test.wikipedia.org - python-version: 3.6 family: wpbeta code: en domain: en.wikipedia.beta.wmflabs.org - - python-version: 3.11 + - python-version: 3.7 family: wpbeta code: zh domain: zh.wikipedia.beta.wmflabs.org @@ -45,20 +51,12 @@
- 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 }} + _oauth_token: OAUTH_TOKEN_${{ matrix.family }}_${{ matrix.code }} uses: ASzc/change-string-case-action@v5 id: token with: @@ -100,7 +98,7 @@ - name: Test with unittest timeout-minutes: 1 env: - ${{ steps.token.outputs.uppercase }}: ${{ secrets[format('{0}', steps.token.outputs.uppercase)] }} + PYWIKIBOT_TEST_OAUTH: ${{ secrets[format('{0}', steps.token.outputs.uppercase)] }} run: | python pwb.py version coverage run -m unittest -vv tests/site_login_logout_tests.py diff --git a/tests/README.rst b/tests/README.rst index acc4b21..cd07199 100644 --- a/tests/README.rst +++ b/tests/README.rst @@ -123,6 +123,15 @@
.. note:: test names must be given without subsequent ``_tests``.
+**PYWIKIBOT_TEST_OAUTH** + This environment variable holds the Oauth token. It is set by + ``oauth_tests-ci.yml`` CI config file and is solely used by + :mod:`tests.oauth_tests`. You can use it for your private tests. The + environment variabke must contain consumer key and secret and access + key and secret delimited by ``:`` as:: + + PYWIKIBOT_TEST_OAUTH=consumer_key:consumer_secret:access_key:access:secret + **PYWIKIBOT_TEST_RUNNING** This environment variable skips tests instead of raising :exc:`exceptions.MaxlagTimeoutError` when maximum retries attempted due to diff --git a/tests/oauth_tests.py b/tests/oauth_tests.py index 242c126..f66413c 100755 --- a/tests/oauth_tests.py +++ b/tests/oauth_tests.py @@ -26,9 +26,7 @@
def _get_oauth_tokens(self): """Get valid OAuth tokens from environment variables.""" - tokens_env = 'OAUTH_TOKEN_' + self.family.upper() - tokens = os.environ.get(tokens_env + '_' + self.code.upper()) - tokens = tokens or os.environ.get(tokens_env) + tokens = os.environ.get('PYWIKIBOT_TEST_OAUTH') return tuple(tokens.split(':')) if tokens is not None else None
def setUp(self):
pywikibot-commits@lists.wikimedia.org