1
- #! /bin/bash
1
+ #! /usr/bin/env bash
2
+
2
3
# This Source Code Form is subject to the terms of the Mozilla Public
3
4
# License, v. 2.0. If a copy of the MPL was not distributed with this
4
5
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
5
6
#
6
7
# Copyright Oxide Computer Company
7
8
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
+
8
13
set -e
9
14
set -o pipefail
10
15
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
14
19
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
18
37
fi
19
38
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
21
41
: # Do nothing, the test results are already up to date
22
42
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
27
47
fi
28
48
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 "
33
54
exit 0
34
- done
55
+ done
0 commit comments