-
Notifications
You must be signed in to change notification settings - Fork 158
Optimize build_test.sh to not rereun tests on flake failure #1065
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
base: master
Are you sure you want to change the base?
Conversation
# shellcheck disable=SC2046 | ||
go test -shuffle=on ${race:-} -timeout="${TIMEOUT:-600s}" -coverprofile=coverage.out -covermode=atomic "$@" $(go list ./... | grep -v github.com/ava-labs/coreth/tests) | tee test.out || command_status=$? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's possible to write this line so it both
A. works
B. passes lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about separating creation of the array from its use?
mapfile -t pkgs < <(go list ./... | grep -v github.com/ava-labs/coreth/tests)
go test -shuffle=on "${race:-}" -timeout="${TIMEOUT:-600s}" -coverprofile=coverage.out -covermode=atomic "$@" "${pkgs[@]}" | tee test.\
out || command_status=$?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If only! Writing this script was actually quite difficult because while bash is a decent programming language (imo). mapfile
was added in Bash 4.0 and all supported macOS releases (including the ones behind GitHub Actions’ macos‑latest runner) still ship with Bash 3.2.x—currently 3.2.57—because Apple never adopted the GPL v3‑licensed Bash 4+ and instead moved its interactive shell to zsh while leaving /bin/bash frozen at 3.2.57
(see https://jmmv.dev/2019/11/macos-bash-baggage.html)
Thus all of our testing scripts need to be compatible with bash circa 2014, and I was hindered from using a lot of newer bash features that would have made this easier to write.
If you endorse it, I can refactor the whole testing script to use Python (or GoLang) instead of bash but it would be a much more significant change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no obligation to be compatible with macos's ancient bash version. In avalanchego, we explicitly require a modern bash. One way to ensure the use of modern bash could be to run the command with scripts/dev_shell.sh
, since the nix shell guarantees a compatible bash version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! That's definitely something that is worth bringing over to the evm repositories in my opinion.
Why did you decide to write this in bash? The complexity involved would really benefit from a real programming language (i.e. golang). |
Not really any particular reason besides sticking with the current structure (order remains the same, |
I'm not going to block merge of this - that's up to the coreth maintainers - so these comments are more food for thought when considering future changes.
|
Why this should be merged
Currently, if a single test fails, the entire test-suite is reran (up to 4 possible times). This is extremely inefficient as if a flaky test fails, the test suite will rerun, but then maybe a different flaky test fails, so the whole test-suite is rerun, etc. This leads to long time waiting for CI jobs to pass in GitHub, which is a large waste of time.
The prior claim that re-running all prior tests was necessary is copied below:
However, there may not be an unexpected failure that causes subsequent tests not to run -- if a single flaky test fails there is no need to rerun the whole test-suite. Additionally, even if there is a panic that causes subsequent tests not to run, there's still no reason to re-run the whole test-suite -- just the tests that failed, and the tests that never ran.
How this works
go test -json -shuffle=on
for structured outputHow this was tested
This modifies the test framework directly.
Need to be documented?
No
Need to update RELEASES.md?
No