Skip to content

Respect the --ci flag in more places in bootstrap#152734

Open
Shunpoco wants to merge 2 commits intorust-lang:mainfrom
Shunpoco:cleanup-bootstrap-ci
Open

Respect the --ci flag in more places in bootstrap#152734
Shunpoco wants to merge 2 commits intorust-lang:mainfrom
Shunpoco:cleanup-bootstrap-ci

Conversation

@Shunpoco
Copy link
Contributor

@Shunpoco Shunpoco commented Feb 16, 2026

Motivation

Currently, the way of checking CI environment in bootstrap is not unified. Sometimes --ci flag is respected, but in other cases only GITHUB_ACTIONS env var is checked.

Change

This PR modifies the way of treating the flag in bootstrap. If --ci (or --ci=true) is added, bootstrap's config set ci_env as CiEnv::GithubActions. This PR also modifies some lines in bootstrap to respect the config's CiEnv instance.

Note

I haven't touched anything in tidy, because I want to raise another PR for introducing --ci flag in tidy. In the PR, I will need to change how tidy treats CI information. So currently I leave it as it is.

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc 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 16, 2026
@rust-log-analyzer

This comment has been minimized.

@Shunpoco Shunpoco force-pushed the cleanup-bootstrap-ci branch 2 times, most recently from 9cbfad4 to 3d26693 Compare February 17, 2026 00:19
@rust-log-analyzer

This comment has been minimized.

@Kobzol
Copy link
Member

Kobzol commented Feb 17, 2026

--ci is a bootstrap thing, while CiEnv is in build_helper, to be shared with multiple tools (which might have their own CLI flags or CI semantics). Let's not add any flag logic to build_helper, please.

Replacing uses of CiEnv with reading config.is_running_on_ci in bootstrap is good though.

@Shunpoco
Copy link
Contributor Author

Thanks, now I understand that bootstrap's --ci flag should not integrated into CiEnv.

But I still think it's worth to introduce Other variant into CiEnv. In order to make a tool (CiEnv user) behave closer to actual CI environment with a ci flag, CiEnv should say "this running environment is some kinds of CI env", because some functions (like get_closest_upstream_commit in src/build_helper/src/git.rs) takes a CiEnv instance as an argument, and I don't think passing CiEnv::GitHubActions when --ci=true is a good idea.
I know that my CiEnv::new(flag) is not a good function since it's tied with Bootstrap's flag. I can move the function into bootstrap's config. (So a tool will have its own constructor function for CiEnv if it has --ci flag).

What do you think about it?

@Shunpoco Shunpoco force-pushed the cleanup-bootstrap-ci branch from 3d26693 to 960683b Compare February 17, 2026 12:26
@Kobzol
Copy link
Member

Kobzol commented Feb 17, 2026

I don't think passing CiEnv::GitHubActions when --ci=true is a good idea.

Why? That's exactly what should happen, if we override the mode to --ci=true, the code should assume it is running under CI.

@Shunpoco
Copy link
Contributor Author

Shunpoco commented Feb 17, 2026

Because CiEnv has None/GithubActions variants, not None/CI variants (nor just a boolean). I was expecting that in the future we would have a new variant for another CI env (I don't think migrating CI is easy task, though). So I thought the separation between GithubActions env and Other env (in this PR, from ci flag) was meaningful.

But if you think all CI env should go to CiEnv::GithubActions, I think that's fine. your way is much simpler than what I thought (now I feel that I was thinking too much).

So can I write such a code in bootstrap config's parse_inner()?

        let ci_env = match flags_ci {
            Some(true) => CiEnv::GitHubActions,
            Some(false) => CiEnv::None,
            None => CiEnv::current(),
        };

@Kobzol
Copy link
Member

Kobzol commented Feb 17, 2026

I was expecting that in the future we would have a new variant for another CI env

It's actually the other way around - we used to have more variants there (e.g. Azure pipelines), but those were removed as they stopped being used in our CI. We don't really explicitly support any downstream usage of our CI, so we only maintain what we use upstream, and that is currently just GitHub Actions. We could turn --ci into a string option if we ever have more CI providers in the future, but for now a boolean is enough. This option is useful mostly only for bootstrap developers and bootstrap tests anyway.

So can I write such a code in bootstrap config's parse_inner()?

Yeah, sounds reasonable, because we anyway have to pass CiEnv to the git build_helper functions, so we might as well centralize its creation, rather than CiEnv::current() ad-hoc. That sounds like an improvement :)

@Kobzol
Copy link
Member

Kobzol commented Feb 17, 2026

r? kobzol

@Shunpoco
Copy link
Contributor Author

Thanks for the clarification! Now I fully understand that.

--ci flag in bootstrap is not respected in some cases. This commit modifies such inconsistencies in the tool.
@Shunpoco Shunpoco force-pushed the cleanup-bootstrap-ci branch from 960683b to 0596a08 Compare February 17, 2026 18:30
@Shunpoco Shunpoco changed the title Integrate --ci flag into CiEnv in bootstrap Modify around --ci flag in bootstrap Feb 17, 2026
@Shunpoco Shunpoco marked this pull request as ready for review February 17, 2026 20:10
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 17, 2026
@@ -1,6 +1,7 @@
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, Default)]
Copy link
Member

Choose a reason for hiding this comment

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

Default is a bit of a footgun here, and it's unclear to me that not being on CI is a good default anyway. ::current() should be used instead.

Since default seems to be unused, I think that you can just revert this change?

Copy link
Contributor Author

@Shunpoco Shunpoco Feb 17, 2026

Choose a reason for hiding this comment

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

I added Default to CiEnv because bootstrap's Config has Default (now ci_env is a member of Config).
But I just find that no one use Config::default(), so I will drop Default from both Config and CiEnv.

Update: I dropped Defaults in 7e22e90

@Kobzol Kobzol changed the title Modify around --ci flag in bootstrap Respect the --ci flag in more places in bootstrap Feb 17, 2026
@Kobzol
Copy link
Member

Kobzol commented Feb 17, 2026

Thank you, left one nit. After fixing it, you can r=me.

@bors delegate

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 17, 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.

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 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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