Skip to content

Commit

Permalink
ci: use tools/ci.sh in Github Actions hyperledger-cacti#497
Browse files Browse the repository at this point in the history
Primary change
=============

While we were getting to know the GitHub Actions CI runner
we temporarily stopped using the tools/ci.sh script
to run the tests, but now that we are properly
familiarized with GHA and it's quirks, it is time to
go back to the good old script we've been using before migrating
over to GHA for CI.

Secondary change
================

Add retries to the tests to minimize the amount of failures
due to flake where manual intervention is needed (e.g. manually
restarting the tests after a false negative).
This will also not make the false negatives go away 100% but
the hope is that it will reduce them in numbers and therefore
make it a little less annoying for contributors who send PRs.

Fixes hyperledger-cacti#497

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Mar 30, 2021
1 parent adf0dea commit 8ea904e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,4 @@ jobs:

- uses: actions/checkout@v2.3.4

# https://stackoverflow.com/a/61789467
- run: npm config list
- run: npm config delete proxy
- run: npm config delete http-proxy
- run: npm config delete https-proxy

# https://stackoverflow.com/a/15483897
- run: npm cache verify
- run: npm cache clean --force
- run: npm cache verify

- run: npm ci
- run: ./node_modules/.bin/lerna bootstrap
- run: npm run build:dev:backend
- run: npm run test:all -- --bail
- run: ./tools/ci.sh
38 changes: 36 additions & 2 deletions tools/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,45 @@ function mainTask()
### COMMON
cd $PROJECT_ROOT_DIR

# https://stackoverflow.com/a/61789467
npm config list
npm config delete proxy
npm config delete http-proxy
npm config delete https-proxy

# https://stackoverflow.com/a/15483897
npm cache verify
npm cache clean --force
npm cache verify

npm ci
./node_modules/.bin/lerna clean --yes
./node_modules/.bin/lerna bootstrap

# The "quick" build that is enough for the tests to be runnable
npm run build:dev:backend

# Tests are still flaky (on weak hardware such as the CI env) despite our best
# efforts so here comes the mighty hammer of brute force. 3 times the charm...
{
npm run test:all -- --bail && echo "$(date +%FT%T%z) [CI] First (#1) try of tests succeeded OK."
} ||
{
echo "$(date +%FT%T%z) [CI] First (#1) try of tests failed starting second try now..."
npm run test:all -- --bail && echo "$(date +%FT%T%z) [CI] Second (#2) try of tests succeeded OK."
} ||
{
echo "$(date +%FT%T%z) [CI] Second (#2) try of tests failed starting third and last try now..."
npm run test:all -- --bail && echo "$(date +%FT%T%z) [CI] Third (#3) try of tests succeeded OK."
}

# The webpack production build needs more memory than the default allocation
export NODE_OPTIONS=--max_old_space_size=4096

# We run the full build last because the tests don't need it so in the interest
# of providing feedback about failing tests as early as possible we run the
# dev:backend build first and then the tests which is the fastest way to get
# to a failed test if there was one.
npm run build
npm run test:all

ENDED_AT=`date +%s`
runtime=$((ENDED_AT-STARTED_AT))
Expand Down

0 comments on commit 8ea904e

Please sign in to comment.