Skip to content

Introduce --ci flag in tidy#152949

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Shunpoco:tidy-ci
Mar 1, 2026
Merged

Introduce --ci flag in tidy#152949
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Shunpoco:tidy-ci

Conversation

@Shunpoco
Copy link
Contributor

@Shunpoco Shunpoco commented Feb 21, 2026

Context

Currently tidy doesn't have --ci flag. Even if bootstrap has --ci=true, it isn't passed to tidy. As a result, some parts of tidy where we need to turn on ci mode are never executed on our local.

Change

This PR introduces --ci flag in tidy, and modify CiInfo and other parts of tidy where currently use CiEnv::is_ci() for checking if the running environment is ci or not.

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Feb 21, 2026
@rust-log-analyzer

This comment has been minimized.

@Shunpoco
Copy link
Contributor Author

r? @Kobzol

This is a continuation PR from #152734 🙏

@rustbot
Copy link
Collaborator

rustbot commented Feb 22, 2026

Kobzol is not on the review rotation at the moment.
They may take a while to respond.

@Shunpoco Shunpoco marked this pull request as ready for review February 22, 2026 00:12
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 22, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 22, 2026

tidy extra checks were modified.

cc @lolbinarycat

The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging.

cc @davidtwco, @wesleywiser

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 22, 2026
ci_env: CiEnv::current(),
base_commit: None,
};
let ci_env =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering if we can merge CiInfo into TidyCtx so that TidyCtx becomes the (only) central place to distribute contexts. It also makes the code base simpler.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think it would be worth a try. I remember trying something like that? Maybe, it was a long time ago.. You can try and see if there aren't any issues with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did it in e5c12c6 and 05b0869.

Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

Thanks! Making CI mode be configurable in tidy sounds useful indeed.

View changes since this review

pub struct TidyFlags {
/// Applies style and formatting changes during a tidy run.
bless: bool,
/// CI flag which for emurating CI env.
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what the comment was supposed to say.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol, I wanted to say that this flag is for turning on CI mode even in a local environment. I will modify the words 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ee53d97

ci_env: CiEnv::current(),
base_commit: None,
};
let ci_env =
Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think it would be worth a try. I remember trying something like that? Maybe, it was a long time ago.. You can try and see if there aren't any issues with that.

let ci_env = match ci_flag {
Some(true) => CiEnv::GitHubActions,
Some(false) => CiEnv::None,
None => CiEnv::None,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
None => CiEnv::None,
None => CiEnv::current(),

Not that we would run tidy manually on CI, but it should auto detect if the flag is not passed.

Copy link
Contributor Author

@Shunpoco Shunpoco Feb 28, 2026

Choose a reason for hiding this comment

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

Thanks, I overlooked this misconfiguration. Fixed in de607cc

@Kobzol
Copy link
Member

Kobzol commented Feb 28, 2026

No need to clone TidyCtx, find_base_commit can just receive &TidyCtx by reference. After you change that, you can squash the commits using @bors squash, and r=me. Thank you!

@bors delegate

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 28, 2026

✌️ @Shunpoco, you can now approve this pull request!

If @Kobzol told you to "r=me" after making some further change, then please make that change and post @bors r=Kobzol.

@Shunpoco
Copy link
Contributor Author

@bors squash

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 28, 2026

🚧 Squashing... this can take a few minutes.

* add --ci flag in tidy

This commit introduces --ci flag in tidy because currently bootstrap can't pass its ci env information to tidy. It also modifies how CiInfo initialize its ci_env variable. tidy codes which uses CiEnv::is_ci for checking ci are now using ci_env in CiInfo.
* address review
- Fix comment
- Use Option for ci flag in order to have true/false explicitly or unspecified (implicit false)
* integrate CiInfo into TidyCtx
* remove CiInfo
* CiEnv::current() should be called when ci flag is not added
* extract base_commit() to a separate function
* use &TidyCtx instead of clone
@rust-bors

This comment was marked as duplicate.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 28, 2026

🔨 7 commits were squashed into af29989.

@Kobzol
Copy link
Member

Kobzol commented Feb 28, 2026

Thank you!

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 28, 2026

📌 Commit af29989 has been approved by Kobzol

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 28, 2026
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 1, 2026
Introduce --ci flag in tidy

## Context
Currently tidy doesn't have `--ci` flag. Even if bootstrap has --ci=true, it isn't passed to tidy. As a result, some parts of tidy where we need to turn on `ci mode` are never executed on our local.

## Change
This PR introduces --ci flag in tidy, and modify CiInfo and other parts of tidy where currently use `CiEnv::is_ci()` for checking if the running environment is ci or not.
rust-bors bot pushed a commit that referenced this pull request Mar 1, 2026
Rollup of 5 pull requests

Successful merges:

 - #152042 (Suggest async block instead of async closure when possible)
 - #152949 (Introduce --ci flag in tidy)
 - #152655 (Disable debug_assert_not_in_new_nodes for multiple threads)
 - #153209 (Clean up `QueryVTable::hash_result` into `hash_value_fn`)
 - #153229 (rustfmt: add test for field representing type builtin syntax)
rust-bors bot pushed a commit that referenced this pull request Mar 1, 2026
Rollup of 5 pull requests

Successful merges:

 - #152042 (Suggest async block instead of async closure when possible)
 - #152949 (Introduce --ci flag in tidy)
 - #152655 (Disable debug_assert_not_in_new_nodes for multiple threads)
 - #153209 (Clean up `QueryVTable::hash_result` into `hash_value_fn`)
 - #153229 (rustfmt: add test for field representing type builtin syntax)
@rust-bors rust-bors bot merged commit 1b67449 into rust-lang:main Mar 1, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 1, 2026
rust-timer added a commit that referenced this pull request Mar 1, 2026
Rollup merge of #152949 - Shunpoco:tidy-ci, r=Kobzol

Introduce --ci flag in tidy

## Context
Currently tidy doesn't have `--ci` flag. Even if bootstrap has --ci=true, it isn't passed to tidy. As a result, some parts of tidy where we need to turn on `ci mode` are never executed on our local.

## Change
This PR introduces --ci flag in tidy, and modify CiInfo and other parts of tidy where currently use `CiEnv::is_ci()` for checking if the running environment is ci or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants