From c0336c7a82470133dd0f243be6c6ed1ba125f0fb Mon Sep 17 00:00:00 2001 From: Patrick Maslana Date: Wed, 29 May 2024 15:28:05 -0700 Subject: [PATCH 1/9] Perform the check for users listed in the labelskipmap when building the list of community PRs --- internal/config/config.go | 2 +- internal/github/{pullRequests.go => communityPRs.go} | 2 +- internal/label/pullrequests.go | 5 +---- k8s/label-prs.yml.j2 | 3 --- k8s/notify-stale-pending-prs.yml.j2 | 3 +++ 5 files changed, 6 insertions(+), 9 deletions(-) rename internal/github/{pullRequests.go => communityPRs.go} (96%) diff --git a/internal/config/config.go b/internal/config/config.go index e02608b..8b361f8 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,13 +14,13 @@ type LabelConfig struct { LabelExternal string `yaml:"label_external"` LabelCheckRepos []CheckRepo `yaml:"label_check_repos"` LabelSkipUsers []string `yaml:"label_skip_users"` - LabelSkipMap map[string]bool } // CheckRepo is config settings when checking a repo type CheckRepo struct { Name string `yaml:"name"` MinimumNumber int `yaml:"minimum_number"` + LabelSkipMap map[string]bool } // CheckStalePending are config settings when checking a repo diff --git a/internal/github/pullRequests.go b/internal/github/communityPRs.go similarity index 96% rename from internal/github/pullRequests.go rename to internal/github/communityPRs.go index 313faa2..0896677 100644 --- a/internal/github/pullRequests.go +++ b/internal/github/communityPRs.go @@ -46,7 +46,7 @@ func FindCommunityPRs(repos []config.CheckRepo, teamMembers map[string]bool, git continue } user := *pullRequest.User.Login - if !teamMembers[user] { + if !teamMembers[user] || !fullRepo.LabelSkipMap[user] { finalPRs = append(finalPRs, pullRequest) } } diff --git a/internal/label/pullrequests.go b/internal/label/pullrequests.go index 25e159e..6a12412 100644 --- a/internal/label/pullrequests.go +++ b/internal/label/pullrequests.go @@ -25,16 +25,13 @@ func PullRequests(githubClient *github.Client, internalTeam string, cfg config.L for _, pullRequest := range pullRequests { user := *pullRequest.User.Login - if cfg.LabelSkipMap[user] { - continue - } + var label string if teamMembers[user] { label = cfg.LabelInternal } else { label = cfg.LabelExternal } - if label != "" { log.Printf("Pull Request %d by %s will be labeled %s\n", *pullRequest.Number, user, label) hasLabel := false diff --git a/k8s/label-prs.yml.j2 b/k8s/label-prs.yml.j2 index bef6d15..b8100b6 100644 --- a/k8s/label-prs.yml.j2 +++ b/k8s/label-prs.yml.j2 @@ -26,6 +26,3 @@ secretFile: minimum_number: 533 - name: "Chia-Network/chialisp-web" minimum_number: 263 - label_skip_users: - - "dependabot[bot]" - - "github-actions[bot]" diff --git a/k8s/notify-stale-pending-prs.yml.j2 b/k8s/notify-stale-pending-prs.yml.j2 index 10d84db..34212b4 100644 --- a/k8s/notify-stale-pending-prs.yml.j2 +++ b/k8s/notify-stale-pending-prs.yml.j2 @@ -21,3 +21,6 @@ secretFile: minimum_number: 17788 - name: "Chia-Network/chia-blockchain-gui" minimum_number: 2300 + label_skip_users: + - "dependabot[bot]" + - "github-actions[bot]" From da8eed530690ae9ede6aac15304329f8586b7944 Mon Sep 17 00:00:00 2001 From: Patrick Maslana Date: Wed, 29 May 2024 15:50:05 -0700 Subject: [PATCH 2/9] Add back the label_skip_users --- k8s/label-prs.yml.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/k8s/label-prs.yml.j2 b/k8s/label-prs.yml.j2 index b8100b6..bef6d15 100644 --- a/k8s/label-prs.yml.j2 +++ b/k8s/label-prs.yml.j2 @@ -26,3 +26,6 @@ secretFile: minimum_number: 533 - name: "Chia-Network/chialisp-web" minimum_number: 263 + label_skip_users: + - "dependabot[bot]" + - "github-actions[bot]" From 0a53a8851b817ee6e719201b3e0774ab6ab2acdf Mon Sep 17 00:00:00 2001 From: Patrick Maslana Date: Wed, 29 May 2024 15:54:20 -0700 Subject: [PATCH 3/9] Fix an issue with loading the config --- internal/config/config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/config/config.go b/internal/config/config.go index 8b361f8..2ee47c6 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -6,6 +6,7 @@ type Config struct { InternalTeam string `yaml:"internal_team"` LabelConfig `yaml:",inline"` CheckStalePending `yaml:",inline"` + CheckRepo `yaml:",inline"` } // LabelConfig is the configuration options specific to labeling PRs From e56fbf91c133b13652a8567333c94bae7df71283 Mon Sep 17 00:00:00 2001 From: Patrick Maslana Date: Wed, 29 May 2024 17:25:56 -0700 Subject: [PATCH 4/9] Remove label from LabelSKipUsers and LabelSkipMap. --- internal/config/config.go | 8 ++++---- internal/config/load.go | 6 +++--- internal/github/communityPRs.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 2ee47c6..02c762f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,14 +14,14 @@ type LabelConfig struct { LabelInternal string `yaml:"label_internal"` LabelExternal string `yaml:"label_external"` LabelCheckRepos []CheckRepo `yaml:"label_check_repos"` - LabelSkipUsers []string `yaml:"label_skip_users"` } // CheckRepo is config settings when checking a repo type CheckRepo struct { - Name string `yaml:"name"` - MinimumNumber int `yaml:"minimum_number"` - LabelSkipMap map[string]bool + Name string `yaml:"name"` + MinimumNumber int `yaml:"minimum_number"` + SkipUsers []string `yaml:"label_skip_users"` + SkipUsersMap map[string]bool } // CheckStalePending are config settings when checking a repo diff --git a/internal/config/load.go b/internal/config/load.go index d8d3a1c..4c52e1f 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -20,9 +20,9 @@ func LoadConfig(path string) (*Config, error) { return nil, err } - config.LabelSkipMap = map[string]bool{} - for _, user := range config.LabelSkipUsers { - config.LabelSkipMap[user] = true + config.SkipUsersMap = map[string]bool{} + for _, user := range config.SkipUsers { + config.SkipUsersMap[user] = true } return config, nil diff --git a/internal/github/communityPRs.go b/internal/github/communityPRs.go index 0896677..2490c20 100644 --- a/internal/github/communityPRs.go +++ b/internal/github/communityPRs.go @@ -46,7 +46,7 @@ func FindCommunityPRs(repos []config.CheckRepo, teamMembers map[string]bool, git continue } user := *pullRequest.User.Login - if !teamMembers[user] || !fullRepo.LabelSkipMap[user] { + if !teamMembers[user] || !fullRepo.SkipMap[user] { finalPRs = append(finalPRs, pullRequest) } } From c6bd9322b0df065d0920bb15742957d805101420 Mon Sep 17 00:00:00 2001 From: Patrick Maslana Date: Wed, 29 May 2024 17:32:47 -0700 Subject: [PATCH 5/9] Fix a typo --- internal/github/communityPRs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/github/communityPRs.go b/internal/github/communityPRs.go index 2490c20..5de4cad 100644 --- a/internal/github/communityPRs.go +++ b/internal/github/communityPRs.go @@ -46,7 +46,7 @@ func FindCommunityPRs(repos []config.CheckRepo, teamMembers map[string]bool, git continue } user := *pullRequest.User.Login - if !teamMembers[user] || !fullRepo.SkipMap[user] { + if !teamMembers[user] || !fullRepo.SkipUsersMap[user] { finalPRs = append(finalPRs, pullRequest) } } From 8a93102247f17454c279e876c2afd3e56c3e854a Mon Sep 17 00:00:00 2001 From: Patrick Maslana Date: Fri, 31 May 2024 12:59:40 -0700 Subject: [PATCH 6/9] Fix issues with the structs and split out the pending-stale prs to their own pods --- .github/workflows/build-deploy.yml | 3 ++- cmd/labelPRs.go | 2 +- cmd/notifyPendingCI.go | 2 +- cmd/notifyStale.go | 2 +- internal/config/config.go | 27 +++++++------------ internal/github/checkPendingCI.go | 6 ++--- internal/github/checkStalePRs.go | 4 +-- internal/github/communityPRs.go | 6 ++--- internal/label/pullrequests.go | 6 ++--- k8s/label-prs.yml.j2 | 4 +-- k8s/notify-pending-prs.yaml.j2 | 25 +++++++++++++++++ ...ing-prs.yml.j2 => notify-stale-prs.yml.j2} | 1 - 12 files changed, 53 insertions(+), 35 deletions(-) create mode 100644 k8s/notify-pending-prs.yaml.j2 rename k8s/{notify-stale-pending-prs.yml.j2 => notify-stale-prs.yml.j2} (97%) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 9bfa6bc..a84c218 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -29,7 +29,8 @@ jobs: matrix: mode: - name: label-prs - - name: notify-stale-pending-prs + - name: notify-pending-prs + - name: notify-stale-prs steps: - uses: actions/checkout@v4 diff --git a/cmd/labelPRs.go b/cmd/labelPRs.go index 15ce856..29e21a4 100644 --- a/cmd/labelPRs.go +++ b/cmd/labelPRs.go @@ -27,7 +27,7 @@ var labelPRsCmd = &cobra.Command{ loopDuration := viper.GetDuration("loop-time") for { log.Println("Labeling Pull Requests") - err = label.PullRequests(client, cfg.InternalTeam, cfg.LabelConfig) + err = label.PullRequests(client, cfg.InternalTeam, cfg) if err != nil { log.Fatalln(err.Error()) } diff --git a/cmd/notifyPendingCI.go b/cmd/notifyPendingCI.go index 8f8eceb..84b7572 100644 --- a/cmd/notifyPendingCI.go +++ b/cmd/notifyPendingCI.go @@ -27,7 +27,7 @@ var notifyPendingCICmd = &cobra.Command{ var listPendingPRs []string for { log.Println("Checking for community PRs that are waiting for CI to run") - listPendingPRs, err = github2.CheckForPendingCI(client, cfg.InternalTeam, cfg.CheckStalePending) + listPendingPRs, err = github2.CheckForPendingCI(client, cfg.InternalTeam, cfg) if err != nil { log.Printf("The following error occurred while obtaining a list of pending PRs: %s", err) time.Sleep(loopDuration) diff --git a/cmd/notifyStale.go b/cmd/notifyStale.go index 10a66bb..06a779c 100644 --- a/cmd/notifyStale.go +++ b/cmd/notifyStale.go @@ -27,7 +27,7 @@ var notifyStaleCmd = &cobra.Command{ var listPendingPRs []string for { log.Println("Checking for community PRs that have no update in the last 7 days") - _, err = github2.CheckStalePRs(client, cfg.InternalTeam, cfg.CheckStalePending) + _, err = github2.CheckStalePRs(client, cfg.InternalTeam, cfg) if err != nil { log.Printf("The following error occurred while obtaining a list of stale PRs: %s", err) time.Sleep(loopDuration) diff --git a/internal/config/config.go b/internal/config/config.go index 02c762f..81b755a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -2,29 +2,22 @@ package config // Config defines the config for all aspects of the bot type Config struct { - GithubToken string `yaml:"github_token"` - InternalTeam string `yaml:"internal_team"` - LabelConfig `yaml:",inline"` - CheckStalePending `yaml:",inline"` - CheckRepo `yaml:",inline"` + GithubToken string `yaml:"github_token"` + InternalTeam string `yaml:"internal_team"` + SkipUsers []string `yaml:"skip_users"` + SkipUsersMap map[string]bool + LabelConfig `yaml:",inline"` + CheckRepos []CheckRepo `yaml:"check_repos"` } // LabelConfig is the configuration options specific to labeling PRs type LabelConfig struct { - LabelInternal string `yaml:"label_internal"` - LabelExternal string `yaml:"label_external"` - LabelCheckRepos []CheckRepo `yaml:"label_check_repos"` + LabelInternal string `yaml:"label_internal"` + LabelExternal string `yaml:"label_external"` } // CheckRepo is config settings when checking a repo type CheckRepo struct { - Name string `yaml:"name"` - MinimumNumber int `yaml:"minimum_number"` - SkipUsers []string `yaml:"label_skip_users"` - SkipUsersMap map[string]bool -} - -// CheckStalePending are config settings when checking a repo -type CheckStalePending struct { - CheckStalePending []CheckRepo `yaml:"check_stale_pending_repos"` + Name string `yaml:"name"` + MinimumNumber int `yaml:"minimum_number"` } diff --git a/internal/github/checkPendingCI.go b/internal/github/checkPendingCI.go index 0bb4376..3d21433 100644 --- a/internal/github/checkPendingCI.go +++ b/internal/github/checkPendingCI.go @@ -14,11 +14,11 @@ import ( ) // CheckForPendingCI returns a list of PR URLs that are ready for CI to run but haven't started yet. -func CheckForPendingCI(githubClient *github.Client, internalTeam string, cfg config.CheckStalePending) ([]string, error) { +func CheckForPendingCI(githubClient *github.Client, internalTeam string, repos *config.Config) ([]string, error) { teamMembers, _ := GetTeamMemberList(githubClient, internalTeam) var pendingPRs []string - for _, fullRepo := range cfg.CheckStalePending { + for _, fullRepo := range repos.CheckRepos { log.Println("Checking repository:", fullRepo.Name) parts := strings.Split(fullRepo.Name, "/") if len(parts) != 2 { @@ -28,7 +28,7 @@ func CheckForPendingCI(githubClient *github.Client, internalTeam string, cfg con owner, repo := parts[0], parts[1] // Fetch community PRs using the FindCommunityPRs function - communityPRs, err := FindCommunityPRs(cfg.CheckStalePending, teamMembers, githubClient) + communityPRs, err := FindCommunityPRs(repos, teamMembers, githubClient) if err != nil { return nil, err } diff --git a/internal/github/checkStalePRs.go b/internal/github/checkStalePRs.go index 7a2f729..aeab26a 100644 --- a/internal/github/checkStalePRs.go +++ b/internal/github/checkStalePRs.go @@ -12,14 +12,14 @@ import ( ) // CheckStalePRs will return a list of PR URLs that have not been updated in the last 7 days by internal team members. -func CheckStalePRs(githubClient *github.Client, internalTeam string, cfg config.CheckStalePending) ([]string, error) { +func CheckStalePRs(githubClient *github.Client, internalTeam string, cfg *config.Config) ([]string, error) { var stalePRUrls []string cutoffDate := time.Now().Add(7 * 24 * time.Hour) // 7 days ago teamMembers, err := GetTeamMemberList(githubClient, internalTeam) if err != nil { return nil, err } - communityPRs, err := FindCommunityPRs(cfg.CheckStalePending, teamMembers, githubClient) + communityPRs, err := FindCommunityPRs(cfg, teamMembers, githubClient) if err != nil { return nil, err } diff --git a/internal/github/communityPRs.go b/internal/github/communityPRs.go index 5de4cad..b8b6979 100644 --- a/internal/github/communityPRs.go +++ b/internal/github/communityPRs.go @@ -12,7 +12,7 @@ import ( ) // FindCommunityPRs obtains PRs based on provided filters -func FindCommunityPRs(repos []config.CheckRepo, teamMembers map[string]bool, githubClient *github.Client) ([]*github.PullRequest, error) { +func FindCommunityPRs(cfg *config.Config, teamMembers map[string]bool, githubClient *github.Client) ([]*github.PullRequest, error) { var finalPRs []*github.PullRequest opts := &github.PullRequestListOptions{ State: "open", @@ -24,7 +24,7 @@ func FindCommunityPRs(repos []config.CheckRepo, teamMembers map[string]bool, git }, } - for _, fullRepo := range repos { + for _, fullRepo := range cfg.CheckRepos { log.Println("Checking repository:", fullRepo.Name) parts := strings.Split(fullRepo.Name, "/") if len(parts) != 2 { @@ -46,7 +46,7 @@ func FindCommunityPRs(repos []config.CheckRepo, teamMembers map[string]bool, git continue } user := *pullRequest.User.Login - if !teamMembers[user] || !fullRepo.SkipUsersMap[user] { + if !teamMembers[user] || !cfg.SkipUsersMap[user] { finalPRs = append(finalPRs, pullRequest) } } diff --git a/internal/label/pullrequests.go b/internal/label/pullrequests.go index 6a12412..64adde9 100644 --- a/internal/label/pullrequests.go +++ b/internal/label/pullrequests.go @@ -12,13 +12,13 @@ import ( ) // PullRequests applies internal or community labels to pull requests -func PullRequests(githubClient *github.Client, internalTeam string, cfg config.LabelConfig) error { +func PullRequests(githubClient *github.Client, internalTeam string, cfg *config.Config) error { teamMembers, err := github2.GetTeamMemberList(githubClient, internalTeam) if err != nil { return fmt.Errorf("error getting team members: %w", err) // Properly handle and return error if team member list fetch fails } - pullRequests, err := github2.FindCommunityPRs(cfg.LabelCheckRepos, teamMembers, githubClient) + pullRequests, err := github2.FindCommunityPRs(cfg, teamMembers, githubClient) if err != nil { return fmt.Errorf("error finding community PRs: %w", err) // Handle error from finding community PRs } @@ -30,7 +30,7 @@ func PullRequests(githubClient *github.Client, internalTeam string, cfg config.L if teamMembers[user] { label = cfg.LabelInternal } else { - label = cfg.LabelExternal + label = cfg.LabelInternal } if label != "" { log.Printf("Pull Request %d by %s will be labeled %s\n", *pullRequest.Number, user, label) diff --git a/k8s/label-prs.yml.j2 b/k8s/label-prs.yml.j2 index bef6d15..b647527 100644 --- a/k8s/label-prs.yml.j2 +++ b/k8s/label-prs.yml.j2 @@ -17,7 +17,7 @@ secretFile: internal_team: "{{ INTERNAL_TEAM_NAME }}" label_internal: "" label_external: "community-pr" - label_check_repos: + check_repos: - name: "Chia-Network/chia-blockchain" minimum_number: 17788 - name: "Chia-Network/chia-blockchain-gui" @@ -26,6 +26,6 @@ secretFile: minimum_number: 533 - name: "Chia-Network/chialisp-web" minimum_number: 263 - label_skip_users: + skip_users: - "dependabot[bot]" - "github-actions[bot]" diff --git a/k8s/notify-pending-prs.yaml.j2 b/k8s/notify-pending-prs.yaml.j2 new file mode 100644 index 0000000..e5cd157 --- /dev/null +++ b/k8s/notify-pending-prs.yaml.j2 @@ -0,0 +1,25 @@ +replicaCount: 1 +image: + repository: ghcr.io/chia-network/github-bot + tag: {{ DOCKER_TAG }} + +deployment: + args: + - notify-stale + - --loop + +# Creates a secret with the following values, and mounts as a file into the main deployment container +secretFile: + mountPath: "/config" + stringValues: + config.yml: | + github_token: "{{ BOT_GITHUB_TOKEN }}" + internal_team: "{{ INTERNAL_TEAM_NAME }}" + check_stale_pending_repos: + - name: "Chia-Network/chia-blockchain" + minimum_number: 17788 + - name: "Chia-Network/chia-blockchain-gui" + minimum_number: 2300 + label_skip_users: + - "dependabot[bot]" + - "github-actions[bot]" diff --git a/k8s/notify-stale-pending-prs.yml.j2 b/k8s/notify-stale-prs.yml.j2 similarity index 97% rename from k8s/notify-stale-pending-prs.yml.j2 rename to k8s/notify-stale-prs.yml.j2 index 34212b4..4ea3511 100644 --- a/k8s/notify-stale-pending-prs.yml.j2 +++ b/k8s/notify-stale-prs.yml.j2 @@ -6,7 +6,6 @@ image: deployment: args: - notify-pendingci - - notify-stale - --loop # Creates a secret with the following values, and mounts as a file into the main deployment container From 6a7b6b8962d6d0141c3d86b896af5240f124e8ff Mon Sep 17 00:00:00 2001 From: Patrick Maslana Date: Fri, 31 May 2024 13:07:12 -0700 Subject: [PATCH 7/9] Fix a typo --- internal/label/pullrequests.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/label/pullrequests.go b/internal/label/pullrequests.go index 64adde9..7ebeca4 100644 --- a/internal/label/pullrequests.go +++ b/internal/label/pullrequests.go @@ -30,7 +30,7 @@ func PullRequests(githubClient *github.Client, internalTeam string, cfg *config. if teamMembers[user] { label = cfg.LabelInternal } else { - label = cfg.LabelInternal + label = cfg.LabelExternal } if label != "" { log.Printf("Pull Request %d by %s will be labeled %s\n", *pullRequest.Number, user, label) From c323c36bc20980a392a0af7692f2bcb9eb05da0d Mon Sep 17 00:00:00 2001 From: Patrick Maslana Date: Fri, 31 May 2024 13:50:37 -0700 Subject: [PATCH 8/9] Renamed a file and fixed key names in the j2 yaml files --- k8s/{notify-pending-prs.yaml.j2 => notify-pending-prs.yml.j2} | 4 ++-- k8s/notify-stale-prs.yml.j2 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename k8s/{notify-pending-prs.yaml.j2 => notify-pending-prs.yml.j2} (91%) diff --git a/k8s/notify-pending-prs.yaml.j2 b/k8s/notify-pending-prs.yml.j2 similarity index 91% rename from k8s/notify-pending-prs.yaml.j2 rename to k8s/notify-pending-prs.yml.j2 index e5cd157..b7a1f3b 100644 --- a/k8s/notify-pending-prs.yaml.j2 +++ b/k8s/notify-pending-prs.yml.j2 @@ -15,11 +15,11 @@ secretFile: config.yml: | github_token: "{{ BOT_GITHUB_TOKEN }}" internal_team: "{{ INTERNAL_TEAM_NAME }}" - check_stale_pending_repos: + check_repos: - name: "Chia-Network/chia-blockchain" minimum_number: 17788 - name: "Chia-Network/chia-blockchain-gui" minimum_number: 2300 - label_skip_users: + skip_users: - "dependabot[bot]" - "github-actions[bot]" diff --git a/k8s/notify-stale-prs.yml.j2 b/k8s/notify-stale-prs.yml.j2 index 4ea3511..4289e44 100644 --- a/k8s/notify-stale-prs.yml.j2 +++ b/k8s/notify-stale-prs.yml.j2 @@ -15,11 +15,11 @@ secretFile: config.yml: | github_token: "{{ BOT_GITHUB_TOKEN }}" internal_team: "{{ INTERNAL_TEAM_NAME }}" - check_stale_pending_repos: + check_repos: - name: "Chia-Network/chia-blockchain" minimum_number: 17788 - name: "Chia-Network/chia-blockchain-gui" minimum_number: 2300 - label_skip_users: + skip_users: - "dependabot[bot]" - "github-actions[bot]" From 4d7d8df0e8c39e7ce05c9ae58c18b910f70aa780 Mon Sep 17 00:00:00 2001 From: Patrick Maslana Date: Fri, 31 May 2024 14:20:32 -0700 Subject: [PATCH 9/9] Fix a redundant passing of internalteam var and rename the config struct that is passed in CheckforPendingCI --- cmd/labelPRs.go | 2 +- cmd/notifyPendingCI.go | 2 +- cmd/notifyStale.go | 2 +- internal/github/checkPendingCI.go | 8 ++++---- internal/github/checkStalePRs.go | 4 ++-- internal/label/pullrequests.go | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/labelPRs.go b/cmd/labelPRs.go index 29e21a4..8dc9b16 100644 --- a/cmd/labelPRs.go +++ b/cmd/labelPRs.go @@ -27,7 +27,7 @@ var labelPRsCmd = &cobra.Command{ loopDuration := viper.GetDuration("loop-time") for { log.Println("Labeling Pull Requests") - err = label.PullRequests(client, cfg.InternalTeam, cfg) + err = label.PullRequests(client, cfg) if err != nil { log.Fatalln(err.Error()) } diff --git a/cmd/notifyPendingCI.go b/cmd/notifyPendingCI.go index 84b7572..d3784c2 100644 --- a/cmd/notifyPendingCI.go +++ b/cmd/notifyPendingCI.go @@ -27,7 +27,7 @@ var notifyPendingCICmd = &cobra.Command{ var listPendingPRs []string for { log.Println("Checking for community PRs that are waiting for CI to run") - listPendingPRs, err = github2.CheckForPendingCI(client, cfg.InternalTeam, cfg) + listPendingPRs, err = github2.CheckForPendingCI(client, cfg) if err != nil { log.Printf("The following error occurred while obtaining a list of pending PRs: %s", err) time.Sleep(loopDuration) diff --git a/cmd/notifyStale.go b/cmd/notifyStale.go index 06a779c..dbbf3ae 100644 --- a/cmd/notifyStale.go +++ b/cmd/notifyStale.go @@ -27,7 +27,7 @@ var notifyStaleCmd = &cobra.Command{ var listPendingPRs []string for { log.Println("Checking for community PRs that have no update in the last 7 days") - _, err = github2.CheckStalePRs(client, cfg.InternalTeam, cfg) + _, err = github2.CheckStalePRs(client, cfg) if err != nil { log.Printf("The following error occurred while obtaining a list of stale PRs: %s", err) time.Sleep(loopDuration) diff --git a/internal/github/checkPendingCI.go b/internal/github/checkPendingCI.go index 3d21433..26d458c 100644 --- a/internal/github/checkPendingCI.go +++ b/internal/github/checkPendingCI.go @@ -14,11 +14,11 @@ import ( ) // CheckForPendingCI returns a list of PR URLs that are ready for CI to run but haven't started yet. -func CheckForPendingCI(githubClient *github.Client, internalTeam string, repos *config.Config) ([]string, error) { - teamMembers, _ := GetTeamMemberList(githubClient, internalTeam) +func CheckForPendingCI(githubClient *github.Client, cfg *config.Config) ([]string, error) { + teamMembers, _ := GetTeamMemberList(githubClient, cfg.InternalTeam) var pendingPRs []string - for _, fullRepo := range repos.CheckRepos { + for _, fullRepo := range cfg.CheckRepos { log.Println("Checking repository:", fullRepo.Name) parts := strings.Split(fullRepo.Name, "/") if len(parts) != 2 { @@ -28,7 +28,7 @@ func CheckForPendingCI(githubClient *github.Client, internalTeam string, repos * owner, repo := parts[0], parts[1] // Fetch community PRs using the FindCommunityPRs function - communityPRs, err := FindCommunityPRs(repos, teamMembers, githubClient) + communityPRs, err := FindCommunityPRs(cfg, teamMembers, githubClient) if err != nil { return nil, err } diff --git a/internal/github/checkStalePRs.go b/internal/github/checkStalePRs.go index aeab26a..455fde9 100644 --- a/internal/github/checkStalePRs.go +++ b/internal/github/checkStalePRs.go @@ -12,10 +12,10 @@ import ( ) // CheckStalePRs will return a list of PR URLs that have not been updated in the last 7 days by internal team members. -func CheckStalePRs(githubClient *github.Client, internalTeam string, cfg *config.Config) ([]string, error) { +func CheckStalePRs(githubClient *github.Client, cfg *config.Config) ([]string, error) { var stalePRUrls []string cutoffDate := time.Now().Add(7 * 24 * time.Hour) // 7 days ago - teamMembers, err := GetTeamMemberList(githubClient, internalTeam) + teamMembers, err := GetTeamMemberList(githubClient, cfg.InternalTeam) if err != nil { return nil, err } diff --git a/internal/label/pullrequests.go b/internal/label/pullrequests.go index 7ebeca4..a93a4d8 100644 --- a/internal/label/pullrequests.go +++ b/internal/label/pullrequests.go @@ -12,8 +12,8 @@ import ( ) // PullRequests applies internal or community labels to pull requests -func PullRequests(githubClient *github.Client, internalTeam string, cfg *config.Config) error { - teamMembers, err := github2.GetTeamMemberList(githubClient, internalTeam) +func PullRequests(githubClient *github.Client, cfg *config.Config) error { + teamMembers, err := github2.GetTeamMemberList(githubClient, cfg.InternalTeam) if err != nil { return fmt.Errorf("error getting team members: %w", err) // Properly handle and return error if team member list fetch fails }