Skip to content

Conversation

@amustaque97
Copy link
Contributor

@amustaque97 amustaque97 commented Dec 2, 2025

Closes: #2132
Extends environment configuration to support specifying deployment branch restrictions, allowing teams to control which branches can deploy to each environment via a new field in the TOML schema.

@amustaque97 amustaque97 marked this pull request as ready for review December 2, 2025 18:48
@rustbot
Copy link

rustbot commented Dec 2, 2025

rust_team_data/src/v1.rs has been modified, it is used (as a git dependency) by multiple sub-projects like triagebot, the www.rust-lang.org website and others.

If you are changing the data structures, please make sure that the changes are not going to break serde deserialization (adding a field is fine; removing or renaming a field isn't).

If you must do a breaking change to the format, make sure to coordinate it with all the users of the rust_team_data crate.

cc @Urgau

[[environments]]
name = "github-pages"
[environments.github-pages]
branches = []
Copy link
Member

Choose a reason for hiding this comment

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

Just to avoid a common default case, if the branches array is empty, I'd remove it from the current files, and keep the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Copilot AI review requested due to automatic review settings December 3, 2025 05:14
Copilot finished reviewing on behalf of amustaque97 December 3, 2025 05:18
Copy link

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 pull request adds support for deployment branch restrictions to repository environment configurations. It transforms the environment schema from a simple list of environment names to a map structure that can specify which branches are allowed to deploy to each environment.

Key changes:

  • Schema migration from array-of-tables [[environments]] to table-of-tables [environments.{name}] with optional branches field
  • New EnvironmentDiff::Update variant to handle changes to existing environment branch policies
  • Implementation of GitHub API integration for managing deployment branch policies via separate API endpoints

Reviewed changes

Copilot reviewed 112 out of 112 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/schema.rs Changed environments from Vec<Environment> to HashMap<String, Environment> and replaced name field with branches: Vec<String>
rust_team_data/src/v1.rs Updated public API schema to use IndexMap<String, Environment> with branches field
src/validate.rs Updated validation to check environment names as HashMap keys and validate branch names are non-empty
src/static_api.rs Updated static API generation to sort and collect environments from HashMap into IndexMap
src/main.rs Updated environment listing to display branch restrictions when present
sync-team/src/github/mod.rs Added Update variant to EnvironmentDiff and updated diff logic to detect branch policy changes
sync-team/src/github/api/write.rs Added update_environment, get_environment_branch_policies, set_environment_branch_policies, and delete_environment_branch_policy methods
sync-team/src/github/api/read.rs Changed repo_environments return type to HashMap<String, Environment>
sync-team/src/github/tests/test_utils.rs Updated test utilities to use HashMap-based environments and added environment_with_branches helper
sync-team/src/github/tests/mod.rs Updated test cases to use new environment structure
tests/static-api/_expected/v1/repos/*.json Updated expected JSON output to use object {} instead of array [] for environments
repos/rust-lang/*.toml Migrated all repository TOML files from [[environments]] to [environments.{name}] syntax
repos/rust-lang/bors.toml Example of environment with branch restrictions: branches = ["main"]
docs/toml-schema.md Updated documentation with new table-of-tables syntax and branch restrictions examples

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

Comment on lines +1121 to +1126
EnvironmentDiff::Update(name, branches) => {
writeln!(f, " 🔄 Update: {name}")?;
if !branches.is_empty() {
writeln!(f, " Branches: {}", branches.join(", "))?;
}
}
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

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

The display output for EnvironmentDiff::Update doesn't clearly communicate when branch restrictions are being removed. When updating an environment from having branch restrictions to having none (empty branches list), the output only shows "🔄 Update: {name}" without indicating that restrictions are being cleared.

Suggested improvement:

EnvironmentDiff::Update(name, branches) => {
    writeln!(f, "    🔄 Update: {name}")?;
    if branches.is_empty() {
        writeln!(f, "        Remove branch restrictions")?;
    } else {
        writeln!(f, "        Branches: {}", branches.join(", "))?;
    }
}

This makes it clearer to users what configuration change is being applied.

Copilot uses AI. Check for mistakes.
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.

Allow configuring deployment branches in environments

3 participants