Skip to content

Run integration tests in retry loop #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- node_modules
- run:
name: Test
command: npm run test
command: ./.circleci/test.sh
- run:
name: Coverage
command: npm run coverage
Expand Down
34 changes: 34 additions & 0 deletions .circleci/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# override CircleCi's default run settings,
# so that we run all tests and do not exit early
# on test failures.
set +e
set +o pipefail

EXIT_STATE=0
MAX_AUTO_RETRY=5

# inspired by https://unix.stackexchange.com/a/82602
retry () {
local n=0

until [ $n -ge $MAX_AUTO_RETRY ]; do
"$@" && break
n=$[$n+1]
echo ''
echo run $n of $MAX_AUTO_RETRY failed, trying again ...
echo ''
sleep 15
done

if [ $n -eq $MAX_AUTO_RETRY ]; then
EXIT_STATE=1
fi
}

npm run pretest
npm run test:lint || EXIT_STATE=$?
npm run test:unit || EXIT_STATE=$?
retry npm run test:integration
exit $EXIT_STATE