Skip to content

Commit

Permalink
Merge pull request #131 from MichaelPesce/improve-test-efficiency
Browse files Browse the repository at this point in the history
Terminate workflow processes after completing tests
  • Loading branch information
MichaelPesce authored Aug 1, 2024
2 parents 70678be + 5ba9a0c commit fdeafc6
Showing 1 changed file with 38 additions and 0 deletions.
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

0 comments on commit fdeafc6

Please sign in to comment.