diff --git a/scripts/view-test-artifacts.ts b/scripts/view-test-artifacts.ts index d01d12156..f902f0886 100644 --- a/scripts/view-test-artifacts.ts +++ b/scripts/view-test-artifacts.ts @@ -111,7 +111,8 @@ const downloadSingleTestArtifact = async (tempDir: string, artifact: Required { - 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); diff --git a/shared-scripts.sh b/shared-scripts.sh index 66020b87c..647a1b1d2 100644 --- a/shared-scripts.sh +++ b/shared-scripts.sh @@ -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 }