Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1287996?usp=email )

Change subject: [tests] Add SOCKS proxy support to several GutHub actions tests
......................................................................

[tests] Add SOCKS proxy support to several GutHub actions tests

Also
- remove printing public IP of runner
- remove experimental attributes of beta tests

Bug: T426484
Change-Id: I88a080451d08a925edf86ea6f5eea6edcd9064dc
---
M .github/workflows/doctest.yml
M .github/workflows/graalpy_tests.yml
M .github/workflows/login_tests-ci.yml
M .github/workflows/oauth_tests-ci.yml
M .github/workflows/pywikibot-ci.yml
M .github/workflows/windows_tests.yml
6 files changed, 113 insertions(+), 23 deletions(-)

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




diff --git a/.github/workflows/doctest.yml b/.github/workflows/doctest.yml
index 0b93f55..2ecac32 100644
--- a/.github/workflows/doctest.yml
+++ b/.github/workflows/doctest.yml
@@ -52,6 +52,32 @@
           pip install "pytest >= 9.0.3"
           pip install requests-sse
           pip install wikitextparser
+          pip install requests[socks]
+      - name: Configure and start WMCS SOCKS tunnel
+        env:
+          USER: ${{ secrets.WMCS_USER }}
+        run: |
+          mkdir -p ~/.ssh
+          printf "%s" "${{ secrets.WMCS_SSH_KEY }}" > ~/.ssh/id_ed25519
+          chmod 600 ~/.ssh/id_ed25519
+          ssh-keygen -lf ~/.ssh/id_ed25519
+          ssh-keyscan bastion.wmcloud.org >> ~/.ssh/known_hosts
+          ssh \
+            -o StrictHostKeyChecking=accept-new \
+            -o ExitOnForwardFailure=yes \
+            -o ServerAliveInterval=30 \
+            -o ServerAliveCountMax=3 \
+            -o ConnectTimeout=10 \
+            -f -N \
+            -D 127.0.0.1:1080 \
+            -i ~/.ssh/id_ed25519 \
+            "[email protected]"
+          echo "Socket connection:"
+          ss -lntp | grep 1080 || true
+          echo "Local IP:"
+          curl -s https://api.ipify.org
+          echo "Proxy IP:"
+          curl --proxy socks5h://127.0.0.1:1080 -s https://api.ipify.org
       - name: Generate user files
         run: |
           python -Werror::UserWarning -m pwb generate_user_files 
-site:wikipedia:test -user:${{ env.PYWIKIBOT_USERNAME }} -v -debug;
@@ -59,6 +85,14 @@
         id: ci_test
         continue-on-error: true
         timeout-minutes: 5
+        env:
+          PYWIKIBOT_TEST_NO_RC: ${{ (matrix.site == 'wikisource:zh' || 
matrix.test_no_rc) && 1 || 0 }}
+          # Force GIL "off" due to mwparserfromhell issue as suggested by 
warning in T412624
+          PYTHON_GIL: ${{ endsWith(matrix.python-version, 't') && '0' || '1' }}
+          HTTP_PROXY: socks5h://127.0.0.1:1080
+          HTTPS_PROXY: socks5h://127.0.0.1:1080
+          ALL_PROXY: socks5h://127.0.0.1:1080
+          NO_PROXY: ""
         run: |
           python pwb.py version
           pytest --version
@@ -73,4 +107,5 @@
           CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
       - name: Check on failure
         if: steps.ci_test.outcome == 'failure'
-        run: exit 1
+        run: |-
+          exit 1
diff --git a/.github/workflows/graalpy_tests.yml 
b/.github/workflows/graalpy_tests.yml
index d6095a8..e0d0672 100644
--- a/.github/workflows/graalpy_tests.yml
+++ b/.github/workflows/graalpy_tests.yml
@@ -77,6 +77,4 @@
       - name: Check on failure
         if: steps.ci_test.outcome == 'failure'
         run: |-
-          # Print public IP of runner
-          curl -s https://api.ipify.org
           exit 1
diff --git a/.github/workflows/login_tests-ci.yml 
b/.github/workflows/login_tests-ci.yml
index 32a2f20..e15a828 100644
--- a/.github/workflows/login_tests-ci.yml
+++ b/.github/workflows/login_tests-ci.yml
@@ -58,16 +58,13 @@
             family: wpbeta
             code: en
             os: ubuntu-22.04
-            experimental: true
           - python-version: '3.9'
             site: false
             family: wpbeta
             code: zh
             os: ubuntu-22.04
-            experimental: true
           - python-version: '3.10'
             site: wikisource:beta
-            experimental: true
           - python-version: '3.9'
             site: wikidata:test
             os: ubuntu-22.04
@@ -78,7 +75,7 @@
             os: ubuntu-22.04
           - python-version: '3.10'
             site: wowwiki:uk
-          - python-version: 3
+          - python-version: '3'
             site: wikipedia:de
             os: macOS-latest
     steps:
@@ -100,7 +97,38 @@
           pip install mwparserfromhell
           pip install packaging
           pip install requests
+          pip install requests[socks]
+      - name: Configure and start WMCS SOCKS tunnel
+        env:
+          USER: ${{ secrets.WMCS_USER }}
+        run: |
+          mkdir -p ~/.ssh
+          printf "%s" "${{ secrets.WMCS_SSH_KEY }}" > ~/.ssh/id_ed25519
+          chmod 600 ~/.ssh/id_ed25519
+          ssh-keygen -lf ~/.ssh/id_ed25519
+          ssh-keyscan bastion.wmcloud.org >> ~/.ssh/known_hosts
+          ssh \
+            -o StrictHostKeyChecking=accept-new \
+            -o ExitOnForwardFailure=yes \
+            -o ServerAliveInterval=30 \
+            -o ServerAliveCountMax=3 \
+            -o ConnectTimeout=10 \
+            -f -N \
+            -D 127.0.0.1:1080 \
+            -i ~/.ssh/id_ed25519 \
+            "[email protected]"
+          echo "Socket connection:"
+          ss -lntp | grep 1080 || true
+          echo "Local IP:"
+          curl -s https://api.ipify.org
+          echo "Proxy IP:"
+          curl --proxy socks5h://127.0.0.1:1080 -s https://api.ipify.org
       - name: Generate family files
+        env:
+          HTTP_PROXY: socks5h://127.0.0.1:1080
+          HTTPS_PROXY: socks5h://127.0.0.1:1080
+          ALL_PROXY: socks5h://127.0.0.1:1080
+          NO_PROXY: ""
         run: |
           if  [ ${{matrix.family || 0}} == wpbeta ]; then
             python pwb.py generate_family_file 
http://${{matrix.code}}.wikipedia.beta.wmcloud.org/ wpbeta y
@@ -128,6 +156,11 @@
         id: ci_test
         continue-on-error: true
         timeout-minutes: 2
+        env:
+          HTTP_PROXY: socks5h://127.0.0.1:1080
+          HTTPS_PROXY: socks5h://127.0.0.1:1080
+          ALL_PROXY: socks5h://127.0.0.1:1080
+          NO_PROXY: ""
         run: |
           python pwb.py version
           coverage run -m unittest -vv tests/site_login_logout_tests.py
@@ -141,4 +174,5 @@
           CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
       - name: Check on failure
         if: steps.ci_test.outcome == 'failure'
-        run: exit 1
+        run: |-
+          exit 1
diff --git a/.github/workflows/oauth_tests-ci.yml 
b/.github/workflows/oauth_tests-ci.yml
index e4b421f..550c38a 100644
--- a/.github/workflows/oauth_tests-ci.yml
+++ b/.github/workflows/oauth_tests-ci.yml
@@ -40,12 +40,10 @@
             family: wpbeta
             code: en
             domain: en.wikipedia.beta.wmcloud.org
-            experimental: true
           - python-version: '3.9'
             family: wpbeta
             code: zh
             domain: zh.wikipedia.beta.wmcloud.org
-            experimental: true
     steps:
       - name: Checkout Repository
         uses: actions/checkout@v6
@@ -82,8 +80,39 @@
           pip install mwoauth
           pip install packaging
           pip install requests
+          pip install requests[socks]
+      - name: Configure and start WMCS SOCKS tunnel
+        env:
+          USER: ${{ secrets.WMCS_USER }}
+        run: |
+          mkdir -p ~/.ssh
+          printf "%s" "${{ secrets.WMCS_SSH_KEY }}" > ~/.ssh/id_ed25519
+          chmod 600 ~/.ssh/id_ed25519
+          ssh-keygen -lf ~/.ssh/id_ed25519
+          ssh-keyscan bastion.wmcloud.org >> ~/.ssh/known_hosts
+          ssh \
+            -o StrictHostKeyChecking=accept-new \
+            -o ExitOnForwardFailure=yes \
+            -o ServerAliveInterval=30 \
+            -o ServerAliveCountMax=3 \
+            -o ConnectTimeout=10 \
+            -f -N \
+            -D 127.0.0.1:1080 \
+            -i ~/.ssh/id_ed25519 \
+            "[email protected]"
+          echo "Socket connection:"
+          ss -lntp | grep 1080 || true
+          echo "Local IP:"
+          curl -s https://api.ipify.org
+          echo "Proxy IP:"
+          curl --proxy socks5h://127.0.0.1:1080 -s https://api.ipify.org
       - name: Generate family files
         if: ${{ matrix.family == 'wpbeta' }}
+        env:
+          HTTP_PROXY: socks5h://127.0.0.1:1080
+          HTTPS_PROXY: socks5h://127.0.0.1:1080
+          ALL_PROXY: socks5h://127.0.0.1:1080
+          NO_PROXY: ""
         run: |
           python pwb.py generate_family_file 
http://${{matrix.code}}.wikipedia.beta.wmcloud.org/ wpbeta y
       - name: Generate user files
@@ -117,6 +146,10 @@
           PYWIKIBOT_TEST_WRITE: 1
           PYWIKIBOT_TEST_OAUTH: ${{ secrets[format('{0}', 
steps.token.outputs.uppercase)] }}
           PYWIKIBOT_TEST_MODULES: edit_failure,file,oauth,superset
+          HTTP_PROXY: socks5h://127.0.0.1:1080
+          HTTPS_PROXY: socks5h://127.0.0.1:1080
+          ALL_PROXY: socks5h://127.0.0.1:1080
+          NO_PROXY: ""
         run: |
           python pwb.py version
           coverage run -m unittest -vv
@@ -130,4 +163,5 @@
           CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
       - name: Check on failure
         if: steps.ci_test.outcome == 'failure'
-        run: exit 1
+        run: |-
+          exit 1
diff --git a/.github/workflows/pywikibot-ci.yml 
b/.github/workflows/pywikibot-ci.yml
index 3c108dd..a323b59 100644
--- a/.github/workflows/pywikibot-ci.yml
+++ b/.github/workflows/pywikibot-ci.yml
@@ -42,15 +42,12 @@
             site: false
             family: wpbeta
             code: en
-            experimental: true
           - python-version: '3.9'
             site: false
             family: wpbeta
             code: zh
-            experimental: true
           - python-version: '3.10'
             site: wikisource:beta
-            experimental: true
           - python-version: '3.9'
             site: wikidata:test
           - python-version: '3.11'
@@ -123,16 +120,12 @@
             -D 127.0.0.1:1080 \
             -i ~/.ssh/id_ed25519 \
             "[email protected]"
-          echo
-          echo "Socket connection"
+          echo "Socket connection:"
           ss -lntp | grep 1080 || true
-          echo
           echo "Local IP:"
           curl -s https://api.ipify.org
-          echo
           echo "Proxy IP:"
           curl --proxy socks5h://127.0.0.1:1080 -s https://api.ipify.org
-          echo
       - name: Generate family files
         env:
           HTTP_PROXY: socks5h://127.0.0.1:1080
@@ -195,6 +188,4 @@
       - name: Check on failure
         if: steps.ci_test.outcome == 'failure'
         run: |-
-          # Print public IP of runner
-          curl -s https://api.ipify.org
           exit 1
diff --git a/.github/workflows/windows_tests.yml 
b/.github/workflows/windows_tests.yml
index 1858a45..8d5bef1 100644
--- a/.github/workflows/windows_tests.yml
+++ b/.github/workflows/windows_tests.yml
@@ -85,6 +85,4 @@
       - name: Check on failure
         if: steps.ci_test.outcome == 'failure'
         run: |-
-          # Print public IP of runner
-          curl -s https://api.ipify.org
           exit 1

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

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

Reply via email to