.github: Enable with-ssh for Windows (#63440)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63440

Signed-off-by: Eli Uriegas <eliuriegas@fb.com>

Test Plan: Imported from OSS

Reviewed By: janeyx99

Differential Revision: D30521460

Pulled By: seemethere

fbshipit-source-id: e987e170e73fb4f9d9f024bed0e58404ed206848
This commit is contained in:
Eli Uriegas
2021-08-24 14:13:04 -07:00
committed by Facebook GitHub Bot
parent 4e37a015c7
commit 865d127a66
7 changed files with 172 additions and 0 deletions

View File

@ -0,0 +1,11 @@
function Get-SSH-Sessions {
Get-Process sshd -IncludeUserName |
Where-Object UserName -notLike "*SYSTEM*" |
Select-Object Id
}
$runningSessions = Get-SSH-Sessions
foreach ($session in $runningSessions) {
Stop-Process -id $session.Id
}

View File

@ -0,0 +1,17 @@
function Get-SSH-Users {
# Gets ssh sessions for all users not named SYSTEM
Get-CimInstance -ClassName Win32_Process -Filter "Name = 'sshd.exe'" |
Get-CimAssociatedInstance -Association Win32_SessionProcess |
Get-CimAssociatedInstance -Association Win32_LoggedOnUser |
Where-Object {$_.Name -ne 'SYSTEM'} |
Measure-Object
}
$usersLoggedOn = Get-SSH-Users
Write-Output "Holding runner until all ssh sessions have logged out"
while ($usersLoggedOn.Count -gt 0) {
$usersLoggedOn = Get-SSH-Users
Write-Output "."
Start-Sleep -s 5
}

View File

@ -4,6 +4,20 @@
{# squid_no_proxy is a list of common set of fixed domains or IPs that we don't need to proxy. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/http_proxy_config.html#windows-proxy #}
{%- set squid_no_proxy = "localhost,127.0.0.1,amazonaws.com,s3.amazonaws.com,169.254.169.254,169.254.170.2,/var/run/docker.sock" -%}
{%- macro wait_and_kill_ssh() -%}
- name: Wait until all sessions have drained
shell: powershell
if: always()
timeout-minutes: 120
run: |
.github\scripts\wait_for_ssh_to_drain.ps1
- name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
shell: powershell
if: always()
run: |
.github\scripts\kill_active_ssh_sessions.ps1
{%- endmacro -%}
# Template is at: .github/templates/windows_ci_workflow.yml.j2
# Generation script: .github/scripts/generate_ci_workflows.py
name: !{{ build_environment }}
@ -76,6 +90,10 @@ jobs:
http_proxy: "!{{ squid_proxy }}"
https_proxy: "!{{ squid_proxy }}"
steps:
- name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
uses: seemethere/add-github-ssh-key@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
@ -123,6 +141,7 @@ jobs:
if-no-files-found: error
name: ${{ env.BUILD_ENVIRONMENT }}
path: C:\${{ github.run_id }}\build-results
!{{ wait_and_kill_ssh() }}
- name: Cleanup build-results and workspaces
if: always()
shell: bash
@ -193,6 +212,10 @@ jobs:
# deep clone, to allow use of git merge-base
fetch-depth: 0
!{{ common.display_ec2_information() }}
- name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
uses: seemethere/add-github-ssh-key@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Visual Studio 2019 toolchain
shell: powershell
run: |
@ -251,6 +274,7 @@ jobs:
if-no-files-found: error
path:
pytorch-${{ github.run_id }}/test-reports-*.zip
!{{ wait_and_kill_ssh() }}
- name: Cleanup workspace
if: always()
shell: bash

View File

@ -51,6 +51,10 @@ jobs:
http_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
https_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
steps:
- name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
uses: seemethere/add-github-ssh-key@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
@ -99,6 +103,17 @@ jobs:
if-no-files-found: error
name: ${{ env.BUILD_ENVIRONMENT }}
path: C:\${{ github.run_id }}\build-results
- name: Wait until all sessions have drained
shell: powershell
if: always()
timeout-minutes: 120
run: |
.github\scripts\wait_for_ssh_to_drain.ps1
- name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
shell: powershell
if: always()
run: |
.github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup build-results and workspaces
if: always()
shell: bash
@ -163,6 +178,10 @@ jobs:
shell: bash
run: |
.github/scripts/display_ec2_information.sh
- name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
uses: seemethere/add-github-ssh-key@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Visual Studio 2019 toolchain
shell: powershell
run: |
@ -219,6 +238,17 @@ jobs:
if-no-files-found: error
path:
pytorch-${{ github.run_id }}/test-reports-*.zip
- name: Wait until all sessions have drained
shell: powershell
if: always()
timeout-minutes: 120
run: |
.github\scripts\wait_for_ssh_to_drain.ps1
- name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
shell: powershell
if: always()
run: |
.github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup workspace
if: always()
shell: bash

View File

@ -51,6 +51,10 @@ jobs:
http_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
https_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
steps:
- name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
uses: seemethere/add-github-ssh-key@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
@ -91,6 +95,17 @@ jobs:
if-no-files-found: error
name: ${{ env.BUILD_ENVIRONMENT }}
path: C:\${{ github.run_id }}\build-results
- name: Wait until all sessions have drained
shell: powershell
if: always()
timeout-minutes: 120
run: |
.github\scripts\wait_for_ssh_to_drain.ps1
- name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
shell: powershell
if: always()
run: |
.github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup build-results and workspaces
if: always()
shell: bash
@ -155,6 +170,10 @@ jobs:
shell: bash
run: |
.github/scripts/display_ec2_information.sh
- name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
uses: seemethere/add-github-ssh-key@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Visual Studio 2019 toolchain
shell: powershell
run: |
@ -203,6 +222,17 @@ jobs:
if-no-files-found: error
path:
pytorch-${{ github.run_id }}/test-reports-*.zip
- name: Wait until all sessions have drained
shell: powershell
if: always()
timeout-minutes: 120
run: |
.github\scripts\wait_for_ssh_to_drain.ps1
- name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
shell: powershell
if: always()
run: |
.github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup workspace
if: always()
shell: bash

View File

@ -53,6 +53,10 @@ jobs:
http_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
https_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
steps:
- name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
uses: seemethere/add-github-ssh-key@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
@ -101,6 +105,17 @@ jobs:
if-no-files-found: error
name: ${{ env.BUILD_ENVIRONMENT }}
path: C:\${{ github.run_id }}\build-results
- name: Wait until all sessions have drained
shell: powershell
if: always()
timeout-minutes: 120
run: |
.github\scripts\wait_for_ssh_to_drain.ps1
- name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
shell: powershell
if: always()
run: |
.github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup build-results and workspaces
if: always()
shell: bash
@ -165,6 +180,10 @@ jobs:
shell: bash
run: |
.github/scripts/display_ec2_information.sh
- name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
uses: seemethere/add-github-ssh-key@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Visual Studio 2019 toolchain
shell: powershell
run: |
@ -221,6 +240,17 @@ jobs:
if-no-files-found: error
path:
pytorch-${{ github.run_id }}/test-reports-*.zip
- name: Wait until all sessions have drained
shell: powershell
if: always()
timeout-minutes: 120
run: |
.github\scripts\wait_for_ssh_to_drain.ps1
- name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
shell: powershell
if: always()
run: |
.github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup workspace
if: always()
shell: bash

View File

@ -53,6 +53,10 @@ jobs:
http_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
https_proxy: "http://internal-tf-lb-20210727220640487900000002-835786077.us-east-1.elb.amazonaws.com:3128"
steps:
- name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
uses: seemethere/add-github-ssh-key@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PyTorch
uses: actions/checkout@v2
with:
@ -101,6 +105,17 @@ jobs:
if-no-files-found: error
name: ${{ env.BUILD_ENVIRONMENT }}
path: C:\${{ github.run_id }}\build-results
- name: Wait until all sessions have drained
shell: powershell
if: always()
timeout-minutes: 120
run: |
.github\scripts\wait_for_ssh_to_drain.ps1
- name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
shell: powershell
if: always()
run: |
.github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup build-results and workspaces
if: always()
shell: bash
@ -165,6 +180,10 @@ jobs:
shell: bash
run: |
.github/scripts/display_ec2_information.sh
- name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
uses: seemethere/add-github-ssh-key@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Visual Studio 2019 toolchain
shell: powershell
run: |
@ -221,6 +240,17 @@ jobs:
if-no-files-found: error
path:
pytorch-${{ github.run_id }}/test-reports-*.zip
- name: Wait until all sessions have drained
shell: powershell
if: always()
timeout-minutes: 120
run: |
.github\scripts\wait_for_ssh_to_drain.ps1
- name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
shell: powershell
if: always()
run: |
.github\scripts\kill_active_ssh_sessions.ps1
- name: Cleanup workspace
if: always()
shell: bash