Skip to content

fix(rust.sh): remove unnecessary nightly flag from cargo doc command#879

Merged
github-actions[bot] merged 1 commit intodevelopfrom
doc-pipeline
Mar 30, 2026
Merged

fix(rust.sh): remove unnecessary nightly flag from cargo doc command#879
github-actions[bot] merged 1 commit intodevelopfrom
doc-pipeline

Conversation

@Dwlad90
Copy link
Copy Markdown
Owner

@Dwlad90 Dwlad90 commented Mar 30, 2026

  • Updated the cargo doc command in rust.sh to remove the +nightly flag, simplifying the documentation build process.
  • This change aims to enhance compatibility and streamline the documentation generation without relying on the nightly version of Cargo.

Description

Please include a summary of the changes and the related issue. Please also
include relevant motivation and context. List any dependencies that are required
for this change.

Fixes

(Optional) Fixes # (issue)

Additional Info

(Optional) Add any other relevant information about the pull request here.

Type of change

Please select options that are relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes
  • I have read the CONTRIBUTING document

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to simplify Rust documentation generation by removing the explicit nightly toolchain selector from the docs script, and it also introduces consistent “exit-on-error” and process-cleanup trap handling across several shell scripts.

Changes:

  • Remove +nightly from cargo doc invocation in the Rust docs script.
  • Add set -e and INT/TERM/EXIT trap logic to multiple scripts to improve failure handling and subprocess cleanup.
  • Add trap teardown (trap - ...) at the end of affected scripts.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
scripts/parse-args.sh Adds set -e and trap setup/teardown around argument parsing.
scripts/packages/test/index.sh Adds trap setup/teardown around Rust test detection/execution.
scripts/packages/docs/rust.sh Removes +nightly from cargo doc and adds trap teardown.
scripts/packages/build/typescript.sh Adds trap setup/teardown for TypeScript build script.
scripts/packages/build/rust.sh Adds trap setup/teardown for Rust build script.
scripts/functions.sh Adds set -e and trap setup/teardown to the shared functions library.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/parse-args.sh Outdated
Comment on lines +3 to +9
# Exit immediately when any subprocess returns a non-zero command
set -e

# Kill all subprocesses when exiting
# shellcheck disable=2154
trap 'exit $exit_code' INT TERM
trap 'exit_code=$?; kill 0' EXIT
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

parse-args.sh is sourced by other scripts (e.g. scripts/packages/build/*.sh). Adding set -e and especially installing/uninstalling INT/TERM/EXIT traps here mutates the caller shell: the final trap - INT TERM EXIT clears any traps set by the parent script, so the parent no longer has its cleanup/kill-on-exit behavior for the rest of execution. Recommend removing trap logic (and ideally set -e) from this shared, sourced helper, or refactor it into a function that returns parsed values without altering global shell options/traps.

Copilot uses AI. Check for mistakes.
Comment thread scripts/functions.sh Outdated
Comment on lines +3 to +10
# Exit immediately when any subprocess returns a non-zero command
set -e

# Kill all subprocesses when exiting
# shellcheck disable=2154
trap 'exit $exit_code' INT TERM
trap 'exit_code=$?; kill 0' EXIT

Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

This file is sourced by multiple entrypoint scripts. Setting set -e and registering traps in a sourced library changes the caller’s execution environment, and the trap - INT TERM EXIT at the end immediately removes any traps the parent script set before sourcing this file. functions.sh should avoid changing shell options/traps; keep it to function definitions, and let entrypoint scripts own set -e/trap setup.

Copilot uses AI. Check for mistakes.
export RUSTDOCFLAGS="--enable-index-page -Zunstable-options"

cargo doc +nightly --no-deps --document-private-items $verbose_flag $open_docs || handle_error "Failed to build cargo docs"
cargo doc --no-deps --document-private-items $verbose_flag $open_docs || handle_error "Failed to build cargo docs"
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

rust-toolchain.toml pins a stable toolchain, but this script still exports RUSTDOCFLAGS with -Zunstable-options (nightly-only). Removing cargo doc +nightly will make docs generation fail on stable. Either keep using the nightly toolchain for docs, or remove/guard the nightly-only -Z flags so cargo doc works on stable as intended.

Suggested change
cargo doc --no-deps --document-private-items $verbose_flag $open_docs || handle_error "Failed to build cargo docs"
cargo +nightly doc --no-deps --document-private-items $verbose_flag $open_docs || handle_error "Failed to build cargo docs"

Copilot uses AI. Check for mistakes.
Comment thread scripts/packages/build/typescript.sh Outdated
set -e

# Kill all subprocesses when exiting
# shellcheck disable=2154
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

exit_code is not initialized before being used in the INT/TERM trap. If the script is interrupted before any command fails, exit $exit_code will typically exit with the status of the last successful command (often 0), masking the interrupt. Initialize exit_code to a non-zero default (e.g. 130) or set explicit exit codes per-signal in the trap handlers.

Suggested change
# shellcheck disable=2154
# shellcheck disable=2154
exit_code=130

Copilot uses AI. Check for mistakes.
Comment thread scripts/packages/test/index.sh Outdated
Comment on lines +6 to +9
# Kill all subprocesses when exiting
# shellcheck disable=2154
trap 'exit $exit_code' INT TERM
trap 'exit_code=$?; kill 0' EXIT
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

exit_code is not initialized before being used in the INT/TERM trap. On SIGINT/SIGTERM, this can cause the script to exit 0 (status of the last successful command) instead of a non-zero signal exit code, which can incorrectly mark CI runs as successful. Initialize exit_code up front or use explicit per-signal exit codes in the trap.

Copilot uses AI. Check for mistakes.
Comment thread scripts/packages/build/rust.sh Outdated
cp "$built_path" "$dist_dir" || handle_error "Failed to copy the built file"
fi

# Remove traps to exit with 0
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The comment says “Remove traps to exit with 0”, but unsetting traps doesn’t control the exit status; it just restores default signal/exit handling. Consider rewording to reflect the actual intent (e.g. avoiding the EXIT trap cleanup on successful completion).

Suggested change
# Remove traps to exit with 0
# Clear traps to restore default signal/exit handling (avoid EXIT trap cleanup on success)

Copilot uses AI. Check for mistakes.
Comment thread scripts/parse-args.sh Outdated
# set positional arguments in their proper place
eval set -- "$PARAMS"

# Remove traps to exit with 0
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The comment says “Remove traps to exit with 0”, but unsetting traps doesn’t set/force exit status 0; it only removes the trap handlers. Consider rewording to avoid implying exit-code behavior.

Suggested change
# Remove traps to exit with 0
# Clear custom traps before normal script completion

Copilot uses AI. Check for mistakes.
Comment thread scripts/functions.sh Outdated
} No newline at end of file
}

# Remove traps to exit with 0
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The comment says “Remove traps to exit with 0”, but unsetting traps doesn’t influence the exit code; it only restores default signal/exit handling. Consider rewording to match behavior.

Suggested change
# Remove traps to exit with 0
# Remove traps and restore default signal/exit handling

Copilot uses AI. Check for mistakes.
@Dwlad90 Dwlad90 force-pushed the doc-pipeline branch 2 times, most recently from d2954d9 to a93dcff Compare March 30, 2026 20:57
- Updated the `cargo doc` command in `rust.sh` to remove the `+nightly` flag, simplifying the documentation build process.
- This change aims to enhance compatibility and streamline the documentation generation without relying on the nightly version of Cargo.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1 to 4
#!/bin/bash
set -e # Exit immediately if a command fails

# Define the patterns: #[test], test_transform(, or test!(
# We use -E for extended regex to use the OR (|) operator
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

Dropping set -e here changes failure semantics: if cargo test --lib/... fails but cargo test --doc passes, this script will exit 0 and mask the failure. Restore set -e (or explicitly check/propagate the exit code after each cargo test) to ensure test failures are not hidden.

Copilot uses AI. Check for mistakes.
Comment on lines 1 to 5
#!/usr/bin/env sh

# Exit immediately when any subprocess returns a non-zero command
set -e

script_dir="$(cd "$(dirname "$0")" && pwd)"
dist_dir="./dist"

Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The PR title/description says this is only about removing +nightly from the Rust docs build, but this PR also removes set -e / trap-based error handling in multiple unrelated scripts (e.g., build/test scripts). If this broader behavior change is intentional, the PR description should be updated (and ideally split into a separate PR) so reviewers can evaluate the risk and rationale separately.

Copilot uses AI. Check for mistakes.
@Dwlad90
Copy link
Copy Markdown
Owner Author

Dwlad90 commented Mar 30, 2026

/approve

@Dwlad90
Copy link
Copy Markdown
Owner Author

Dwlad90 commented Mar 30, 2026

/merge

@github-actions
Copy link
Copy Markdown
Contributor

Success! Fast forwarded develop to doc-pipeline!

@github-actions github-actions Bot merged commit 3282eba into develop Mar 30, 2026
26 checks passed
@github-actions github-actions Bot deleted the doc-pipeline branch March 30, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants