Skip to content

Commit

Permalink
fix(github-bot): require most rules to only work on base branch
Browse files Browse the repository at this point in the history
  • Loading branch information
thehowl committed Jan 23, 2025
1 parent b7f9f74 commit 39208f8
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions contribs/github-bot/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ func Config(gh *client.GitHub) ([]AutomaticCheck, []ManualCheck) {
auto := []AutomaticCheck{
{
Description: "Maintainers must be able to edit this pull request ([more info](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork))",
If: c.CreatedFromFork(),
Then: r.MaintainerCanModify(),
If: c.And(
c.BaseBranch("^master$"),
c.CreatedFromFork(),
),
Then: r.MaintainerCanModify(),

Check warning on line 40 in contribs/github-bot/internal/config/config.go

View check run for this annotation

Codecov / codecov/patch

contribs/github-bot/internal/config/config.go#L36-L40

Added lines #L36 - L40 were not covered by tests
},
{
Description: "Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff",
If: c.FileChanged(gh, "^docs/"),
If: c.And(
c.BaseBranch("^master$"),
c.FileChanged(gh, "^docs/"),
),

Check warning on line 47 in contribs/github-bot/internal/config/config.go

View check run for this annotation

Codecov / codecov/patch

contribs/github-bot/internal/config/config.go#L44-L47

Added lines #L44 - L47 were not covered by tests
Then: r.And(
r.Or(
r.AuthorInTeam(gh, "tech-staff"),
Expand All @@ -57,7 +63,10 @@ func Config(gh *client.GitHub) ([]AutomaticCheck, []ManualCheck) {
},
{
Description: "Pending initial approval by a review team member, or review from tech-staff",
If: c.Not(c.AuthorInTeam(gh, "tech-staff")),
If: c.And(
c.BaseBranch("^master$"),
c.Not(c.AuthorInTeam(gh, "tech-staff")),
),

Check warning on line 69 in contribs/github-bot/internal/config/config.go

View check run for this annotation

Codecov / codecov/patch

contribs/github-bot/internal/config/config.go#L66-L69

Added lines #L66 - L69 were not covered by tests
Then: r.
If(r.Or(
r.ReviewByOrgMembers(gh).WithDesiredState(utils.ReviewStateApproved),
Expand Down Expand Up @@ -91,7 +100,7 @@ func Config(gh *client.GitHub) ([]AutomaticCheck, []ManualCheck) {
{
Description: "Determine if infra needs to be updated before merging",
If: c.And(
c.BaseBranch("master"),
c.BaseBranch("^master$"),

Check warning on line 103 in contribs/github-bot/internal/config/config.go

View check run for this annotation

Codecov / codecov/patch

contribs/github-bot/internal/config/config.go#L103

Added line #L103 was not covered by tests
c.Or(
c.FileChanged(gh, `Dockerfile`),
c.FileChanged(gh, `^misc/deployments`),
Expand Down

0 comments on commit 39208f8

Please sign in to comment.