Skip to content

Commit b9ca211

Browse files
authored
ci: add timeout to test step (#50206)
ci: add timeout to test step (#50186) Additionally, take a screenshot on timeout so that we can debug why there is a hang
1 parent 2396024 commit b9ca211

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/pipeline-segment-electron-test.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ jobs:
209209
210210
- name: Run Electron Tests
211211
shell: bash
212+
timeout-minutes: 40
212213
env:
213214
MOCHA_REPORTER: mocha-multi-reporters
214215
MOCHA_MULTI_REPORTERS: mocha-junit-reporter, tap
@@ -259,6 +260,19 @@ jobs:
259260
260261
fi
261262
fi
263+
- name: Take screenshot on timeout or cancellation
264+
if: ${{ inputs.target-platform != 'linux' && (cancelled() || failure()) }}
265+
shell: bash
266+
run: |
267+
screenshot_dir="src/electron/spec/artifacts"
268+
mkdir -p "$screenshot_dir"
269+
screenshot_file="$screenshot_dir/screenshot-timeout-$(date +%Y%m%d%H%M%S).png"
270+
if [ "${{ inputs.target-platform }}" = "macos" ]; then
271+
screencapture -x "$screenshot_file" || true
272+
elif [ "${{ inputs.target-platform }}" = "win" ]; then
273+
powershell -command "Add-Type -AssemblyName System.Windows.Forms; \$screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds; \$bitmap = New-Object System.Drawing.Bitmap(\$screen.Width, \$screen.Height); \$graphics = [System.Drawing.Graphics]::FromImage(\$bitmap); \$graphics.CopyFromScreen(\$screen.Location, [System.Drawing.Point]::Empty, \$screen.Size); \$bitmap.Save('$screenshot_file')" || true
274+
fi
275+
262276
- name: Upload Test results to Datadog
263277
env:
264278
DD_ENV: ci
@@ -274,7 +288,7 @@ jobs:
274288
fi
275289
if: always() && !cancelled()
276290
- name: Upload Test Artifacts
277-
if: always() && !cancelled()
291+
if: always()
278292
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
279293
with:
280294
name: test_artifacts_${{ env.ARTIFACT_KEY }}_${{ matrix.shard }}

0 commit comments

Comments
 (0)