Skip to content
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

ci: capture script failures properly #156

Merged
merged 3 commits into from
Jan 24, 2025

Conversation

alex-liang3
Copy link
Contributor

@alex-liang3 alex-liang3 commented Jan 23, 2025

Jobs in downstream repos which used the ostk-* helper scripts (like Check C++ Format) were not correctly raising their error codes. This is because the .sh scripts would return the exit code of the final command (popd), regardless of what commands failed earlier in the script.

We can check the exit code of the commands we're interested in, and append an || exit 1 to cause the script to return an error if the command itself failed.

For example, this job passed even though clang-format itself failed. This PR and its failing job demonstrates the effect of this change.

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Enhanced error handling in development helper scripts for C++ and Python formatting and testing.
    • Added exit conditions to prevent script continuation on command failures.
    • Improved script robustness by ensuring immediate termination on errors.
    • Updated GitHub Actions workflows to utilize a specific version of QEMU for cross-platform builds.

@alex-liang3 alex-liang3 self-assigned this Jan 23, 2025
Copy link

coderabbitai bot commented Jan 23, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces consistent error handling across several shell scripts in the development helpers directory. The changes focus on adding || exit 1 to various commands like clang-format, black, and pytest, ensuring that if these commands fail, the scripts will immediately terminate with a non-zero exit status. This modification improves script robustness by preventing further execution when critical formatting or testing steps encounter errors. Additionally, updates were made to GitHub Actions workflows to enhance the setup for cross-platform builds.

Changes

File Change Summary
tools/development/helpers/check-format-cpp.sh Added error handling for clang-format command
tools/development/helpers/check-format-python.sh Added error handling for black formatting check
tools/development/helpers/format-cpp.sh Added error handling for clang-format command
tools/development/helpers/format-python.sh Added error handling for black formatting command
tools/development/helpers/test-python.sh Added error handling for pytest command
.github/workflows/build-image.yml Added specific image for QEMU setup in workflow
.github/workflows/build-packages.yml Updated QEMU action version and specified image for ARM64 setup

Possibly related PRs

  • fix: upload artefacts with different names #148: The changes in build-packages.yml involve updates to artifact names, which may relate to the overall error handling improvements in the main PR by ensuring that artifacts are correctly identified and managed during the build process.

Suggested reviewers

  • vishwa2710
  • apaletta3

Poem

🐰 Debugging Bunny's Bash Ballet
With scripts that hop and never fail,
Error handling now sets the trail
Exit one when commands go astray
Robust and clean, we code today!
🚀 No more silent errors' sway


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba2d82f and ade9a41.

📒 Files selected for processing (7)
  • .github/workflows/build-image.yml (1 hunks)
  • .github/workflows/build-packages.yml (2 hunks)
  • tools/development/helpers/check-format-cpp.sh (1 hunks)
  • tools/development/helpers/check-format-python.sh (1 hunks)
  • tools/development/helpers/format-cpp.sh (1 hunks)
  • tools/development/helpers/format-python.sh (1 hunks)
  • tools/development/helpers/test-python.sh (1 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (5)
tools/development/helpers/format-python.sh (1)

12-12: Handle potential popd failures

Add error handling to popd to prevent silent failures if the directory stack becomes corrupted.

-popd > /dev/null
+popd > /dev/null || exit 1
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 12-12: Use 'popd ... || exit' or 'popd ... || return' in case popd fails.

(SC2164)

tools/development/helpers/check-format-python.sh (1)

12-12: Handle potential popd failures

Add error handling to popd to prevent silent failures if the directory stack becomes corrupted.

-popd > /dev/null
+popd > /dev/null || exit 1
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 12-12: Use 'popd ... || exit' or 'popd ... || return' in case popd fails.

(SC2164)

tools/development/helpers/test-python.sh (1)

13-13: Handle potential popd failures

Add error handling to popd to prevent silent failures if the directory stack becomes corrupted.

-popd > /dev/null
+popd > /dev/null || exit 1
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 13-13: Use 'popd ... || exit' or 'popd ... || return' in case popd fails.

(SC2164)

tools/development/helpers/format-cpp.sh (1)

12-12: Handle potential popd failures

Add error handling to popd to prevent silent failures if the directory stack becomes corrupted.

-popd > /dev/null
+popd > /dev/null || exit 1
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 12-12: Use 'popd ... || exit' or 'popd ... || return' in case popd fails.

(SC2164)

tools/development/helpers/check-format-cpp.sh (1)

12-12: Handle potential popd failures

Add error handling to popd to prevent silent failures if the directory stack becomes corrupted.

-popd > /dev/null
+popd > /dev/null || exit 1
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 12-12: Use 'popd ... || exit' or 'popd ... || return' in case popd fails.

(SC2164)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fda9dcd and ba2d82f.

📒 Files selected for processing (5)
  • tools/development/helpers/check-format-cpp.sh (1 hunks)
  • tools/development/helpers/check-format-python.sh (1 hunks)
  • tools/development/helpers/format-cpp.sh (1 hunks)
  • tools/development/helpers/format-python.sh (1 hunks)
  • tools/development/helpers/test-python.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
tools/development/helpers/format-python.sh

[warning] 12-12: Use 'popd ... || exit' or 'popd ... || return' in case popd fails.

(SC2164)

tools/development/helpers/check-format-python.sh

[warning] 12-12: Use 'popd ... || exit' or 'popd ... || return' in case popd fails.

(SC2164)

tools/development/helpers/test-python.sh

[error] 10-10: Double quote array expansions to avoid re-splitting elements.

(SC2068)


[warning] 13-13: Use 'popd ... || exit' or 'popd ... || return' in case popd fails.

(SC2164)

tools/development/helpers/check-format-cpp.sh

[warning] 9-9: Quote this to prevent word splitting.

(SC2046)


[warning] 12-12: Use 'popd ... || exit' or 'popd ... || return' in case popd fails.

(SC2164)

tools/development/helpers/format-cpp.sh

[warning] 9-9: Quote this to prevent word splitting.

(SC2046)


[warning] 12-12: Use 'popd ... || exit' or 'popd ... || return' in case popd fails.

(SC2164)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Push and Tag Base Image with Version / Build Development Image
🔇 Additional comments (2)
tools/development/helpers/format-python.sh (1)

9-10: LGTM: Error handling added for black command

The addition of || exit 1 ensures formatting failures are properly captured and reported.

tools/development/helpers/check-format-python.sh (1)

9-10: LGTM: Error handling added for black check command

The addition of || exit 1 ensures formatting check failures are properly captured and reported.

tools/development/helpers/test-python.sh Show resolved Hide resolved
tools/development/helpers/format-cpp.sh Show resolved Hide resolved
tools/development/helpers/check-format-cpp.sh Show resolved Hide resolved
@alex-liang3 alex-liang3 changed the title ci: capture exit code properly ci: capture script failures properly Jan 23, 2025
@vishwa2710 vishwa2710 enabled auto-merge (squash) January 23, 2025 21:32
@alex-liang3 alex-liang3 force-pushed the ci/fail-checks-properly branch from b73a22a to ade9a41 Compare January 24, 2025 13:58
@alex-liang3 alex-liang3 changed the base branch from main to ci/fix-intermittent-qemu-issues January 24, 2025 13:58
@vishwa2710 vishwa2710 merged commit 4cdb71f into ci/fix-intermittent-qemu-issues Jan 24, 2025
1 of 2 checks passed
@vishwa2710 vishwa2710 deleted the ci/fail-checks-properly branch January 24, 2025 13:58
alex-liang3 added a commit that referenced this pull request Jan 24, 2025
@alex-liang3 alex-liang3 restored the ci/fail-checks-properly branch January 24, 2025 14:03
alex-liang3 added a commit that referenced this pull request Jan 24, 2025
vishwa2710 pushed a commit that referenced this pull request Jan 24, 2025
* ci: bump qemu to v8

* ci: capture script failures properly (#156)

* ci: capture exit code properly

* chore: simplify exit

* style: fix whitespace

* Revert "ci: capture script failures properly (#156)"

This reverts commit 4cdb71f.
alex-liang3 added a commit that referenced this pull request Jan 25, 2025
* ci: capture exit code properly

* chore: simplify exit

* style: fix whitespace
alex-liang3 added a commit that referenced this pull request Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants