Skip to content

Rustify ci/integration.sh script#6817

Merged
ytmimi merged 5 commits into
rust-lang:mainfrom
GuillaumeGomez:rustify-shell
Apr 1, 2026
Merged

Rustify ci/integration.sh script#6817
ytmimi merged 5 commits into
rust-lang:mainfrom
GuillaumeGomez:rustify-shell

Conversation

@GuillaumeGomez
Copy link
Copy Markdown
Member

As discussed on zulip.

I went the easy road: didn't create a workspace for this script, so it uses the same dependencies as the main project (although it only needs std). It can be run with cargo run --bin ci-integration.

Anyway, this is very straightforward conversion, please tell me if you'd prefer things to be different in any regard.

r? @jieyouxu

@rustbot rustbot added A-CI Area: CI S-waiting-on-review Status: awaiting review from the assignee but also interested parties. labels Mar 4, 2026
Copy link
Copy Markdown
Contributor

@matthewhughes934 matthewhughes934 left a comment

Choose a reason for hiding this comment

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

All my style comments are subjective, so feel free to ignore at your discretion

View changes since this review

Comment thread ci/integration.rs Outdated
Comment thread ci/integration.rs Outdated
Comment thread ci/integration.rs
}

let output = run_command_with_output_and_env("cargo", &["test", test_args], current_dir, &env)?;
if ["build failed", "test result: FAILED."]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will we get here? If tests or builds fail I assume cargo test will exit non-zero and in that case will run_command_with_output_and_env above return an Err?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I kept the same behaviour as before: https://github.com/rust-lang/rustfmt/blob/main/ci/integration.sh#L46-L48

If the output contains one of the two strings, we return the function with 0, meaning success. Sounds super weird but that's the current behaviour.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Btw, run_command_with_output_and_env doesn't check whether or not the command exited successfully.

Copy link
Copy Markdown
Member

@jieyouxu jieyouxu Mar 10, 2026

Choose a reason for hiding this comment

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

My guess is that the intention there is to skip over crates which already fails test (if the baseline fails it could be other reasons too).

This comment was marked as resolved.

Comment thread ci/integration.rs Outdated
Comment thread ci/integration.rs Outdated
Comment thread ci/integration.rs
)?;
write_file("rustfmt_check_output", &output)?;

run_command_with_env("cargo", &["test", test_args], current_dir, &env)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't we already run cargo test at line 118?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might catch really broken --check format where it should not have modified the source in some off chance, seems okay to keep it. Can we add a comment here to say sth to that effect? I imagine we won't be the only ones with that question reading this :)

Comment thread ci/integration.rs
@GuillaumeGomez
Copy link
Copy Markdown
Member Author

Applied suggestions and fixed file creation.

Copy link
Copy Markdown
Contributor

@matthewhughes934 matthewhughes934 left a comment

Choose a reason for hiding this comment

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

I think I didn't read the original script carefully enough on my first review (I think most my confusion comes from things that script was already doing, sorry about that). So this review is more focused on changes in behaviour from the old script

(also Github isn't letting me resolve some of the conversations your answered? I don't see the button for it for some reason)

View changes since this review

Comment thread ci/integration.rs Outdated
Comment thread ci/integration.rs
Comment thread ci/integration.rs
@GuillaumeGomez
Copy link
Copy Markdown
Member Author

Updated!

Comment thread ci/integration.rs Outdated
@GuillaumeGomez
Copy link
Copy Markdown
Member Author

Applied suggestion.

Copy link
Copy Markdown
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. This broadly looks good to me, some nits.
@rustbot author

View changes since this review

INTEGRATION: ${{ matrix.integration }}
TARGET: x86_64-unknown-linux-gnu
run: ./ci/integration.sh
run: cargo run --bin ci-integration
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remark (not for this PR): I wonder if we should coalsce this and Diff Check into one crate, sth akin to citool on r-l/r. The benefit is that the tools could then share common logic easily.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's what I plan to do. But to reduce the diff, I decided to do it in multiple parts:

  1. Migrate shell scripts to rust
  2. Improve code

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Although I think I'll make one crate once I start porting the second one to not duplicate code.

Comment thread ci/integration.rs
Comment thread ci/integration.rs
}

let output = run_command_with_output_and_env("cargo", &["test", test_args], current_dir, &env)?;
if ["build failed", "test result: FAILED."]
Copy link
Copy Markdown
Member

@jieyouxu jieyouxu Mar 10, 2026

Choose a reason for hiding this comment

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

My guess is that the intention there is to skip over crates which already fails test (if the baseline fails it could be other reasons too).

Comment thread ci/integration.rs

let output =
run_command_with_output_and_env("cargo", &["fmt", "--all", "-v"], current_dir, &env)?;
println!("{}", output.output);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thought (not for this PR): we might be able to help group the logs with GHA log groups

Comment thread ci/integration.rs
)?;
write_file("rustfmt_check_output", &output)?;

run_command_with_env("cargo", &["test", test_args], current_dir, &env)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might catch really broken --check format where it should not have modified the source in some off chance, seems okay to keep it. Can we add a comment here to say sth to that effect? I imagine we won't be the only ones with that question reading this :)

Comment thread ci/integration.rs
Comment thread ci/integration.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: awaiting review from the assignee but also interested parties. labels Mar 10, 2026
@GuillaumeGomez
Copy link
Copy Markdown
Member Author

Applied suggestions, I also added comments to explain the final command as well.

Copy link
Copy Markdown
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Looks good to me with one tiny nit, thanks

View changes since this review

Comment thread Cargo.toml Outdated
Copy link
Copy Markdown
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

This looks good to me now, thanks.
cc @ytmimi maybe a vibe-check when you have time?

View changes since this review

@jieyouxu jieyouxu added pr-ready-to-merge Status: PR is largely ready for merge, waiting for secondary review / last nits S-waiting-on-review Status: awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. labels Mar 12, 2026
@GuillaumeGomez
Copy link
Copy Markdown
Member Author

It's been 3 weeks. Any news here? I'd like to continue this work with migrating the other shell script as well.

Copy link
Copy Markdown
Contributor

@ytmimi ytmimi left a comment

Choose a reason for hiding this comment

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

Gave it a once over and I think the new rust version looks good

View changes since this review

@ytmimi ytmimi merged commit f9ff702 into rust-lang:main Apr 1, 2026
26 checks passed
@rustbot rustbot added the release-notes Needs an associated changelog entry label Apr 1, 2026
@rustbot rustbot removed the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Apr 1, 2026
@ytmimi ytmimi removed the pr-ready-to-merge Status: PR is largely ready for merge, waiting for secondary review / last nits label Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: CI release-notes Needs an associated changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants