Skip to content

rulesets: implement allowed-merge-apps#2304

Open
marcoieni wants to merge 1 commit intomainfrom
rulesets-implement-bypass-app-ids
Open

rulesets: implement allowed-merge-apps#2304
marcoieni wants to merge 1 commit intomainfrom
rulesets-implement-bypass-app-ids

Conversation

@marcoieni
Copy link
Member

Close #2198

"Frontend / Lint",
"Frontend / Test",
]
required-approvals = 0
Copy link
Member Author

@marcoieni marcoieni Mar 9, 2026

Choose a reason for hiding this comment

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

It was already present in the branch protection. See #2046

# GitHub App IDs that are allowed to bypass the branch protection rules.
# The app ID can be found via the GitHub API (GET /orgs/{org}/installations).
# (optional)
bypass-app-ids = [2201425] # workflows-crates-io
Copy link
Member Author

@marcoieni marcoieni Mar 9, 2026

Choose a reason for hiding this comment

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

for simplicity, I put directly the ID, to avoid having another rest API to call GitHub to query for the ID.
Also, this app is only used in crates-io, so I thought adding an enum between app name and ID was overengineering. We can refine this later if needed.

You can see from the screenshot of the issue linked in the PR body that this app is in the bypass list.

Copy link
Member

Choose a reason for hiding this comment

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

Tbh I would rather add the enum variant to document what are all the integrations that we care about (and hardcode the app ID in code, same as we do for bors and Renovatebot).

@marcoieni marcoieni force-pushed the rulesets-implement-bypass-app-ids branch 2 times, most recently from fa95128 to c6e6481 Compare March 9, 2026 22:50
@github-actions
Copy link

github-actions bot commented Mar 9, 2026

Dry-run check results

[WARN  sync_team] sync-team is running in dry mode, no changes will be applied.
[INFO  sync_team] synchronizing crates-io
[INFO  sync_team] synchronizing github
[INFO  sync_team] 💻 Repo Diffs:
    📝 Editing repo 'rust-lang/crates.io':
      Rulesets:
          Updating 'main'
            Include Branches: ["~DEFAULT_BRANCH"] => ["refs/heads/main"]
            Bypass Actors: None => Some([RulesetBypassActor { actor_id: 2201425, actor_type: Integration, bypass_mode: Always }])

OrganizationAdmin,
RepositoryRole,
Team,
DeployKey,
Copy link
Member Author

Choose a reason for hiding this comment

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

@marcoieni marcoieni force-pushed the rulesets-implement-bypass-app-ids branch 3 times, most recently from 39525b0 to 5bedc6d Compare March 9, 2026 23:05
crates-io = "write"

[[branch-protections]]
name = "main"
Copy link
Member Author

Choose a reason for hiding this comment

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

adding this to minimize the sync team dry run diff

@marcoieni marcoieni force-pushed the rulesets-implement-bypass-app-ids branch 2 times, most recently from 44eeeb4 to c7b6732 Compare March 9, 2026 23:10
@@ -429,6 +433,19 @@ allowed-merge-teams = ["awesome-team"]
# When "homu" is used, "bors" has to be in the `bots` array.
# (optional)
merge-bots = ["homu"]
Copy link
Member Author

Choose a reason for hiding this comment

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

@Kobzol one doubt I have: does it makes sense to have merge-bots and bypass-app-ids separated?

Copy link
Member

Choose a reason for hiding this comment

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

No, I don't think so. I would suggest merging (:laughing:) merge-bots and bypass-app-ids into allowed-merge-apps, to mirror the already existing allowed-merge-teams.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I delete merge-bots than retrocompatibility becomes a mess. I.e. I need to change all repos files 🤔
Should we do it in another PR?
Should I momentarely add this github app in "merge-bots"? and then rename it in a separate PR?

Copy link
Member

Choose a reason for hiding this comment

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

merge-bots is currently used only on rust-lang/rust and nowhere else, so I don't see why we would need to change all repo files 🤔

@marcoieni
Copy link
Member Author

marcoieni commented Mar 9, 2026

Here is the dry run diff:

Rulesets:
          Updating 'main'
            Include Branches: ["~DEFAULT_BRANCH"] => ["refs/heads/main"]
            Bypass Actors: None => Some([RulesetBypassActor { actor_id: 2201425, actor_type: Integration, bypass_mode: Always }])

updating the branch to a fixed one from the default is fine.
The bypass actors are changing, but I wonder if this is because the dry run read token doesn't have the read permission for the bypass actors.

EDIT: AI confirmed that's the case
image

@marcoieni marcoieni marked this pull request as ready for review March 9, 2026 23:28
}

// Add non-fast-forward protection if requested
if branch_protection.prevent_force_push {
Copy link
Member

Choose a reason for hiding this comment

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

This is not for this PR, but I think that those two (along with forbid creation) should be the default.

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum MergeBot {
Homu,
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed homu because it was unused.
Also I kept the "MergeBot" name here to minimize LoC changed for this PR

@marcoieni
Copy link
Member Author

Not sure why after my latest changes the dry run diff increased:


    📝 Editing repo 'rust-lang/crates.io':
      Rulesets:
          Updating 'main'
            Include Branches: ["~DEFAULT_BRANCH"] => ["refs/heads/main"]
            Bypass Actors: None => Some([RulesetBypassActor { actor_id: 2201425, actor_type: Integration, bypass_mode: Always }])
            Require code owner review: deleting `false`
            Required status checks: deleting `Backend / Lint (integration_id: 15368), Backend / Test (integration_id: 15368), Backend / dependencies (integration_id: 15368), Frontend / Lint (integration_id: 15368), Frontend / Test (integration_id: 15368)`
            Strict policy for status checks: deleting `false`
            Required approvals: deleting `0`
            Dismiss stale reviews on push: deleting `false`
            Require review thread resolution: deleting `false`
            Require last push approval: deleting `false`

@marcoieni
Copy link
Member Author

I think AI is right:
image
I'm investigating how I can fix this

[[branch-protections]]
pattern = "main"
merge-bots = ["bors"]
pr-required = false
Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to setup this field explicitly instead of inferring it via code (in case the app is bors).
But let's see the dry run.

use api::*;

let uses_merge_bot = !branch_protection.merge_bots.is_empty();
let uses_merge_bot = !branch_protection.allowed_merge_apps.is_empty();
Copy link
Member

Choose a reason for hiding this comment

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

This should be changed to check if allowed_merge_apps contains Bors (not just that it is empty). That should fix the diff.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, but I thought that having the config more explicit was better instead of this custom logic. Wdyt? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

I think that this logic is fine. The high-level config should be "bors managed this branch", and then team should do whatever is necessary to make that happen. Setting pr-required = false just exposes (just one) implementation detail of that. So I'd rather just say that bors can push to this branch, and interpret that is it being bors managed, and set the various protection options accordingly.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I'll change this

@marcoieni marcoieni force-pushed the rulesets-implement-bypass-app-ids branch from eea0ed8 to 9475511 Compare March 10, 2026 12:50
@rustbot
Copy link

rustbot commented Mar 10, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@marcoieni marcoieni changed the title rulesets: implement bypass-app-ids rulesets: implement allowed-merge-apps Mar 10, 2026
@marcoieni marcoieni force-pushed the rulesets-implement-bypass-app-ids branch from 9475511 to 7b29da4 Compare March 10, 2026 12:51
@marcoieni
Copy link
Member Author

The dry run looks good now:


    📝 Editing repo 'rust-lang/crates.io':
      Rulesets:
          Updating 'main'
            Include Branches: ["~DEFAULT_BRANCH"] => ["refs/heads/main"]
            Bypass Actors: None => Some([RulesetBypassActor { actor_id: 2201425, actor_type: Integration, bypass_mode: Always }])

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.

Configure the crates-io ruleset

3 participants