Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1295539?usp=email )
Change subject: GH tests: refactor workflows to use WMCS SOCKS tunnel composite action ......................................................................
GH tests: refactor workflows to use WMCS SOCKS tunnel composite action
Start with doctest.yml
Change-Id: I9a981ab3f18224345643a5c0981d6c5cfa507735 --- A .github/actions/wmcs-socks/action.yml M .github/workflows/doctest.yml 2 files changed, 61 insertions(+), 25 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/.github/actions/wmcs-socks/action.yml b/.github/actions/wmcs-socks/action.yml new file mode 100644 index 0000000..f78cd38 --- /dev/null +++ b/.github/actions/wmcs-socks/action.yml @@ -0,0 +1,57 @@ +--- +name: WMCS SOCKS Tunnel +description: Configure and start WMCS SOCKS proxy tunnel + +inputs: + ssh_user: + description: SSH user for bastion + required: true + ssh_key: + description: Private SSH key + required: true + +runs: + using: composite + steps: + - name: Setup SSH directory + shell: bash + run: | + set -euo pipefail + mkdir -p ~/.ssh + - name: Install SSH key + shell: bash + run: | + set -euo pipefail + printf "%s" "${{ inputs.ssh_key }}" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + - name: Add known hosts + shell: bash + run: | + set -euo pipefail + ssh-keyscan bastion.wmcloud.org >> ~/.ssh/known_hosts + - name: Start SOCKS tunnel + shell: bash + run: | + set -euo pipefail + ssh \ + -o StrictHostKeyChecking=accept-new \ + -o ExitOnForwardFailure=yes \ + -o ServerAliveInterval=30 \ + -o ServerAliveCountMax=3 \ + -o ConnectTimeout=10 \ + -N \ + -D 127.0.0.1:1080 \ + -i ~/.ssh/id_ed25519 \ + "${{ inputs.ssh_user }}@bastion.wmcloud.org" & + echo $! > ssh.pid + echo "SSH tunnel started with PID $(cat ssh.pid)" + - name: Show proxy connection + shell: bash + run: |- + set -euo pipefail + 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 diff --git a/.github/workflows/doctest.yml b/.github/workflows/doctest.yml index d166173..0b53b10 100644 --- a/.github/workflows/doctest.yml +++ b/.github/workflows/doctest.yml @@ -58,31 +58,10 @@ pip install wikitextparser pip install requests[socks] - name: Configure and start WMCS SOCKS tunnel - shell: bash - 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 \ - "$USER@bastion.wmcloud.org" - echo "Socket connection:" - 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 + uses: ./.github/actions/wmcs-socks + with: + ssh_user: ${{ secrets.WMCS_USER }} + ssh_key: ${{ secrets.WMCS_SSH_KEY }} - name: Generate user files run: | python -Werror::UserWarning -m pwb generate_user_files -site:wikipedia:test -user:${{ env.PYWIKIBOT_USERNAME }} -v -debug;
pywikibot-commits@lists.wikimedia.org