Skip to content

Commit

Permalink
(Should fix) oppia#3789: Fix flaky test retry mechanism for Bazel CI (o…
Browse files Browse the repository at this point in the history
…ppia#3908)

* Update unit_tests.yml

* Break test to demonstrate retry in CI.

* Introduce build failure.

* Undo break.
  • Loading branch information
BenHenning authored Oct 7, 2021
1 parent a85c32c commit dd4cdca
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,19 @@ jobs:
# Attempt to build 5 times in case there are flaky builds.
# TODO(#3759): Remove this once there are no longer app test build failures.
i=0
# Disable exit-on-first-failure.
set +e
while [ $i -ne 5 ]; do
i=$(( $i+1 ))
echo "Attempt $i/5 to build test targets"
bazel build --keep_going --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- $BAZEL_TEST_TARGETS
done
# Capture the error code of the final command run (which should be a success if there isn't a real build failure).
last_error_code=$?
# Reenable exit-on-first-failure.
set -e
# Exit only if the most recent exit was a failure (by using a subshell).
(exit $last_error_code)
- name: Build Oppia Tests (without caching, or on a fork)
if: ${{ env.ENABLE_CACHING == 'false' || ((github.ref != 'refs/heads/develop' || github.event_name != 'push') && (github.event.pull_request.head.repo.full_name != 'oppia/oppia-android')) }}
Expand All @@ -248,10 +257,19 @@ jobs:
# Attempt to build 5 times in case there are flaky builds.
# TODO(#3759): Remove this once there are no longer app test build failures.
i=0
# Disable exit-on-first-failure.
set +e
while [ $i -ne 5 ]; do
i=$(( $i+1 ))
echo "Attempt $i/5 to build test targets"
bazel build --keep_going -- $BAZEL_TEST_TARGETS
done
# Capture the error code of the final command run (which should be a success if there isn't a real build failure).
last_error_code=$?
# Reenable exit-on-first-failure.
set -e
# Exit only if the most recent exit was a failure (by using a subshell).
(exit $last_error_code)
- name: Run Oppia Tests (with caching, non-fork only)
if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }}
env:
Expand Down

0 comments on commit dd4cdca

Please sign in to comment.