Skip to content

adding slack notification to channel if it loops for more than 5 mins #1091

adding slack notification to channel if it loops for more than 5 mins

adding slack notification to channel if it loops for more than 5 mins #1091

Workflow file for this run

name: CI
on:
pull_request:
jobs:
CI:
name: "CI"
runs-on: Windows
timeout-minutes: 60
steps:
- name: Check out the GM-TestFramework repo
uses: actions/checkout@v4
with:
path: GM-TF
# - name: Wait for 10 Minutes
# run: Start-Sleep -Seconds 300
# shell: pwsh
- run: .\setup.bat
working-directory: GM-TF
shell: cmd
- name: Testing on PR
run: |
$startTime = Get-Date
$timeoutMinutes = 5
$maxTime = $startTime.AddMinutes($timeoutMinutes)
Write-Host "Starting build..."
run_ci.bat ${{ github.workspace }}/../../configs/${{ github.event.inputs.CONFIG_FILE }} ${{ github.event.inputs.RSS_Feed }} ${{ github.event.inputs.EXTRA_PARAMS }}
# Monitor process for looping
while ($true) {
if ((Get-Date) -gt $maxTime) {
# If looping exceeds 5 minutes, send a Slack notification and exit
$slackPayload = @{
text = "Build is stuck in a loop for more than 5 minutes. Exiting process."
} | ConvertTo-Json -Depth 10
Invoke-RestMethod -Uri "${{ secrets.SLACK_WEBHOOK_URL }}" -Method POST -ContentType "application/json" -Body $slackPayload
throw "Test Framework Build exceeded the 5-minute timeout and was terminated."
}
Start-Sleep -Seconds 10 # Check every 10 seconds
}
working-directory: GM-TF
shell: pwsh
- name: Upload Results Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: summary_file
path: ${{ github.workspace }}\GM-TF\results