Skip to content

Commit

Permalink
fix script
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronZyLee committed Aug 7, 2023
1 parent 6fecb03 commit 3c899a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion scripts/view-test-artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ const downloadSingleTestArtifact = async (tempDir: string, artifact: Required<Te

return Promise.all(
listObjectsResponse.Contents.filter(hasKey).map(({ Key }) => {
const filePath = path.join(artifactDownloadPath, Key.split('/').pop()!);
const filePath = path.join(artifactDownloadPath, Key.split('/').slice(3).join('/'));
fs.ensureDirSync(path.dirname(filePath));
return new Promise((resolve, reject) => {
const writer = fs.createWriteStream(filePath);
s3.getObject({ Bucket, Key }).createReadStream().pipe(writer);
Expand Down
14 changes: 7 additions & 7 deletions shared-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,29 +250,29 @@ function retry {
MAX_ATTEMPTS=2
SLEEP_DURATION=5
FIRST_RUN=true
n=0
RUN_INDEX=0
FAILED_TEST_REGEX_FILE="./amplify-e2e-reports/amplify-e2e-failed-test.txt"
if [ -f $FAILED_TEST_REGEX_FILE ]; then
rm -f $FAILED_TEST_REGEX_FILE
fi
until [ $n -ge $MAX_ATTEMPTS ]
until [ $RUN_INDEX -ge $MAX_ATTEMPTS ]
do
echo "Attempting $@ with max retries $MAX_ATTEMPTS"
setAwsAccountCredentials
"$@" && break
n=$[$n+1]
RUN_INDEX="$RUN_INDEX" "$@" && break
RUN_INDEX=$[$RUN_INDEX+1]
FIRST_RUN=false
echo "Attempt $n completed."
echo "Attempt $RUN_INDEX completed."
sleep $SLEEP_DURATION
done
if [ $n -ge $MAX_ATTEMPTS ]; then
if [ $RUN_INDEX -ge $MAX_ATTEMPTS ]; then
echo "failed: ${@}" >&2
exit 1
fi

resetAwsAccountCredentials
TEST_SUITE=${TEST_SUITE:-"TestSuiteNotSet"}
echo "Attempt $n succeeded."
echo "Attempt $RUN_INDEX succeeded."
exit 0 # don't fail the step if putting the metric fails
}

Expand Down

0 comments on commit 3c899a8

Please sign in to comment.