Skip to content

Commit f5245ab

Browse files
authored
Fix e2e CI failure debug script (#2104)
* induce failure for testing, tweak script * finish fixing the script, remove test failure * add commit arg
1 parent e2a7bcd commit f5245ab

File tree

2 files changed

+39
-17
lines changed

2 files changed

+39
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
.DS_Store
2626
Thumbs.db
2727
test-results/
28+
ci-e2e-traces/
2829
playwright-report/
2930
.vercel

tools/debug-ci-e2e-fail.sh

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,55 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
23
# This Source Code Form is subject to the terms of the Mozilla Public
34
# License, v. 2.0. If a copy of the MPL was not distributed with this
45
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
56
#
67
# Copyright Oxide Computer Company
78

9+
# Run this script on a branch to download the E2E failure traces from the
10+
# latest run on that branch. Pass a commit (full hash, not abbreviated)
11+
# to pull the traces for that commit.
12+
813
set -e
914
set -o pipefail
1015

11-
# Get the ID of the last github actions run if there was one
12-
BRANCH=$(git rev-parse --abbrev-ref HEAD)
13-
RUN_ID=$(gh run list -b "$BRANCH" -w CI -L 1 --json databaseId --jq '.[0].databaseId')
16+
DIR="ci-e2e-traces"
17+
18+
COMMIT=$1
1419

15-
if [ -z "$RUN_ID" ]; then
16-
echo "No action runs found for this branch"
17-
exit 0
20+
# Get the ID of the last github actions run if there was one. If a commit
21+
# is specified, use that, otherwise
22+
if [ -n "$COMMIT" ]; then
23+
echo -e "Looking at latest run on commit $COMMIT"
24+
RUN_ID=$(gh run list --commit "$COMMIT" -w CI -L 1 --json databaseId --jq '.[0].databaseId')
25+
if [ -z "$RUN_ID" ]; then
26+
echo "No action runs found. Make sure to use full commit SHA."
27+
exit 0
28+
fi
29+
else
30+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
31+
echo -e "Looking at latest run on branch $BRANCH"
32+
RUN_ID=$(gh run list -b "$BRANCH" -w CI -L 1 --json databaseId --jq '.[0].databaseId')
33+
if [ -z "$RUN_ID" ]; then
34+
echo "No action runs found"
35+
exit 0
36+
fi
1837
fi
1938

20-
if [ -d "test-results" ] && [ -f "test-results/.run" ] && [ "$RUN_ID" == "$(cat test-results/.run)" ]; then
39+
40+
if [ -e "$DIR/.run" ] && [ "$RUN_ID" == "$(cat $DIR/.run)" ]; then
2141
: # Do nothing, the test results are already up to date
2242
else
23-
rm -rf test-results
24-
echo "Attempting to download test failure traces for current branch..."
25-
gh run download $RUN_ID
26-
echo $RUN_ID > test-results/.run
43+
rm -rf $DIR
44+
echo "Downloading traces..."
45+
gh run download $RUN_ID --dir $DIR
46+
echo $RUN_ID > $DIR/.run
2747
fi
2848

29-
30-
echo "Choose a test trace to view"
31-
select test in $(ls test-results); do
32-
npx playwright show-trace test-results/$test/trace.zip
49+
# gnarly select and re-find is to take filepath noise out of the select list
50+
echo "Choose a trace to view"
51+
select trace in $(find $DIR -name "trace.zip" | sed 's/.*\/\(.*\)\/trace.zip/\1/'); do
52+
selected_trace=$(find $DIR -path "*/$trace"/trace.zip)
53+
npx playwright show-trace "$selected_trace"
3354
exit 0
34-
done
55+
done

0 commit comments

Comments
 (0)