jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/743686 )

Change subject: [tests] Add test environments to github actions
......................................................................

[tests] Add test environments to github actions

- add PYWIKIBOT_TESTS_RUNNING environment variable
- add PYWIKIBOT_TEST_NO_RC environment variable which is 1 for
  wikisource:zh site and matrix.test_no_rc setting and 0 otherwise
- add PYWIKIBOT_TEST_PROD_ONLY for all tests except included tests
- run version script before tests to get the PYWIKIBOT_TESTS_ settings
- use github expressions to simplify settings

Bug: T296371
Change-Id: I13143f91ae031e9698ff3c27a238f7e831278dfd
---
M .github/workflows/pywikibot-ci.yml
M tests/aspects.py
2 files changed, 22 insertions(+), 10 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/.github/workflows/pywikibot-ci.yml 
b/.github/workflows/pywikibot-ci.yml
index a688455..8c6d951 100644
--- a/.github/workflows/pywikibot-ci.yml
+++ b/.github/workflows/pywikibot-ci.yml
@@ -10,30 +10,31 @@
   pull_request:
     branches: [ master ]

+env:
+  PYWIKIBOT_TESTS_RUNNING: 1
+
 jobs:
   build:
-
     runs-on: ubuntu-latest
-    continue-on-error: ${{ matrix.experimental }}
+    continue-on-error: ${{ matrix.experimental || false }}
+
     strategy:
       fail-fast: false
+
       matrix:
         python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "pypy3"]
         site: ["wikipedia:en", "wikisource:zh"]
-        experimental: [false]
+        test_prod_only: [true]
         include:
           - python-version: "3.7"
             site: "wikipedia:test"
-            experimental: false
           - python-version: "3.7"
             site: "wikidata:test"
-            experimental: false
           - python-version: "3.9"
             site: "wiktionary:ar"
-            experimental: false
+            test_no_rc: true
           - python-version: "3.6"
             site: "wikidata:wikidata"
-            experimental: false
           - python-version: "3.8"
             site: "wowwiki:uk"
             experimental: true
@@ -45,10 +46,12 @@
     - uses: actions/checkout@v2
       with:
         submodules: true
+
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v2
       with:
         python-version: ${{ matrix.python-version }}
+
     - name: Install dependencies
       run: |
         python -m pip install --upgrade pip
@@ -58,12 +61,19 @@
         if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
         pip install wikitextparser
         python -c "import setuptools; print('setuptools:', 
setuptools.__version__)"
+
     - name: Generate user files
       run: |
         python -Werror::UserWarning -m pwb generate_user_files 
-site:${{matrix.site}} -v -debug
         echo "max_retries = 3" >> user-config.py
         echo "maximum_GET_length = 5000" >> user-config.py
         echo "console_encoding = 'utf8'" >> user-config.py
+
     - name: Test with unittest
+      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 discover -vv -p \"*_tests.py\"
diff --git a/tests/aspects.py b/tests/aspects.py
index ef26423..dc9da6e 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -864,10 +864,11 @@
             interface = DrySite

         for data in cls.sites.values():
+            prod_only = os.environ.get('PYWIKIBOT_TEST_PROD_ONLY', '0') == '1'
             if (data.get('code') in ('test', 'mediawiki')
-                    and 'PYWIKIBOT_TEST_PROD_ONLY' in os.environ and not dry):
+                    and prod_only and not dry):
                 raise unittest.SkipTest(
-                    'Site code "{}" and PYWIKIBOT_TEST_PROD_ONLY is set.'
+                    'Site code {!r} and PYWIKIBOT_TEST_PROD_ONLY is set.'
                     .format(data['code']))

             if 'site' not in data and 'code' in data and 'family' in data:
@@ -1370,7 +1371,8 @@
     def setUpClass(cls):
         """Set up test class."""
         if os.environ.get('PYWIKIBOT_TEST_NO_RC', '0') == '1':
-            raise unittest.SkipTest('RecentChanges tests disabled.')
+            raise unittest.SkipTest(
+                'PYWIKIBOT_TEST_NO_RC is set; RecentChanges tests disabled.')

         super().setUpClass()


--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/743686
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I13143f91ae031e9698ff3c27a238f7e831278dfd
Gerrit-Change-Number: 743686
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to