Skip to content

Commit

Permalink
Replace yarn with npm
Browse files Browse the repository at this point in the history
  • Loading branch information
zxl629 committed Dec 27, 2024
1 parent 34da228 commit 4da782f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/callable-local-e2e-webpack-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ jobs:
E2E_ENV: ${{ '{}' }}
run: |
if [ -z “” ]; then
../amplify-data/scripts/retry-yarn-script.sh -s \
../amplify-data/scripts/retry-npm-script.sh -s \
"ci:test-webpack \
webpack \
webpack \
chrome \
dev \
cli \
--env $(echo $E2E_ENV | jq -r 'tostring')" \
-n 3
else
echo "Skipping specialized yarn script execution in the dev environment."
fi
Expand Down
50 changes: 50 additions & 0 deletions scripts/retry-npm-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# flags:
# -s = script name
# -n = how many times to retry
# -r (optional) = run git reset in between retries

# usage example:
# ./retry-command.sh -s lint -n 5
# ./retry-command.sh -s publish:local -n 3 -r true

while getopts s:n:r: option
do
case "${option}"
in
s) SCRIPT=${OPTARG};;
n) N=${OPTARG};;
r) GIT_RESET=${OPTARG};;
esac
done

# initialize counter
n=0
# loop until n > first param
until [ "$n" -gt $N ]
do
# $1 is the argument passed in, e.g. publish:local
# if the publish command succeeds, `break` exits the loop
npm run $SCRIPT && break

if [[ $GIT_RESET ]]
then
# reset git HEAD (remove the package.json changes made by lerna)
echo "Resetting git HEAD"
git reset --hard
fi

if [ "$n" -eq $N ];
then
echo "Returning error"
exit 1
fi

# increment counter
n=$((n+1))

# wait 5 seconds
sleep 5
echo "Retry $n of $N"
done

0 comments on commit 4da782f

Please sign in to comment.