-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: fixes bot workflow and comment update (#3229)
This PR should (normally) fix the issues with the bot on this repo. In addition to the fixes, I also replaced the old config with a config that has much simpler rules while we decide what to add later on, once we've verified that everything is working properly. Here is the current config, If nothing seems off to you, we can merge it as it is then improve it incrementaly. ```go auto := []automaticCheck{ { description: "Maintainers must be able to edit this pull request", ifC: c.Always(), thenR: r.MaintainerCanModify(), }, { description: "The pull request head branch must be up-to-date with its base", ifC: c.Always(), thenR: r.UpToDateWith(gh, r.PR_BASE), }, { description: "Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff", ifC: c.FileChanged(gh, "^docs/"), thenR: r.Or( r.And( r.AuthorInTeam(gh, "devrels"), r.ReviewByTeamMembers(gh, "tech-staff", 1), ), r.And( r.AuthorInTeam(gh, "tech-staff"), r.ReviewByTeamMembers(gh, "devrels", 1), ), ), }, } manual := []manualCheck{ { description: "The pull request description provides enough details", ifC: c.Not(c.AuthorInTeam(gh, "core-contributors")), teams: Teams{"core-contributors"}, }, { description: "Determine if infra needs to be updated before merging", ifC: c.And( c.BaseBranch("master"), c.Or( c.FileChanged(gh, `Dockerfile`), c.FileChanged(gh, `^misc/deployments`), c.FileChanged(gh, `^misc/docker-`), c.FileChanged(gh, `^.github/workflows/releaser.*\.yml$`), c.FileChanged(gh, `^.github/workflows/portal-loop\.yml$`), ), ), teams: Teams{"devops"}, }, } ``` <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests </details>
- Loading branch information
Showing
15 changed files
with
126 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package conditions | ||
|
||
import ( | ||
"github.com/gnolang/gno/contribs/github-bot/internal/utils" | ||
|
||
"github.com/google/go-github/v64/github" | ||
"github.com/xlab/treeprint" | ||
) | ||
|
||
// Draft Condition. | ||
type draft struct{} | ||
|
||
var _ Condition = &baseBranch{} | ||
|
||
func (*draft) IsMet(pr *github.PullRequest, details treeprint.Tree) bool { | ||
return utils.AddStatusNode(pr.GetDraft(), "This pull request is a draft", details) | ||
} | ||
|
||
func Draft() Condition { | ||
return &draft{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package conditions | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/gnolang/gno/contribs/github-bot/internal/utils" | ||
"github.com/google/go-github/v64/github" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/xlab/treeprint" | ||
) | ||
|
||
func TestDraft(t *testing.T) { | ||
t.Parallel() | ||
|
||
for _, testCase := range []struct { | ||
name string | ||
isMet bool | ||
}{ | ||
{"draft is true", true}, | ||
{"draft is false", false}, | ||
} { | ||
t.Run(testCase.name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
pr := &github.PullRequest{Draft: &testCase.isMet} | ||
details := treeprint.New() | ||
condition := Draft() | ||
|
||
assert.Equal(t, condition.IsMet(pr, details), testCase.isMet, fmt.Sprintf("condition should have a met status: %t", testCase.isMet)) | ||
assert.True(t, utils.TestLastNodeStatus(t, testCase.isMet, details), fmt.Sprintf("condition details should have a status: %t", testCase.isMet)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters