Fix: Add pipefail and error handling to compilation step
#3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Add pipefail and error handling to compilation step
Description
This PR improves error handling in the Slither workflow's compilation step by adding proper bash error handling flags and executing the compile command in a controlled subshell.
Type of Change
Related Issue
N/A - Proactive improvement for error handling
Changes Made
.github/workflows/slither.yaml:set -euo pipefailbefore executing compile commandbash -eo pipefail -c "$COMPILE_COMMAND"What changed:
Before:
After:
Why This Matters
Without proper error handling flags:
command1 | command2) wouldn't be detectedWith
set -euo pipefail:-e: Exit immediately if any command fails-u: Treat undefined variables as errors-o pipefail: Return the exit code of the last failed command in a pipelineThis ensures the workflow fails fast and clearly when compilation issues occur, rather than continuing with potentially broken artifacts.
Testing
Additional Context
This change follows shell scripting best practices and aligns with the recent shellcheck warning fixes. It ensures that compilation failures are properly detected and reported, improving the reliability and debuggability of the Slither analysis workflow.
The
bash -eo pipefail -cwrapper ensures the flags apply to the entire compile command, even if it's a complex multi-command string.