Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminate workflow processes after completing tests #131

Merged
merged 16 commits into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,44 @@ jobs:
timeout-minutes: 45
run: npx cypress run

- name: stop linux services
if: runner.os == 'Linux'
run: fuser -k 3000/tcp && fuser -k 8001/tcp

- name: stop windows services
if: runner.os == 'Windows'
run: |
$ports = @(3000, 8001)
foreach ($port in $ports){
$netTCPConnections = Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue
if ($netTCPConnections) {
foreach ($netTCPConnection in $netTCPConnections) {
$processId = $netTCPConnection.OwningProcess
Write-Host "Found ID $processId"
$process = Get-Process -Id $processId -ErrorAction SilentlyContinue
if ($process) {
Write-Host "Found valid process $process"
if ($process.Name -notcontains "Idle") {
try {
Write-Host "Attempting to kill ID $processId with name $process.Name."
Stop-Process -Id $process.Id -Force
Write-Host "Process with ID $processId on port $port killed."
} catch {
Write-Host "Failed to kill process with ID $processId - $_"
}
} else {
Write-Host "The process using port $port is the idle process and cannot be terminated."
}
} else {
Write-Host "No process found using port $port."
}
}
} else {
Write-Host "No TCP connection found on port $port."
}
}
shell: pwsh

- name: Upload artifact for screenshots & videos
uses: actions/upload-artifact@v4
if: always()
Expand Down