This repository was archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·53 lines (43 loc) · 1.72 KB
/
run.sh
File metadata and controls
executable file
·53 lines (43 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
cd ~
export DISPLAY=:10
export PATH=$PATH:/usr/bin:/usr/local/bin
curl "http://metadata/computeMetadata/v1/instance/attributes/" -H "Metadata-Flavor: Google" > metadata_keys
while read key; do
export $key=$(curl "http://metadata/computeMetadata/v1/instance/attributes/$key" -H "Metadata-Flavor: Google")
done < metadata_keys
read -a targets <<< $(echo $E2E_TARGETS)
for targetUrl in "${targets[@]}"
do
TARGET_DIR=$(echo $targetUrl|awk 'BEGIN { FS = "/" } ; { print $5 }' | awk 'BEGIN { FS = "." } ; { print $1}')
if [ ! -d "$TARGET_DIR" ]; then
git clone $targetUrl;
fi
cd $TARGET_DIR;
git checkout master;
git fetch origin;
MERGERESULT=$(git merge origin/master -X theirs -m "merge");
if [ -f E2E_OUTFILE ]; then
exit 0
fi
PASSFAIL=--FAIL--
if npm run e2e >E2E_OUTFILE 2>&1; then
PASSFAIL=pass
fi
cd ~
echo -n $(date) >> $TARGET_DIR.log
echo -n " " >> $TARGET_DIR.log
echo $PASSFAIL >> $TARGET_DIR.log
if [ $PASSFAIL == "--FAIL--" ]; then
mv $TARGET_DIR/E2E_OUTFILE "$TARGET_DIR/E2E_ERROR_$(date)" || true
mv $TARGET_DIR/uncaught-exception.png "$TARGET_DIR/uncaught-exception-$(date).png" || true
if [ $(tail -n 3 $TARGET_DIR.log |grep FAIL |wc -l) = 3 ]; then
TOKEN=$(curl -s "http://metadata/computeMetadata/v1/instance/service-accounts/default/token?alt=text" \
-H "Metadata-Flavor: Google" |grep access_token |awk '{print $2}')
curl -X POST -H "Content-Length: 0" -H "Authorization: Bearer $TOKEN" \
"http://logger-dot-rvaserver2.appspot.com/queue?task=submit&logger_version=1&token=scenario-runner&environment=prod&severity=alert&error_message=e2e-scenario-failed&error_details=$TARGET_DIR"
fi
else
rm $TARGET_DIR/E2E_OUTFILE
fi
done