From dabfcbbefd70686259e823b6b286bc1c9eac6eeb Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Fri, 9 May 2025 16:19:38 -0700 Subject: [PATCH 1/4] Move github membership data into tools --- tools/github-membership/go.mod | 8 + tools/github-membership/go.sum | 4 + tools/github-membership/membership.go | 119 ++++++++++ tools/github-membership/membership_data.go | 141 ++++++++++++ tools/github-membership/membership_test.go | 255 +++++++++++++++++++++ 5 files changed, 527 insertions(+) create mode 100644 tools/github-membership/go.mod create mode 100644 tools/github-membership/go.sum create mode 100644 tools/github-membership/membership.go create mode 100644 tools/github-membership/membership_data.go create mode 100644 tools/github-membership/membership_test.go diff --git a/tools/github-membership/go.mod b/tools/github-membership/go.mod new file mode 100644 index 000000000000..2e9009edb7de --- /dev/null +++ b/tools/github-membership/go.mod @@ -0,0 +1,8 @@ +module github.com/trodge/magic-modules/membership-tools/tools/github-membership + +go 1.25 + +require ( + github.com/google/go-cmp v0.7.0 + golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 +) diff --git a/tools/github-membership/go.sum b/tools/github-membership/go.sum new file mode 100644 index 000000000000..b1a17c8eac29 --- /dev/null +++ b/tools/github-membership/go.sum @@ -0,0 +1,4 @@ +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI= +golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ= diff --git a/tools/github-membership/membership.go b/tools/github-membership/membership.go new file mode 100644 index 000000000000..2f972e417f89 --- /dev/null +++ b/tools/github-membership/membership.go @@ -0,0 +1,119 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ +package membership + +import ( + "fmt" + "math/rand" + "slices" + "time" + + "golang.org/x/exp/maps" +) + +type UserType int64 + +const ( + CommunityUserType UserType = iota + GooglerUserType + CoreContributorUserType +) + +func (ut UserType) String() string { + switch ut { + case GooglerUserType: + return "Googler" + case CoreContributorUserType: + return "Core Contributor" + default: + return "Community Contributor" + } +} + +func (gh *Client) GetUserType(user string) UserType { + if IsCoreContributor(user) { + fmt.Println("User is a core contributor") + return CoreContributorUserType + } + + if gh.IsTeamMember("GoogleCloudPlatform", "terraform", user) { + fmt.Println("User is an active member of the 'terraform' team in 'GoogleCloudPlatform' organization") + return GooglerUserType + } else { + fmt.Printf("User '%s' is not an active member of the 'terraform' team in 'GoogleCloudPlatform' organization\n", user) + } + + if gh.IsOrgMember(user, "GoogleCloudPlatform") { + fmt.Println("User is a GCP org member") + return GooglerUserType + } + + if gh.IsOrgMember(user, "googlers") { + fmt.Println("User is a googlers org member") + return GooglerUserType + } + + return CommunityUserType +} + +// Check if a user is team member to not request a random reviewer +func IsCoreContributor(user string) bool { + _, isTrustedContributor := trustedContributors[user] + return IsCoreReviewer(user) || isTrustedContributor +} + +func IsCoreReviewer(user string) bool { + _, isCoreReviewer := reviewerRotation[user] + return isCoreReviewer +} + +// GetRandomReviewer returns a random available reviewer (optionally excluding some people from the reviewer pool) +func GetRandomReviewer(excludedReviewers []string) string { + availableReviewers := AvailableReviewers(excludedReviewers) + reviewer := availableReviewers[rand.Intn(len(availableReviewers))] + return reviewer +} + +func AvailableReviewers(excludedReviewers []string) []string { + return available(time.Now(), reviewerRotation, excludedReviewers) +} + +func available(nowTime time.Time, reviewerRotation map[string]ReviewerConfig, excludedReviewers []string) []string { + excludedReviewers = append(excludedReviewers, onVacation(nowTime, reviewerRotation)...) + notExcluded := make(map[string]struct{}, len(reviewerRotation)) + for reviewer := range reviewerRotation { + notExcluded[reviewer] = struct{}{} + } + for _, excluded := range excludedReviewers { + delete(notExcluded, excluded) + } + ret := maps.Keys(notExcluded) + slices.Sort(ret) + return ret +} + +func onVacation(nowTime time.Time, reviewerRotation map[string]ReviewerConfig) []string { + var onVacationList []string + for reviewer, config := range reviewerRotation { + for _, v := range config.vacations { + if nowTime.Before(v.GetStart(config.timezone)) || nowTime.After(v.GetEnd(config.timezone)) { + continue + } + onVacationList = append(onVacationList, reviewer) + } + } + return onVacationList +} diff --git a/tools/github-membership/membership_data.go b/tools/github-membership/membership_data.go new file mode 100644 index 000000000000..81b5df820da8 --- /dev/null +++ b/tools/github-membership/membership_data.go @@ -0,0 +1,141 @@ +package membership + +import "time" + +type date struct { + year int + month int + day int +} + +func newDate(year, month, day int) date { + return date{ + year: year, + month: month, + day: day, + } +} + +type Vacation struct { + startDate, endDate date +} + +// GetStart returns a time corresponding to the beginning of the start date in the given timezone. +func (v Vacation) GetStart(timezone *time.Location) time.Time { + if timezone == nil { + timezone = usPacific + } + return time.Date(v.startDate.year, time.Month(v.startDate.month), v.startDate.day, 0, 0, 0, 0, timezone) +} + +// GetEnd returns a time corresponding to the end of the end date in the given timezone +func (v Vacation) GetEnd(timezone *time.Location) time.Time { + if timezone == nil { + timezone = usPacific + } + return time.Date(v.endDate.year, time.Month(v.endDate.month), v.endDate.day, 0, 0, 0, 0, timezone).AddDate(0, 0, 1).Add(-1 * time.Millisecond) +} + +type ReviewerConfig struct { + // timezone controls the timezone for vacation start / end dates. Default: US/Pacific. + timezone *time.Location + + // vacations allows specifying times when new reviews should not be requested of the reviewer. + // Existing PRs will still have reviews re-requested. + // Both startDate and endDate are inclusive. + // Example: taking vacation from 2024-03-28 to 2024-04-02. + // { + // vacations: []Vacation{ + // startDate: newDate(2024, 3, 28), + // endDate: newDate(2024, 4, 2), + // }, + // }, + vacations []Vacation +} + +var ( + usPacific, _ = time.LoadLocation("US/Pacific") + usCentral, _ = time.LoadLocation("US/Central") + usEastern, _ = time.LoadLocation("US/Eastern") + london, _ = time.LoadLocation("Europe/London") + + // This is for the random-assignee rotation. + reviewerRotation = map[string]ReviewerConfig{ + "BBBmau": { + vacations: []Vacation{ + { + startDate: newDate(2025, 4, 7), + endDate: newDate(2025, 4, 11), + }, + }, + }, + "c2thorn": { + vacations: []Vacation{ + { + startDate: newDate(2025, 4, 9), + endDate: newDate(2025, 4, 15), + }, + }, + }, + "hao-nan-li": { + vacations: []Vacation{}, + }, + "melinath": { + vacations: []Vacation{}, + }, + "NickElliot": { + vacations: []Vacation{}, + }, + "rileykarson": { + vacations: []Vacation{ + { + startDate: newDate(2025, 2, 25), + endDate: newDate(2025, 3, 10), + }, + }, + }, + "roaks3": { + vacations: []Vacation{}, + }, + "ScottSuarez": { + vacations: []Vacation{}, + }, + "shuyama1": { + vacations: []Vacation{ + { + startDate: newDate(2025, 3, 26), + endDate: newDate(2025, 4, 1), + }, + }, + }, + "SirGitsalot": { + vacations: []Vacation{ + { + startDate: newDate(2025, 1, 18), + endDate: newDate(2025, 1, 25), + }, + }, + }, + "slevenick": { + vacations: []Vacation{}, + }, + "trodge": { + vacations: []Vacation{}, + }, + "zli82016": { + vacations: []Vacation{ + { + startDate: newDate(2025, 1, 15), + endDate: newDate(2025, 2, 9), + }, + }, + }, + } + + // This is for new team members who are onboarding + trustedContributors = map[string]struct{}{ + "bbasata": struct{}{}, + "jaylonmcshan03": struct{}{}, + "malhotrasagar2212": struct{}{}, + } +) diff --git a/tools/github-membership/membership_test.go b/tools/github-membership/membership_test.go new file mode 100644 index 000000000000..be710b9130f5 --- /dev/null +++ b/tools/github-membership/membership_test.go @@ -0,0 +1,255 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ +package membership + +import ( + "testing" + "time" + + "github.com/google/go-cmp/cmp" +) + +func TestTrustedContributors(t *testing.T) { + for member, _ := range trustedContributors { + if IsCoreReviewer(member) { + t.Fatalf(`%v should not be on reviewerRotation list`, member) + } + } +} + +func TestAvailable(t *testing.T) { + // Double-check that timezones are loadable first. + _, err := time.LoadLocation("US/Eastern") + if err != nil { + t.Fatal(err) + } + _, err = time.LoadLocation("US/Pacific") + if err != nil { + t.Fatal(err) + } + + tests := []struct { + name string + rotation map[string]ReviewerConfig + timeNow time.Time + excludedReviewers []string + want []string + }{ + { + name: "reviewers on vacation start date are excluded", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": { + timezone: time.UTC, + vacations: []Vacation{ + { + startDate: newDate(2024, 3, 29), + endDate: newDate(2024, 4, 2), + }, + }, + }, + }, + timeNow: time.Date(2024, 3, 29, 0, 0, 0, 0, time.UTC), + want: []string{"id1"}, + }, + { + name: "reviewers on vacation end date are excluded", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": { + timezone: time.UTC, + vacations: []Vacation{ + { + startDate: newDate(2024, 3, 29), + endDate: newDate(2024, 4, 2), + }, + }, + }, + }, + timeNow: time.Date(2024, 4, 2, 10, 0, 0, 0, time.UTC), + want: []string{"id1"}, + }, + { + name: "reviewers are included after vacation ends", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": { + timezone: time.UTC, + vacations: []Vacation{ + { + startDate: newDate(2024, 3, 29), + endDate: newDate(2024, 4, 2), + }, + }, + }, + }, + timeNow: time.Date(2024, 4, 3, 0, 0, 0, 0, time.UTC), + want: []string{"id1", "id2"}, + }, + { + name: "reviewers are included before vacation starts", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": { + timezone: time.UTC, + vacations: []Vacation{ + { + startDate: newDate(2024, 3, 29), + endDate: newDate(2024, 4, 2), + }, + }, + }, + }, + timeNow: time.Date(2024, 3, 28, 23, 0, 0, 0, time.UTC), + want: []string{"id1", "id2"}, + }, + { + name: "reviewers are excluded if vacation has not ended in the specified time zone", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": { + vacations: []Vacation{ + { + startDate: newDate(2024, 3, 29), + endDate: newDate(2024, 4, 2), + }, + }, + }, + }, + // it's still 2024-04-02 in Pacific time zone + timeNow: time.Date(2024, 4, 3, 0, 0, 0, 0, usEastern), + want: []string{"id1"}, + }, + { + name: "included before vacations", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": { + vacations: []Vacation{ + { + startDate: newDate(2024, 3, 29), + endDate: newDate(2024, 4, 2), + }, + { + startDate: newDate(2024, 5, 2), + endDate: newDate(2024, 5, 5), + }, + }, + }, + }, + timeNow: time.Date(2024, 3, 1, 0, 0, 0, 0, usPacific), + want: []string{"id1", "id2"}, + }, + { + name: "excluded during first vacation", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": { + vacations: []Vacation{ + { + startDate: newDate(2024, 3, 29), + endDate: newDate(2024, 4, 2), + }, + { + startDate: newDate(2024, 5, 2), + endDate: newDate(2024, 5, 5), + }, + }, + }, + }, + timeNow: time.Date(2024, 4, 1, 0, 0, 0, 0, usPacific), + want: []string{"id1"}, + }, + { + name: "included between vacations", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": { + vacations: []Vacation{ + { + startDate: newDate(2024, 3, 29), + endDate: newDate(2024, 4, 2), + }, + { + startDate: newDate(2024, 5, 2), + endDate: newDate(2024, 5, 5), + }, + }, + }, + }, + timeNow: time.Date(2024, 4, 4, 0, 0, 0, 0, usPacific), + want: []string{"id1", "id2"}, + }, + { + name: "excluded during second vacation", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": { + vacations: []Vacation{ + { + startDate: newDate(2024, 3, 29), + endDate: newDate(2024, 4, 2), + }, + { + startDate: newDate(2024, 5, 2), + endDate: newDate(2024, 5, 5), + }, + }, + }, + }, + timeNow: time.Date(2024, 5, 3, 0, 0, 0, 0, usPacific), + want: []string{"id1"}, + }, + { + name: "included after vacations", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": { + vacations: []Vacation{ + { + startDate: newDate(2024, 3, 29), + endDate: newDate(2024, 4, 2), + }, + { + startDate: newDate(2024, 5, 2), + endDate: newDate(2024, 5, 5), + }, + }, + }, + }, + timeNow: time.Date(2024, 6, 1, 0, 0, 0, 0, usPacific), + want: []string{"id1", "id2"}, + }, + { + name: "explicitly excluded reviewers", + rotation: map[string]ReviewerConfig{ + "id1": {vacations: []Vacation{}}, + "id2": {vacations: []Vacation{}}, + }, + excludedReviewers: []string{"id2"}, + want: []string{"id1"}, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := available(test.timeNow, test.rotation, test.excludedReviewers) + if diff := cmp.Diff(test.want, got); diff != "" { + t.Errorf("available(%v, %v, %v) got diff: %s", test.timeNow, test.rotation, test.excludedReviewers, diff) + } + }) + } + +} From 7f69b69d2cb6d375afb81a5082ab8930ae571f33 Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Mon, 2 Jun 2025 02:28:59 +0000 Subject: [PATCH 2/4] Copy vacation updates --- tools/github-membership/membership_data.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/github-membership/membership_data.go b/tools/github-membership/membership_data.go index 81b5df820da8..c711bb9276aa 100644 --- a/tools/github-membership/membership_data.go +++ b/tools/github-membership/membership_data.go @@ -103,8 +103,8 @@ var ( "shuyama1": { vacations: []Vacation{ { - startDate: newDate(2025, 3, 26), - endDate: newDate(2025, 4, 1), + startDate: newDate(2025, 5, 23), + endDate: newDate(2025, 5, 30), }, }, }, @@ -117,7 +117,12 @@ var ( }, }, "slevenick": { - vacations: []Vacation{}, + vacations: []Vacation{ + { + startDate: newDate(2025, 5, 22), + endDate: newDate(2025, 6, 7), + }, + }, }, "trodge": { vacations: []Vacation{}, From ae124698ba8f7d9ccd262849ac02779d2461fc92 Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Mon, 2 Jun 2025 16:14:21 -0700 Subject: [PATCH 3/4] Move magician into tools --- .ci/containers/go-plus/Dockerfile | 2 +- .ci/scripts/go-plus/magician/exec.sh | 4 +- .github/workflows/reassign-reviewer.yml | 4 +- .github/workflows/request-reviewer.yml | 4 +- .github/workflows/scheduled-pr-reminders.yml | 4 +- .github/workflows/unit-test-magician.yml | 4 +- .gitignore | 6 +- tools/github-membership/go.mod | 8 - tools/github-membership/go.sum | 4 - tools/github-membership/membership.go | 119 -------- tools/github-membership/membership_data.go | 146 ---------- tools/github-membership/membership_test.go | 255 ------------------ .../magician/cloudbuild/community.go | 0 .../magician/cloudbuild/constants.go | 0 {.ci => tools}/magician/cloudbuild/init.go | 0 .../magician/cloudstorage/bucket.go | 0 {.ci => tools}/magician/cloudstorage/init.go | 0 .../magician/cmd/check_cassettes.go | 0 .../cmd/collect_nightly_test_status.go | 0 .../cmd/collect_nightly_test_status_test.go | 0 .../cmd/create_test_failure_ticket.go | 0 .../cmd/create_test_failure_ticket_test.go | 0 .../magician/cmd/delete_branches.go | 0 .../magician/cmd/delete_branches_test.go | 0 .../magician/cmd/generate_comment.go | 0 .../magician/cmd/generate_comment_test.go | 8 +- .../magician/cmd/generate_downstream.go | 0 {.ci => tools}/magician/cmd/interfaces.go | 0 .../cmd/manage_test_failure_ticket.go | 0 .../magician/cmd/membership_checker.go | 0 .../magician/cmd/membership_checker_test.go | 0 .../magician/cmd/mock_cloudbuild_test.go | 0 .../magician/cmd/mock_github_test.go | 0 .../magician/cmd/mock_runner_test.go | 10 +- .../magician/cmd/reassign_reviewer.go | 0 .../magician/cmd/reassign_reviewer_test.go | 0 {.ci => tools}/magician/cmd/remove_label.go | 0 .../magician/cmd/remove_label_test.go | 0 .../magician/cmd/request_reviewer.go | 0 .../magician/cmd/request_reviewer_test.go | 0 .../magician/cmd/request_service_reviewers.go | 0 .../cmd/request_service_reviewers_test.go | 0 {.ci => tools}/magician/cmd/root.go | 0 .../magician/cmd/scheduled_pr_reminders.go | 0 .../cmd/scheduled_pr_reminders_test.go | 0 {.ci => tools}/magician/cmd/sync_branch.go | 0 {.ci => tools}/magician/cmd/templates.go | 0 .../cmd/templates/DIFF_COMMENT.md.tmpl | 0 ...HEDULED_PR_WAITING_FOR_CONTRIBUTOR.md.tmpl | 0 .../SCHEDULED_PR_WAITING_FOR_MERGE.md.tmpl | 0 .../SCHEDULED_PR_WAITING_FOR_REVIEW.md.tmpl | 0 .../cmd/templates/TEST_FAILURE_ISSUE.md.tmpl | 0 .../cmd/templates/vcr/post_replay.tmpl | 0 .../cmd/templates/vcr/record_replay.tmpl | 0 .../vcr/vcr_cassettes_update_recording.tmpl | 0 .../vcr/vcr_cassettes_update_replaying.tmpl | 0 {.ci => tools}/magician/cmd/templates_test.go | 0 {.ci => tools}/magician/cmd/test_eap_vcr.go | 0 .../magician/cmd/test_terraform_vcr.go | 0 .../magician/cmd/test_terraform_vcr_test.go | 0 {.ci => tools}/magician/cmd/test_tgc.go | 0 .../magician/cmd/test_tgc_integration.go | 0 {.ci => tools}/magician/cmd/test_tgc_test.go | 0 {.ci => tools}/magician/cmd/test_tpg.go | 0 {.ci => tools}/magician/cmd/test_tpg_test.go | 0 .../magician/cmd/vcr_cassette_update.go | 0 .../magician/cmd/vcr_cassette_update_test.go | 50 ++-- {.ci => tools}/magician/cmd/vcr_merge.go | 0 {.ci => tools}/magician/cmd/vcr_merge_eap.go | 0 {.ci => tools}/magician/cmd/vcr_merge_test.go | 0 .../magician/cmd/wait_for_commit.go | 0 .../magician/cmd/wait_for_commit_test.go | 0 {.ci => tools}/magician/exec/runner.go | 0 {.ci => tools}/magician/github/README.md | 0 .../github/REVIEWER_ASSIGNMENT_COMMENT.md | 0 {.ci => tools}/magician/github/get.go | 0 {.ci => tools}/magician/github/init.go | 0 .../magician/github/integration_test.go | 0 .../magician/github/interface_conversion.go | 0 {.ci => tools}/magician/github/membership.go | 0 .../magician/github/membership_data.go | 0 .../magician/github/membership_test.go | 0 .../magician/github/reviewer_assignment.go | 0 .../github/reviewer_assignment_test.go | 0 {.ci => tools}/magician/github/set.go | 0 {.ci => tools}/magician/go.mod | 0 {.ci => tools}/magician/go.sum | 0 {.ci => tools}/magician/main.go | 0 {.ci => tools}/magician/provider/version.go | 0 {.ci => tools}/magician/source/repo.go | 0 {.ci => tools}/magician/teamcity/get.go | 0 {.ci => tools}/magician/teamcity/init.go | 0 {.ci => tools}/magician/utility/utils.go | 0 {.ci => tools}/magician/utility/utils_test.go | 0 {.ci => tools}/magician/vcr/interfaces.go | 0 {.ci => tools}/magician/vcr/tester.go | 0 96 files changed, 48 insertions(+), 580 deletions(-) delete mode 100644 tools/github-membership/go.mod delete mode 100644 tools/github-membership/go.sum delete mode 100644 tools/github-membership/membership.go delete mode 100644 tools/github-membership/membership_data.go delete mode 100644 tools/github-membership/membership_test.go rename {.ci => tools}/magician/cloudbuild/community.go (100%) rename {.ci => tools}/magician/cloudbuild/constants.go (100%) rename {.ci => tools}/magician/cloudbuild/init.go (100%) rename {.ci => tools}/magician/cloudstorage/bucket.go (100%) rename {.ci => tools}/magician/cloudstorage/init.go (100%) rename {.ci => tools}/magician/cmd/check_cassettes.go (100%) rename {.ci => tools}/magician/cmd/collect_nightly_test_status.go (100%) rename {.ci => tools}/magician/cmd/collect_nightly_test_status_test.go (100%) rename {.ci => tools}/magician/cmd/create_test_failure_ticket.go (100%) rename {.ci => tools}/magician/cmd/create_test_failure_ticket_test.go (100%) rename {.ci => tools}/magician/cmd/delete_branches.go (100%) rename {.ci => tools}/magician/cmd/delete_branches_test.go (100%) rename {.ci => tools}/magician/cmd/generate_comment.go (100%) rename {.ci => tools}/magician/cmd/generate_comment_test.go (95%) rename {.ci => tools}/magician/cmd/generate_downstream.go (100%) rename {.ci => tools}/magician/cmd/interfaces.go (100%) rename {.ci => tools}/magician/cmd/manage_test_failure_ticket.go (100%) rename {.ci => tools}/magician/cmd/membership_checker.go (100%) rename {.ci => tools}/magician/cmd/membership_checker_test.go (100%) rename {.ci => tools}/magician/cmd/mock_cloudbuild_test.go (100%) rename {.ci => tools}/magician/cmd/mock_github_test.go (100%) rename {.ci => tools}/magician/cmd/mock_runner_test.go (90%) rename {.ci => tools}/magician/cmd/reassign_reviewer.go (100%) rename {.ci => tools}/magician/cmd/reassign_reviewer_test.go (100%) rename {.ci => tools}/magician/cmd/remove_label.go (100%) rename {.ci => tools}/magician/cmd/remove_label_test.go (100%) rename {.ci => tools}/magician/cmd/request_reviewer.go (100%) rename {.ci => tools}/magician/cmd/request_reviewer_test.go (100%) rename {.ci => tools}/magician/cmd/request_service_reviewers.go (100%) rename {.ci => tools}/magician/cmd/request_service_reviewers_test.go (100%) rename {.ci => tools}/magician/cmd/root.go (100%) rename {.ci => tools}/magician/cmd/scheduled_pr_reminders.go (100%) rename {.ci => tools}/magician/cmd/scheduled_pr_reminders_test.go (100%) rename {.ci => tools}/magician/cmd/sync_branch.go (100%) rename {.ci => tools}/magician/cmd/templates.go (100%) rename {.ci => tools}/magician/cmd/templates/DIFF_COMMENT.md.tmpl (100%) rename {.ci => tools}/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_CONTRIBUTOR.md.tmpl (100%) rename {.ci => tools}/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_MERGE.md.tmpl (100%) rename {.ci => tools}/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_REVIEW.md.tmpl (100%) rename {.ci => tools}/magician/cmd/templates/TEST_FAILURE_ISSUE.md.tmpl (100%) rename {.ci => tools}/magician/cmd/templates/vcr/post_replay.tmpl (100%) rename {.ci => tools}/magician/cmd/templates/vcr/record_replay.tmpl (100%) rename {.ci => tools}/magician/cmd/templates/vcr/vcr_cassettes_update_recording.tmpl (100%) rename {.ci => tools}/magician/cmd/templates/vcr/vcr_cassettes_update_replaying.tmpl (100%) rename {.ci => tools}/magician/cmd/templates_test.go (100%) rename {.ci => tools}/magician/cmd/test_eap_vcr.go (100%) rename {.ci => tools}/magician/cmd/test_terraform_vcr.go (100%) rename {.ci => tools}/magician/cmd/test_terraform_vcr_test.go (100%) rename {.ci => tools}/magician/cmd/test_tgc.go (100%) rename {.ci => tools}/magician/cmd/test_tgc_integration.go (100%) rename {.ci => tools}/magician/cmd/test_tgc_test.go (100%) rename {.ci => tools}/magician/cmd/test_tpg.go (100%) rename {.ci => tools}/magician/cmd/test_tpg_test.go (100%) rename {.ci => tools}/magician/cmd/vcr_cassette_update.go (100%) rename {.ci => tools}/magician/cmd/vcr_cassette_update_test.go (73%) rename {.ci => tools}/magician/cmd/vcr_merge.go (100%) rename {.ci => tools}/magician/cmd/vcr_merge_eap.go (100%) rename {.ci => tools}/magician/cmd/vcr_merge_test.go (100%) rename {.ci => tools}/magician/cmd/wait_for_commit.go (100%) rename {.ci => tools}/magician/cmd/wait_for_commit_test.go (100%) rename {.ci => tools}/magician/exec/runner.go (100%) rename {.ci => tools}/magician/github/README.md (100%) rename {.ci => tools}/magician/github/REVIEWER_ASSIGNMENT_COMMENT.md (100%) rename {.ci => tools}/magician/github/get.go (100%) rename {.ci => tools}/magician/github/init.go (100%) rename {.ci => tools}/magician/github/integration_test.go (100%) rename {.ci => tools}/magician/github/interface_conversion.go (100%) rename {.ci => tools}/magician/github/membership.go (100%) rename {.ci => tools}/magician/github/membership_data.go (100%) rename {.ci => tools}/magician/github/membership_test.go (100%) rename {.ci => tools}/magician/github/reviewer_assignment.go (100%) rename {.ci => tools}/magician/github/reviewer_assignment_test.go (100%) rename {.ci => tools}/magician/github/set.go (100%) rename {.ci => tools}/magician/go.mod (100%) rename {.ci => tools}/magician/go.sum (100%) rename {.ci => tools}/magician/main.go (100%) rename {.ci => tools}/magician/provider/version.go (100%) rename {.ci => tools}/magician/source/repo.go (100%) rename {.ci => tools}/magician/teamcity/get.go (100%) rename {.ci => tools}/magician/teamcity/init.go (100%) rename {.ci => tools}/magician/utility/utils.go (100%) rename {.ci => tools}/magician/utility/utils_test.go (100%) rename {.ci => tools}/magician/vcr/interfaces.go (100%) rename {.ci => tools}/magician/vcr/tester.go (100%) diff --git a/.ci/containers/go-plus/Dockerfile b/.ci/containers/go-plus/Dockerfile index dbe2c2e672a9..c8dbbdaebec2 100644 --- a/.ci/containers/go-plus/Dockerfile +++ b/.ci/containers/go-plus/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /app1 # Add the source code and build ADD "https://github.com/GoogleCloudPlatform/magic-modules/archive/refs/heads/main.zip" source.zip RUN unzip source.zip && rm source.zip -WORKDIR /app1/magic-modules-main/.ci/magician +WORKDIR /app1/magic-modules-main/tools/magician # Build the binary (we won't use it in the final image, but it's cached) RUN go build -o /dev/null . diff --git a/.ci/scripts/go-plus/magician/exec.sh b/.ci/scripts/go-plus/magician/exec.sh index c438fb69cb22..8121faff74c4 100755 --- a/.ci/scripts/go-plus/magician/exec.sh +++ b/.ci/scripts/go-plus/magician/exec.sh @@ -2,11 +2,11 @@ set -e -# Get the directory of the current script +# Get the directory of the current script (.ci/scripts/go-plus/magician/exec.sh) DIR="$(dirname $(realpath $0))" # Construct the path to the Go program directory and binary -GO_PROGRAM_DIR="$DIR/../../../magician" +GO_PROGRAM_DIR="$DIR/../../../../tools/magician" GO_BINARY="$GO_PROGRAM_DIR/magician_binary" pushd $GO_PROGRAM_DIR diff --git a/.github/workflows/reassign-reviewer.yml b/.github/workflows/reassign-reviewer.yml index 5581c8519865..cb6ab7c204a0 100644 --- a/.github/workflows/reassign-reviewer.yml +++ b/.github/workflows/reassign-reviewer.yml @@ -38,8 +38,8 @@ jobs: - name: Build magician if: steps.read-comment.outputs.match != '' run: | - cd .ci/magician + cd tools/magician go build . - name: Run command if: steps.read-comment.outputs.match != '' - run: .ci/magician/magician reassign-reviewer ${{ github.event.issue.number }} ${{ github.event.comment.user.login }} ${{ steps.read-comment.outputs.group1 }} + run: tools/magician/magician reassign-reviewer ${{ github.event.issue.number }} ${{ github.event.comment.user.login }} ${{ steps.read-comment.outputs.group1 }} diff --git a/.github/workflows/request-reviewer.yml b/.github/workflows/request-reviewer.yml index b8e8d80043ff..ccec60b649ea 100644 --- a/.github/workflows/request-reviewer.yml +++ b/.github/workflows/request-reviewer.yml @@ -34,8 +34,8 @@ jobs: cache: false - name: Build magician run: | - cd .ci/magician + cd tools/magician go build . - name: Request reviewer - run: .ci/magician/magician request-reviewer ${{ github.event.pull_request.number || github.event.issue.number }} + run: tools/magician/magician request-reviewer ${{ github.event.pull_request.number || github.event.issue.number }} diff --git a/.github/workflows/scheduled-pr-reminders.yml b/.github/workflows/scheduled-pr-reminders.yml index 2c8ac5bf4323..0d74c831a914 100644 --- a/.github/workflows/scheduled-pr-reminders.yml +++ b/.github/workflows/scheduled-pr-reminders.yml @@ -25,7 +25,7 @@ jobs: cache: false - name: Build magician run: | - cd .ci/magician + cd tools/magician go build . - name: Request reviewer - run: .ci/magician/magician scheduled-pr-reminders ${{ github.event.pull_request.number }} + run: tools/magician/magician scheduled-pr-reminders ${{ github.event.pull_request.number }} diff --git a/.github/workflows/unit-test-magician.yml b/.github/workflows/unit-test-magician.yml index c90e855ebf5a..2d11eb09520f 100644 --- a/.github/workflows/unit-test-magician.yml +++ b/.github/workflows/unit-test-magician.yml @@ -5,7 +5,7 @@ permissions: read-all on: pull_request: paths: - - '.ci/magician/**' + - 'tools/magician/**' jobs: build-and-unit-tests: @@ -18,7 +18,7 @@ jobs: go-version: '^1.23' - name: Run magician unit tests run: | - cd .ci/magician + cd tools/magician go test ./... env: GITHUB_TOKEN_CLASSIC: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 383e6dbd3c09..48445f340d4f 100644 --- a/.gitignore +++ b/.gitignore @@ -54,8 +54,8 @@ tpgtools/temp.serial tpgtools/serialization.go # ignore magician binary -.ci/magician/magician +tools/magician/magician # ignore leftover testlogs and cassettes -.ci/magician/testlogs -.ci/magician/cassettes +tools/magician/testlogs +tools/magician/cassettes diff --git a/tools/github-membership/go.mod b/tools/github-membership/go.mod deleted file mode 100644 index 2e9009edb7de..000000000000 --- a/tools/github-membership/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module github.com/trodge/magic-modules/membership-tools/tools/github-membership - -go 1.25 - -require ( - github.com/google/go-cmp v0.7.0 - golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 -) diff --git a/tools/github-membership/go.sum b/tools/github-membership/go.sum deleted file mode 100644 index b1a17c8eac29..000000000000 --- a/tools/github-membership/go.sum +++ /dev/null @@ -1,4 +0,0 @@ -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI= -golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ= diff --git a/tools/github-membership/membership.go b/tools/github-membership/membership.go deleted file mode 100644 index 2f972e417f89..000000000000 --- a/tools/github-membership/membership.go +++ /dev/null @@ -1,119 +0,0 @@ -/* -* Copyright 2023 Google LLC. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ -package membership - -import ( - "fmt" - "math/rand" - "slices" - "time" - - "golang.org/x/exp/maps" -) - -type UserType int64 - -const ( - CommunityUserType UserType = iota - GooglerUserType - CoreContributorUserType -) - -func (ut UserType) String() string { - switch ut { - case GooglerUserType: - return "Googler" - case CoreContributorUserType: - return "Core Contributor" - default: - return "Community Contributor" - } -} - -func (gh *Client) GetUserType(user string) UserType { - if IsCoreContributor(user) { - fmt.Println("User is a core contributor") - return CoreContributorUserType - } - - if gh.IsTeamMember("GoogleCloudPlatform", "terraform", user) { - fmt.Println("User is an active member of the 'terraform' team in 'GoogleCloudPlatform' organization") - return GooglerUserType - } else { - fmt.Printf("User '%s' is not an active member of the 'terraform' team in 'GoogleCloudPlatform' organization\n", user) - } - - if gh.IsOrgMember(user, "GoogleCloudPlatform") { - fmt.Println("User is a GCP org member") - return GooglerUserType - } - - if gh.IsOrgMember(user, "googlers") { - fmt.Println("User is a googlers org member") - return GooglerUserType - } - - return CommunityUserType -} - -// Check if a user is team member to not request a random reviewer -func IsCoreContributor(user string) bool { - _, isTrustedContributor := trustedContributors[user] - return IsCoreReviewer(user) || isTrustedContributor -} - -func IsCoreReviewer(user string) bool { - _, isCoreReviewer := reviewerRotation[user] - return isCoreReviewer -} - -// GetRandomReviewer returns a random available reviewer (optionally excluding some people from the reviewer pool) -func GetRandomReviewer(excludedReviewers []string) string { - availableReviewers := AvailableReviewers(excludedReviewers) - reviewer := availableReviewers[rand.Intn(len(availableReviewers))] - return reviewer -} - -func AvailableReviewers(excludedReviewers []string) []string { - return available(time.Now(), reviewerRotation, excludedReviewers) -} - -func available(nowTime time.Time, reviewerRotation map[string]ReviewerConfig, excludedReviewers []string) []string { - excludedReviewers = append(excludedReviewers, onVacation(nowTime, reviewerRotation)...) - notExcluded := make(map[string]struct{}, len(reviewerRotation)) - for reviewer := range reviewerRotation { - notExcluded[reviewer] = struct{}{} - } - for _, excluded := range excludedReviewers { - delete(notExcluded, excluded) - } - ret := maps.Keys(notExcluded) - slices.Sort(ret) - return ret -} - -func onVacation(nowTime time.Time, reviewerRotation map[string]ReviewerConfig) []string { - var onVacationList []string - for reviewer, config := range reviewerRotation { - for _, v := range config.vacations { - if nowTime.Before(v.GetStart(config.timezone)) || nowTime.After(v.GetEnd(config.timezone)) { - continue - } - onVacationList = append(onVacationList, reviewer) - } - } - return onVacationList -} diff --git a/tools/github-membership/membership_data.go b/tools/github-membership/membership_data.go deleted file mode 100644 index c711bb9276aa..000000000000 --- a/tools/github-membership/membership_data.go +++ /dev/null @@ -1,146 +0,0 @@ -package membership - -import "time" - -type date struct { - year int - month int - day int -} - -func newDate(year, month, day int) date { - return date{ - year: year, - month: month, - day: day, - } -} - -type Vacation struct { - startDate, endDate date -} - -// GetStart returns a time corresponding to the beginning of the start date in the given timezone. -func (v Vacation) GetStart(timezone *time.Location) time.Time { - if timezone == nil { - timezone = usPacific - } - return time.Date(v.startDate.year, time.Month(v.startDate.month), v.startDate.day, 0, 0, 0, 0, timezone) -} - -// GetEnd returns a time corresponding to the end of the end date in the given timezone -func (v Vacation) GetEnd(timezone *time.Location) time.Time { - if timezone == nil { - timezone = usPacific - } - return time.Date(v.endDate.year, time.Month(v.endDate.month), v.endDate.day, 0, 0, 0, 0, timezone).AddDate(0, 0, 1).Add(-1 * time.Millisecond) -} - -type ReviewerConfig struct { - // timezone controls the timezone for vacation start / end dates. Default: US/Pacific. - timezone *time.Location - - // vacations allows specifying times when new reviews should not be requested of the reviewer. - // Existing PRs will still have reviews re-requested. - // Both startDate and endDate are inclusive. - // Example: taking vacation from 2024-03-28 to 2024-04-02. - // { - // vacations: []Vacation{ - // startDate: newDate(2024, 3, 28), - // endDate: newDate(2024, 4, 2), - // }, - // }, - vacations []Vacation -} - -var ( - usPacific, _ = time.LoadLocation("US/Pacific") - usCentral, _ = time.LoadLocation("US/Central") - usEastern, _ = time.LoadLocation("US/Eastern") - london, _ = time.LoadLocation("Europe/London") - - // This is for the random-assignee rotation. - reviewerRotation = map[string]ReviewerConfig{ - "BBBmau": { - vacations: []Vacation{ - { - startDate: newDate(2025, 4, 7), - endDate: newDate(2025, 4, 11), - }, - }, - }, - "c2thorn": { - vacations: []Vacation{ - { - startDate: newDate(2025, 4, 9), - endDate: newDate(2025, 4, 15), - }, - }, - }, - "hao-nan-li": { - vacations: []Vacation{}, - }, - "melinath": { - vacations: []Vacation{}, - }, - "NickElliot": { - vacations: []Vacation{}, - }, - "rileykarson": { - vacations: []Vacation{ - { - startDate: newDate(2025, 2, 25), - endDate: newDate(2025, 3, 10), - }, - }, - }, - "roaks3": { - vacations: []Vacation{}, - }, - "ScottSuarez": { - vacations: []Vacation{}, - }, - "shuyama1": { - vacations: []Vacation{ - { - startDate: newDate(2025, 5, 23), - endDate: newDate(2025, 5, 30), - }, - }, - }, - "SirGitsalot": { - vacations: []Vacation{ - { - startDate: newDate(2025, 1, 18), - endDate: newDate(2025, 1, 25), - }, - }, - }, - "slevenick": { - vacations: []Vacation{ - { - startDate: newDate(2025, 5, 22), - endDate: newDate(2025, 6, 7), - }, - }, - }, - "trodge": { - vacations: []Vacation{}, - }, - "zli82016": { - vacations: []Vacation{ - { - startDate: newDate(2025, 1, 15), - endDate: newDate(2025, 2, 9), - }, - }, - }, - } - - // This is for new team members who are onboarding - trustedContributors = map[string]struct{}{ - "bbasata": struct{}{}, - "jaylonmcshan03": struct{}{}, - "malhotrasagar2212": struct{}{}, - } -) diff --git a/tools/github-membership/membership_test.go b/tools/github-membership/membership_test.go deleted file mode 100644 index be710b9130f5..000000000000 --- a/tools/github-membership/membership_test.go +++ /dev/null @@ -1,255 +0,0 @@ -/* -* Copyright 2023 Google LLC. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ -package membership - -import ( - "testing" - "time" - - "github.com/google/go-cmp/cmp" -) - -func TestTrustedContributors(t *testing.T) { - for member, _ := range trustedContributors { - if IsCoreReviewer(member) { - t.Fatalf(`%v should not be on reviewerRotation list`, member) - } - } -} - -func TestAvailable(t *testing.T) { - // Double-check that timezones are loadable first. - _, err := time.LoadLocation("US/Eastern") - if err != nil { - t.Fatal(err) - } - _, err = time.LoadLocation("US/Pacific") - if err != nil { - t.Fatal(err) - } - - tests := []struct { - name string - rotation map[string]ReviewerConfig - timeNow time.Time - excludedReviewers []string - want []string - }{ - { - name: "reviewers on vacation start date are excluded", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": { - timezone: time.UTC, - vacations: []Vacation{ - { - startDate: newDate(2024, 3, 29), - endDate: newDate(2024, 4, 2), - }, - }, - }, - }, - timeNow: time.Date(2024, 3, 29, 0, 0, 0, 0, time.UTC), - want: []string{"id1"}, - }, - { - name: "reviewers on vacation end date are excluded", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": { - timezone: time.UTC, - vacations: []Vacation{ - { - startDate: newDate(2024, 3, 29), - endDate: newDate(2024, 4, 2), - }, - }, - }, - }, - timeNow: time.Date(2024, 4, 2, 10, 0, 0, 0, time.UTC), - want: []string{"id1"}, - }, - { - name: "reviewers are included after vacation ends", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": { - timezone: time.UTC, - vacations: []Vacation{ - { - startDate: newDate(2024, 3, 29), - endDate: newDate(2024, 4, 2), - }, - }, - }, - }, - timeNow: time.Date(2024, 4, 3, 0, 0, 0, 0, time.UTC), - want: []string{"id1", "id2"}, - }, - { - name: "reviewers are included before vacation starts", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": { - timezone: time.UTC, - vacations: []Vacation{ - { - startDate: newDate(2024, 3, 29), - endDate: newDate(2024, 4, 2), - }, - }, - }, - }, - timeNow: time.Date(2024, 3, 28, 23, 0, 0, 0, time.UTC), - want: []string{"id1", "id2"}, - }, - { - name: "reviewers are excluded if vacation has not ended in the specified time zone", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": { - vacations: []Vacation{ - { - startDate: newDate(2024, 3, 29), - endDate: newDate(2024, 4, 2), - }, - }, - }, - }, - // it's still 2024-04-02 in Pacific time zone - timeNow: time.Date(2024, 4, 3, 0, 0, 0, 0, usEastern), - want: []string{"id1"}, - }, - { - name: "included before vacations", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": { - vacations: []Vacation{ - { - startDate: newDate(2024, 3, 29), - endDate: newDate(2024, 4, 2), - }, - { - startDate: newDate(2024, 5, 2), - endDate: newDate(2024, 5, 5), - }, - }, - }, - }, - timeNow: time.Date(2024, 3, 1, 0, 0, 0, 0, usPacific), - want: []string{"id1", "id2"}, - }, - { - name: "excluded during first vacation", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": { - vacations: []Vacation{ - { - startDate: newDate(2024, 3, 29), - endDate: newDate(2024, 4, 2), - }, - { - startDate: newDate(2024, 5, 2), - endDate: newDate(2024, 5, 5), - }, - }, - }, - }, - timeNow: time.Date(2024, 4, 1, 0, 0, 0, 0, usPacific), - want: []string{"id1"}, - }, - { - name: "included between vacations", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": { - vacations: []Vacation{ - { - startDate: newDate(2024, 3, 29), - endDate: newDate(2024, 4, 2), - }, - { - startDate: newDate(2024, 5, 2), - endDate: newDate(2024, 5, 5), - }, - }, - }, - }, - timeNow: time.Date(2024, 4, 4, 0, 0, 0, 0, usPacific), - want: []string{"id1", "id2"}, - }, - { - name: "excluded during second vacation", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": { - vacations: []Vacation{ - { - startDate: newDate(2024, 3, 29), - endDate: newDate(2024, 4, 2), - }, - { - startDate: newDate(2024, 5, 2), - endDate: newDate(2024, 5, 5), - }, - }, - }, - }, - timeNow: time.Date(2024, 5, 3, 0, 0, 0, 0, usPacific), - want: []string{"id1"}, - }, - { - name: "included after vacations", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": { - vacations: []Vacation{ - { - startDate: newDate(2024, 3, 29), - endDate: newDate(2024, 4, 2), - }, - { - startDate: newDate(2024, 5, 2), - endDate: newDate(2024, 5, 5), - }, - }, - }, - }, - timeNow: time.Date(2024, 6, 1, 0, 0, 0, 0, usPacific), - want: []string{"id1", "id2"}, - }, - { - name: "explicitly excluded reviewers", - rotation: map[string]ReviewerConfig{ - "id1": {vacations: []Vacation{}}, - "id2": {vacations: []Vacation{}}, - }, - excludedReviewers: []string{"id2"}, - want: []string{"id1"}, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got := available(test.timeNow, test.rotation, test.excludedReviewers) - if diff := cmp.Diff(test.want, got); diff != "" { - t.Errorf("available(%v, %v, %v) got diff: %s", test.timeNow, test.rotation, test.excludedReviewers, diff) - } - }) - } - -} diff --git a/.ci/magician/cloudbuild/community.go b/tools/magician/cloudbuild/community.go similarity index 100% rename from .ci/magician/cloudbuild/community.go rename to tools/magician/cloudbuild/community.go diff --git a/.ci/magician/cloudbuild/constants.go b/tools/magician/cloudbuild/constants.go similarity index 100% rename from .ci/magician/cloudbuild/constants.go rename to tools/magician/cloudbuild/constants.go diff --git a/.ci/magician/cloudbuild/init.go b/tools/magician/cloudbuild/init.go similarity index 100% rename from .ci/magician/cloudbuild/init.go rename to tools/magician/cloudbuild/init.go diff --git a/.ci/magician/cloudstorage/bucket.go b/tools/magician/cloudstorage/bucket.go similarity index 100% rename from .ci/magician/cloudstorage/bucket.go rename to tools/magician/cloudstorage/bucket.go diff --git a/.ci/magician/cloudstorage/init.go b/tools/magician/cloudstorage/init.go similarity index 100% rename from .ci/magician/cloudstorage/init.go rename to tools/magician/cloudstorage/init.go diff --git a/.ci/magician/cmd/check_cassettes.go b/tools/magician/cmd/check_cassettes.go similarity index 100% rename from .ci/magician/cmd/check_cassettes.go rename to tools/magician/cmd/check_cassettes.go diff --git a/.ci/magician/cmd/collect_nightly_test_status.go b/tools/magician/cmd/collect_nightly_test_status.go similarity index 100% rename from .ci/magician/cmd/collect_nightly_test_status.go rename to tools/magician/cmd/collect_nightly_test_status.go diff --git a/.ci/magician/cmd/collect_nightly_test_status_test.go b/tools/magician/cmd/collect_nightly_test_status_test.go similarity index 100% rename from .ci/magician/cmd/collect_nightly_test_status_test.go rename to tools/magician/cmd/collect_nightly_test_status_test.go diff --git a/.ci/magician/cmd/create_test_failure_ticket.go b/tools/magician/cmd/create_test_failure_ticket.go similarity index 100% rename from .ci/magician/cmd/create_test_failure_ticket.go rename to tools/magician/cmd/create_test_failure_ticket.go diff --git a/.ci/magician/cmd/create_test_failure_ticket_test.go b/tools/magician/cmd/create_test_failure_ticket_test.go similarity index 100% rename from .ci/magician/cmd/create_test_failure_ticket_test.go rename to tools/magician/cmd/create_test_failure_ticket_test.go diff --git a/.ci/magician/cmd/delete_branches.go b/tools/magician/cmd/delete_branches.go similarity index 100% rename from .ci/magician/cmd/delete_branches.go rename to tools/magician/cmd/delete_branches.go diff --git a/.ci/magician/cmd/delete_branches_test.go b/tools/magician/cmd/delete_branches_test.go similarity index 100% rename from .ci/magician/cmd/delete_branches_test.go rename to tools/magician/cmd/delete_branches_test.go diff --git a/.ci/magician/cmd/generate_comment.go b/tools/magician/cmd/generate_comment.go similarity index 100% rename from .ci/magician/cmd/generate_comment.go rename to tools/magician/cmd/generate_comment.go diff --git a/.ci/magician/cmd/generate_comment_test.go b/tools/magician/cmd/generate_comment_test.go similarity index 95% rename from .ci/magician/cmd/generate_comment_test.go rename to tools/magician/cmd/generate_comment_test.go index 6cc1eb029b5d..552f689073e9 100644 --- a/.ci/magician/cmd/generate_comment_test.go +++ b/tools/magician/cmd/generate_comment_test.go @@ -83,19 +83,19 @@ func TestExecGenerateComment(t *testing.T) { {"/mock/dir/magic-modules/tools/diff-processor/bin"}, }, "Run": { - {"/mock/dir/magic-modules/.ci/magician", "git", []string{"clone", "-b", "auto-pr-123456", "https://modular-magician:*******@github.com/modular-magician/terraform-provider-google", "/mock/dir/tpg"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "git", []string{"clone", "-b", "auto-pr-123456", "https://modular-magician:*******@github.com/modular-magician/terraform-provider-google", "/mock/dir/tpg"}, map[string]string(nil)}, {"/mock/dir/tpg", "git", []string{"fetch", "origin", "auto-pr-123456-old"}, map[string]string(nil)}, {"/mock/dir/tpg", "git", []string{"checkout", "auto-pr-123456-old"}, map[string]string(nil)}, {"/mock/dir/tpg", "make", []string{"build"}, map[string]string(nil)}, {"/mock/dir/tpg", "git", []string{"checkout", "auto-pr-123456"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "git", []string{"clone", "-b", "auto-pr-123456", "https://modular-magician:*******@github.com/modular-magician/terraform-provider-google-beta", "/mock/dir/tpgb"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "git", []string{"clone", "-b", "auto-pr-123456", "https://modular-magician:*******@github.com/modular-magician/terraform-provider-google-beta", "/mock/dir/tpgb"}, map[string]string(nil)}, {"/mock/dir/tpgb", "git", []string{"fetch", "origin", "auto-pr-123456-old"}, map[string]string(nil)}, {"/mock/dir/tpgb", "git", []string{"checkout", "auto-pr-123456-old"}, map[string]string(nil)}, {"/mock/dir/tpgb", "make", []string{"build"}, map[string]string(nil)}, {"/mock/dir/tpgb", "git", []string{"checkout", "auto-pr-123456"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "git", []string{"clone", "-b", "auto-pr-123456", "https://modular-magician:*******@github.com/modular-magician/terraform-google-conversion", "/mock/dir/tgc"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "git", []string{"clone", "-b", "auto-pr-123456", "https://modular-magician:*******@github.com/modular-magician/terraform-google-conversion", "/mock/dir/tgc"}, map[string]string(nil)}, {"/mock/dir/tgc", "git", []string{"fetch", "origin", "auto-pr-123456-old"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "git", []string{"clone", "-b", "auto-pr-123456", "https://modular-magician:*******@github.com/modular-magician/docs-examples", "/mock/dir/tfoics"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "git", []string{"clone", "-b", "auto-pr-123456", "https://modular-magician:*******@github.com/modular-magician/docs-examples", "/mock/dir/tfoics"}, map[string]string(nil)}, {"/mock/dir/tfoics", "git", []string{"fetch", "origin", "auto-pr-123456-old"}, map[string]string(nil)}, {"/mock/dir/tpg", "git", []string{"diff", "origin/auto-pr-123456-old", "origin/auto-pr-123456", "--shortstat"}, map[string]string(nil)}, {"/mock/dir/tpg", "git", []string{"diff", "origin/auto-pr-123456-old", "origin/auto-pr-123456", "--name-only"}, map[string]string(nil)}, diff --git a/.ci/magician/cmd/generate_downstream.go b/tools/magician/cmd/generate_downstream.go similarity index 100% rename from .ci/magician/cmd/generate_downstream.go rename to tools/magician/cmd/generate_downstream.go diff --git a/.ci/magician/cmd/interfaces.go b/tools/magician/cmd/interfaces.go similarity index 100% rename from .ci/magician/cmd/interfaces.go rename to tools/magician/cmd/interfaces.go diff --git a/.ci/magician/cmd/manage_test_failure_ticket.go b/tools/magician/cmd/manage_test_failure_ticket.go similarity index 100% rename from .ci/magician/cmd/manage_test_failure_ticket.go rename to tools/magician/cmd/manage_test_failure_ticket.go diff --git a/.ci/magician/cmd/membership_checker.go b/tools/magician/cmd/membership_checker.go similarity index 100% rename from .ci/magician/cmd/membership_checker.go rename to tools/magician/cmd/membership_checker.go diff --git a/.ci/magician/cmd/membership_checker_test.go b/tools/magician/cmd/membership_checker_test.go similarity index 100% rename from .ci/magician/cmd/membership_checker_test.go rename to tools/magician/cmd/membership_checker_test.go diff --git a/.ci/magician/cmd/mock_cloudbuild_test.go b/tools/magician/cmd/mock_cloudbuild_test.go similarity index 100% rename from .ci/magician/cmd/mock_cloudbuild_test.go rename to tools/magician/cmd/mock_cloudbuild_test.go diff --git a/.ci/magician/cmd/mock_github_test.go b/tools/magician/cmd/mock_github_test.go similarity index 100% rename from .ci/magician/cmd/mock_github_test.go rename to tools/magician/cmd/mock_github_test.go diff --git a/.ci/magician/cmd/mock_runner_test.go b/tools/magician/cmd/mock_runner_test.go similarity index 90% rename from .ci/magician/cmd/mock_runner_test.go rename to tools/magician/cmd/mock_runner_test.go index 742ca0617dba..0d56d032f459 100644 --- a/.ci/magician/cmd/mock_runner_test.go +++ b/tools/magician/cmd/mock_runner_test.go @@ -65,10 +65,10 @@ func NewMockRunner() MockRunner { return &mockRunner{ calledMethods: make(map[string][]ParameterList), cmdResults: map[string]string{ - "/mock/dir/magic-modules/.ci/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/docs-examples /mock/dir/tfoics] map[]": "", - "/mock/dir/magic-modules/.ci/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/terraform-google-conversion /mock/dir/tgc] map[]": "", - "/mock/dir/magic-modules/.ci/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/terraform-provider-google /mock/dir/tpg] map[]": "", - "/mock/dir/magic-modules/.ci/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/terraform-provider-google-beta /mock/dir/tpgb] map[]": "", + "/mock/dir/magic-modules/tools/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/docs-examples /mock/dir/tfoics] map[]": "", + "/mock/dir/magic-modules/tools/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/terraform-google-conversion /mock/dir/tgc] map[]": "", + "/mock/dir/magic-modules/tools/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/terraform-provider-google /mock/dir/tpg] map[]": "", + "/mock/dir/magic-modules/tools/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/terraform-provider-google-beta /mock/dir/tpgb] map[]": "", "/mock/dir/magic-modules/tools/diff-processor bin/diff-processor [breaking-changes] map[]": "", "/mock/dir/magic-modules/tools/diff-processor make [build] " + sortedEnvString(diffProcessorEnv): "", "/mock/dir/magic-modules/tools/diff-processor bin/diff-processor [schema-diff] map[]": "{\"AddedResources\": [\"google_alloydb_instance\"]}", @@ -90,7 +90,7 @@ func NewMockRunner() MockRunner { "/mock/dir/tpgbold sed [-i.bak s|github.com/hashicorp/terraform-provider-google-beta|google/provider/old|g go.mod] map[]": "", "/mock/dir/tpgbold sed [-i.bak s|github.com/hashicorp/terraform-provider-google-beta|google/provider/old|g go.sum] map[]": "", }, - cwd: "/mock/dir/magic-modules/.ci/magician", + cwd: "/mock/dir/magic-modules/tools/magician", dirStack: list.New(), } } diff --git a/.ci/magician/cmd/reassign_reviewer.go b/tools/magician/cmd/reassign_reviewer.go similarity index 100% rename from .ci/magician/cmd/reassign_reviewer.go rename to tools/magician/cmd/reassign_reviewer.go diff --git a/.ci/magician/cmd/reassign_reviewer_test.go b/tools/magician/cmd/reassign_reviewer_test.go similarity index 100% rename from .ci/magician/cmd/reassign_reviewer_test.go rename to tools/magician/cmd/reassign_reviewer_test.go diff --git a/.ci/magician/cmd/remove_label.go b/tools/magician/cmd/remove_label.go similarity index 100% rename from .ci/magician/cmd/remove_label.go rename to tools/magician/cmd/remove_label.go diff --git a/.ci/magician/cmd/remove_label_test.go b/tools/magician/cmd/remove_label_test.go similarity index 100% rename from .ci/magician/cmd/remove_label_test.go rename to tools/magician/cmd/remove_label_test.go diff --git a/.ci/magician/cmd/request_reviewer.go b/tools/magician/cmd/request_reviewer.go similarity index 100% rename from .ci/magician/cmd/request_reviewer.go rename to tools/magician/cmd/request_reviewer.go diff --git a/.ci/magician/cmd/request_reviewer_test.go b/tools/magician/cmd/request_reviewer_test.go similarity index 100% rename from .ci/magician/cmd/request_reviewer_test.go rename to tools/magician/cmd/request_reviewer_test.go diff --git a/.ci/magician/cmd/request_service_reviewers.go b/tools/magician/cmd/request_service_reviewers.go similarity index 100% rename from .ci/magician/cmd/request_service_reviewers.go rename to tools/magician/cmd/request_service_reviewers.go diff --git a/.ci/magician/cmd/request_service_reviewers_test.go b/tools/magician/cmd/request_service_reviewers_test.go similarity index 100% rename from .ci/magician/cmd/request_service_reviewers_test.go rename to tools/magician/cmd/request_service_reviewers_test.go diff --git a/.ci/magician/cmd/root.go b/tools/magician/cmd/root.go similarity index 100% rename from .ci/magician/cmd/root.go rename to tools/magician/cmd/root.go diff --git a/.ci/magician/cmd/scheduled_pr_reminders.go b/tools/magician/cmd/scheduled_pr_reminders.go similarity index 100% rename from .ci/magician/cmd/scheduled_pr_reminders.go rename to tools/magician/cmd/scheduled_pr_reminders.go diff --git a/.ci/magician/cmd/scheduled_pr_reminders_test.go b/tools/magician/cmd/scheduled_pr_reminders_test.go similarity index 100% rename from .ci/magician/cmd/scheduled_pr_reminders_test.go rename to tools/magician/cmd/scheduled_pr_reminders_test.go diff --git a/.ci/magician/cmd/sync_branch.go b/tools/magician/cmd/sync_branch.go similarity index 100% rename from .ci/magician/cmd/sync_branch.go rename to tools/magician/cmd/sync_branch.go diff --git a/.ci/magician/cmd/templates.go b/tools/magician/cmd/templates.go similarity index 100% rename from .ci/magician/cmd/templates.go rename to tools/magician/cmd/templates.go diff --git a/.ci/magician/cmd/templates/DIFF_COMMENT.md.tmpl b/tools/magician/cmd/templates/DIFF_COMMENT.md.tmpl similarity index 100% rename from .ci/magician/cmd/templates/DIFF_COMMENT.md.tmpl rename to tools/magician/cmd/templates/DIFF_COMMENT.md.tmpl diff --git a/.ci/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_CONTRIBUTOR.md.tmpl b/tools/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_CONTRIBUTOR.md.tmpl similarity index 100% rename from .ci/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_CONTRIBUTOR.md.tmpl rename to tools/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_CONTRIBUTOR.md.tmpl diff --git a/.ci/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_MERGE.md.tmpl b/tools/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_MERGE.md.tmpl similarity index 100% rename from .ci/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_MERGE.md.tmpl rename to tools/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_MERGE.md.tmpl diff --git a/.ci/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_REVIEW.md.tmpl b/tools/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_REVIEW.md.tmpl similarity index 100% rename from .ci/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_REVIEW.md.tmpl rename to tools/magician/cmd/templates/SCHEDULED_PR_WAITING_FOR_REVIEW.md.tmpl diff --git a/.ci/magician/cmd/templates/TEST_FAILURE_ISSUE.md.tmpl b/tools/magician/cmd/templates/TEST_FAILURE_ISSUE.md.tmpl similarity index 100% rename from .ci/magician/cmd/templates/TEST_FAILURE_ISSUE.md.tmpl rename to tools/magician/cmd/templates/TEST_FAILURE_ISSUE.md.tmpl diff --git a/.ci/magician/cmd/templates/vcr/post_replay.tmpl b/tools/magician/cmd/templates/vcr/post_replay.tmpl similarity index 100% rename from .ci/magician/cmd/templates/vcr/post_replay.tmpl rename to tools/magician/cmd/templates/vcr/post_replay.tmpl diff --git a/.ci/magician/cmd/templates/vcr/record_replay.tmpl b/tools/magician/cmd/templates/vcr/record_replay.tmpl similarity index 100% rename from .ci/magician/cmd/templates/vcr/record_replay.tmpl rename to tools/magician/cmd/templates/vcr/record_replay.tmpl diff --git a/.ci/magician/cmd/templates/vcr/vcr_cassettes_update_recording.tmpl b/tools/magician/cmd/templates/vcr/vcr_cassettes_update_recording.tmpl similarity index 100% rename from .ci/magician/cmd/templates/vcr/vcr_cassettes_update_recording.tmpl rename to tools/magician/cmd/templates/vcr/vcr_cassettes_update_recording.tmpl diff --git a/.ci/magician/cmd/templates/vcr/vcr_cassettes_update_replaying.tmpl b/tools/magician/cmd/templates/vcr/vcr_cassettes_update_replaying.tmpl similarity index 100% rename from .ci/magician/cmd/templates/vcr/vcr_cassettes_update_replaying.tmpl rename to tools/magician/cmd/templates/vcr/vcr_cassettes_update_replaying.tmpl diff --git a/.ci/magician/cmd/templates_test.go b/tools/magician/cmd/templates_test.go similarity index 100% rename from .ci/magician/cmd/templates_test.go rename to tools/magician/cmd/templates_test.go diff --git a/.ci/magician/cmd/test_eap_vcr.go b/tools/magician/cmd/test_eap_vcr.go similarity index 100% rename from .ci/magician/cmd/test_eap_vcr.go rename to tools/magician/cmd/test_eap_vcr.go diff --git a/.ci/magician/cmd/test_terraform_vcr.go b/tools/magician/cmd/test_terraform_vcr.go similarity index 100% rename from .ci/magician/cmd/test_terraform_vcr.go rename to tools/magician/cmd/test_terraform_vcr.go diff --git a/.ci/magician/cmd/test_terraform_vcr_test.go b/tools/magician/cmd/test_terraform_vcr_test.go similarity index 100% rename from .ci/magician/cmd/test_terraform_vcr_test.go rename to tools/magician/cmd/test_terraform_vcr_test.go diff --git a/.ci/magician/cmd/test_tgc.go b/tools/magician/cmd/test_tgc.go similarity index 100% rename from .ci/magician/cmd/test_tgc.go rename to tools/magician/cmd/test_tgc.go diff --git a/.ci/magician/cmd/test_tgc_integration.go b/tools/magician/cmd/test_tgc_integration.go similarity index 100% rename from .ci/magician/cmd/test_tgc_integration.go rename to tools/magician/cmd/test_tgc_integration.go diff --git a/.ci/magician/cmd/test_tgc_test.go b/tools/magician/cmd/test_tgc_test.go similarity index 100% rename from .ci/magician/cmd/test_tgc_test.go rename to tools/magician/cmd/test_tgc_test.go diff --git a/.ci/magician/cmd/test_tpg.go b/tools/magician/cmd/test_tpg.go similarity index 100% rename from .ci/magician/cmd/test_tpg.go rename to tools/magician/cmd/test_tpg.go diff --git a/.ci/magician/cmd/test_tpg_test.go b/tools/magician/cmd/test_tpg_test.go similarity index 100% rename from .ci/magician/cmd/test_tpg_test.go rename to tools/magician/cmd/test_tpg_test.go diff --git a/.ci/magician/cmd/vcr_cassette_update.go b/tools/magician/cmd/vcr_cassette_update.go similarity index 100% rename from .ci/magician/cmd/vcr_cassette_update.go rename to tools/magician/cmd/vcr_cassette_update.go diff --git a/.ci/magician/cmd/vcr_cassette_update_test.go b/tools/magician/cmd/vcr_cassette_update_test.go similarity index 73% rename from .ci/magician/cmd/vcr_cassette_update_test.go rename to tools/magician/cmd/vcr_cassette_update_test.go index 0d391e0f5d45..31af44eb410b 100644 --- a/.ci/magician/cmd/vcr_cassette_update_test.go +++ b/tools/magician/cmd/vcr_cassette_update_test.go @@ -313,77 +313,77 @@ func TestExecVCRCassetteUpdate(t *testing.T) { cmdResults: make(map[string]string), expectedCalls: map[string][]ParameterList{ "Run": { - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-m", "-q", "cp", "gs://ci-vcr-cassettes/beta/fixtures/*", "/mock/dir/magic-modules/.ci/magician/cassettes/beta"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/.ci/magician/cassettes/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/main_cassettes_backup/fixtures/"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "git", []string{"clone", "https://hashicorp:token@github.com/hashicorp/terraform-provider-google-beta", "gopath/src/github.com/hashicorp/terraform-provider-google-beta"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "gs://ci-vcr-cassettes/beta/fixtures/*", "/mock/dir/magic-modules/.ci/magician/cassettes/beta"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/.ci/magician/cassettes/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/main_cassettes_backup/fixtures/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "git", []string{"clone", "https://hashicorp:token@github.com/hashicorp/terraform-provider-google-beta", "gopath/src/github.com/hashicorp/terraform-provider-google-beta"}, map[string]string(nil)}, {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"list", "./..."}, map[string]string(nil)}, {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"test", "", "-parallel", "32", "-v", "-run=TestAcc", "-timeout", "240m", "-ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc", "-vet=off"}, map[string]string{ "ACCTEST_PARALLELISM": "32", - "GOOGLE_APPLICATION_CREDENTIALS": "/mock/dir/magic-modules/.ci/magician/sa_key.json", + "GOOGLE_APPLICATION_CREDENTIALS": "/mock/dir/magic-modules/tools/magician/sa_key.json", "GOOGLE_CREDENTIALS": "sa_key", "GOOGLE_TEST_DIRECTORY": "", "SA_KEY": "sa_key", "TF_ACC": "1", "TF_LOG": "DEBUG", - "TF_LOG_PATH_MASK": "/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/%s.log", + "TF_LOG_PATH_MASK": "/mock/dir/magic-modules/tools/magician/testlogs/replaying/beta/%s.log", "TF_LOG_SDK_FRAMEWORK": "INFO", "TF_SCHEMA_PANIC_ON_ERROR": "1", "VCR_MODE": "REPLAYING", - "VCR_PATH": "/mock/dir/magic-modules/.ci/magician/cassettes/beta", + "VCR_PATH": "/mock/dir/magic-modules/tools/magician/cassettes/beta", }}, - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/replaying/"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/replaying/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, }, }, }, { name: "replay failed then record", cmdResults: map[string]string{ - "gopath/src/github.com/hashicorp/terraform-provider-google-beta go [test -parallel 32 -v -run=TestAcc -timeout 240m -ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc -vet=off] map[ACCTEST_PARALLELISM:32 GOOGLE_APPLICATION_CREDENTIALS:/mock/dir/magic-modules/.ci/magician/sa_key.json GOOGLE_CREDENTIALS:sa_key GOOGLE_TEST_DIRECTORY: SA_KEY:sa_key TF_ACC:1 TF_LOG:DEBUG TF_LOG_PATH_MASK:/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/%s.log TF_LOG_SDK_FRAMEWORK:INFO TF_SCHEMA_PANIC_ON_ERROR:1 VCR_MODE:REPLAYING VCR_PATH:/mock/dir/magic-modules/.ci/magician/cassettes/beta]": "--- FAIL: TestAccContainerNodePool_defaultDriverInstallation (590.29s)", - "gopath/src/github.com/hashicorp/terraform-provider-google-beta go [test -parallel 1 -v -run=TestAccContainerNodePool_defaultDriverInstallation$ -timeout 240m -ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc -vet=off] map[ACCTEST_PARALLELISM:1 GOOGLE_APPLICATION_CREDENTIALS:/mock/dir/magic-modules/.ci/magician/sa_key.json GOOGLE_CREDENTIALS:sa_key GOOGLE_TEST_DIRECTORY: SA_KEY:sa_key TF_ACC:1 TF_LOG:DEBUG TF_LOG_PATH_MASK:/mock/dir/magic-modules/.ci/magician/testlogs/recording/beta/%s.log TF_LOG_SDK_FRAMEWORK:INFO TF_SCHEMA_PANIC_ON_ERROR:1 VCR_MODE:RECORDING VCR_PATH:/mock/dir/magic-modules/.ci/magician/cassettes/beta]": "--- PASS: TestAccContainerNodePool_defaultDriverInstallation (590.29s)", + "gopath/src/github.com/hashicorp/terraform-provider-google-beta go [test -parallel 32 -v -run=TestAcc -timeout 240m -ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc -vet=off] map[ACCTEST_PARALLELISM:32 GOOGLE_APPLICATION_CREDENTIALS:/mock/dir/magic-modules/tools/magician/sa_key.json GOOGLE_CREDENTIALS:sa_key GOOGLE_TEST_DIRECTORY: SA_KEY:sa_key TF_ACC:1 TF_LOG:DEBUG TF_LOG_PATH_MASK:/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/%s.log TF_LOG_SDK_FRAMEWORK:INFO TF_SCHEMA_PANIC_ON_ERROR:1 VCR_MODE:REPLAYING VCR_PATH:/mock/dir/magic-modules/.ci/magician/cassettes/beta]": "--- FAIL: TestAccContainerNodePool_defaultDriverInstallation (590.29s)", + "gopath/src/github.com/hashicorp/terraform-provider-google-beta go [test -parallel 1 -v -run=TestAccContainerNodePool_defaultDriverInstallation$ -timeout 240m -ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc -vet=off] map[ACCTEST_PARALLELISM:1 GOOGLE_APPLICATION_CREDENTIALS:/mock/dir/magic-modules/tools/magician/sa_key.json GOOGLE_CREDENTIALS:sa_key GOOGLE_TEST_DIRECTORY: SA_KEY:sa_key TF_ACC:1 TF_LOG:DEBUG TF_LOG_PATH_MASK:/mock/dir/magic-modules/.ci/magician/testlogs/recording/beta/%s.log TF_LOG_SDK_FRAMEWORK:INFO TF_SCHEMA_PANIC_ON_ERROR:1 VCR_MODE:RECORDING VCR_PATH:/mock/dir/magic-modules/.ci/magician/cassettes/beta]": "--- PASS: TestAccContainerNodePool_defaultDriverInstallation (590.29s)", }, expectedCalls: map[string][]ParameterList{ "Run": { // replay - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-m", "-q", "cp", "gs://ci-vcr-cassettes/beta/fixtures/*", "/mock/dir/magic-modules/.ci/magician/cassettes/beta"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/.ci/magician/cassettes/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/main_cassettes_backup/fixtures/"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "git", []string{"clone", "https://hashicorp:token@github.com/hashicorp/terraform-provider-google-beta", "gopath/src/github.com/hashicorp/terraform-provider-google-beta"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "gs://ci-vcr-cassettes/beta/fixtures/*", "/mock/dir/magic-modules/.ci/magician/cassettes/beta"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/.ci/magician/cassettes/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/main_cassettes_backup/fixtures/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "git", []string{"clone", "https://hashicorp:token@github.com/hashicorp/terraform-provider-google-beta", "gopath/src/github.com/hashicorp/terraform-provider-google-beta"}, map[string]string(nil)}, {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"list", "./..."}, map[string]string(nil)}, {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"test", "", "-parallel", "32", "-v", "-run=TestAcc", "-timeout", "240m", "-ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc", "-vet=off"}, map[string]string{ "ACCTEST_PARALLELISM": "32", - "GOOGLE_APPLICATION_CREDENTIALS": "/mock/dir/magic-modules/.ci/magician/sa_key.json", + "GOOGLE_APPLICATION_CREDENTIALS": "/mock/dir/magic-modules/tools/magician/sa_key.json", "GOOGLE_CREDENTIALS": "sa_key", "GOOGLE_TEST_DIRECTORY": "", "SA_KEY": "sa_key", "TF_ACC": "1", "TF_LOG": "DEBUG", - "TF_LOG_PATH_MASK": "/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/%s.log", + "TF_LOG_PATH_MASK": "/mock/dir/magic-modules/tools/magician/testlogs/replaying/beta/%s.log", "TF_LOG_SDK_FRAMEWORK": "INFO", "TF_SCHEMA_PANIC_ON_ERROR": "1", "VCR_MODE": "REPLAYING", - "VCR_PATH": "/mock/dir/magic-modules/.ci/magician/cassettes/beta", + "VCR_PATH": "/mock/dir/magic-modules/tools/magician/cassettes/beta", }}, - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/replaying/"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/replaying/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, // record {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"list", "./..."}, map[string]string(nil)}, {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"test", "", "-parallel", "1", "-v", "-run=TestAccContainerNodePool_defaultDriverInstallation$", "-timeout", "240m", "-ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc", "-vet=off"}, map[string]string{ "ACCTEST_PARALLELISM": "1", - "GOOGLE_APPLICATION_CREDENTIALS": "/mock/dir/magic-modules/.ci/magician/sa_key.json", + "GOOGLE_APPLICATION_CREDENTIALS": "/mock/dir/magic-modules/tools/magician/sa_key.json", "GOOGLE_CREDENTIALS": "sa_key", "GOOGLE_TEST_DIRECTORY": "", "SA_KEY": "sa_key", "TF_ACC": "1", "TF_LOG": "DEBUG", - "TF_LOG_PATH_MASK": "/mock/dir/magic-modules/.ci/magician/testlogs/recording/beta/%s.log", + "TF_LOG_PATH_MASK": "/mock/dir/magic-modules/tools/magician/testlogs/recording/beta/%s.log", "TF_LOG_SDK_FRAMEWORK": "INFO", "TF_SCHEMA_PANIC_ON_ERROR": "1", "VCR_MODE": "RECORDING", - "VCR_PATH": "/mock/dir/magic-modules/.ci/magician/cassettes/beta", + "VCR_PATH": "/mock/dir/magic-modules/tools/magician/cassettes/beta", }}, - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/recording_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/recording/"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/recording/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/.ci/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/.ci/magician/cassettes/beta/*", "gs://ci-vcr-cassettes/beta/fixtures/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/recording_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/recording/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/recording/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/.ci/magician/cassettes/beta/*", "gs://ci-vcr-cassettes/beta/fixtures/"}, map[string]string(nil)}, }, }, }, @@ -393,7 +393,7 @@ func TestExecVCRCassetteUpdate(t *testing.T) { t.Run(tc.name, func(t *testing.T) { rnr := &mockRunner{ calledMethods: make(map[string][]ParameterList), - cwd: "/mock/dir/magic-modules/.ci/magician", + cwd: "/mock/dir/magic-modules/tools/magician", dirStack: list.New(), cmdResults: tc.cmdResults, } diff --git a/.ci/magician/cmd/vcr_merge.go b/tools/magician/cmd/vcr_merge.go similarity index 100% rename from .ci/magician/cmd/vcr_merge.go rename to tools/magician/cmd/vcr_merge.go diff --git a/.ci/magician/cmd/vcr_merge_eap.go b/tools/magician/cmd/vcr_merge_eap.go similarity index 100% rename from .ci/magician/cmd/vcr_merge_eap.go rename to tools/magician/cmd/vcr_merge_eap.go diff --git a/.ci/magician/cmd/vcr_merge_test.go b/tools/magician/cmd/vcr_merge_test.go similarity index 100% rename from .ci/magician/cmd/vcr_merge_test.go rename to tools/magician/cmd/vcr_merge_test.go diff --git a/.ci/magician/cmd/wait_for_commit.go b/tools/magician/cmd/wait_for_commit.go similarity index 100% rename from .ci/magician/cmd/wait_for_commit.go rename to tools/magician/cmd/wait_for_commit.go diff --git a/.ci/magician/cmd/wait_for_commit_test.go b/tools/magician/cmd/wait_for_commit_test.go similarity index 100% rename from .ci/magician/cmd/wait_for_commit_test.go rename to tools/magician/cmd/wait_for_commit_test.go diff --git a/.ci/magician/exec/runner.go b/tools/magician/exec/runner.go similarity index 100% rename from .ci/magician/exec/runner.go rename to tools/magician/exec/runner.go diff --git a/.ci/magician/github/README.md b/tools/magician/github/README.md similarity index 100% rename from .ci/magician/github/README.md rename to tools/magician/github/README.md diff --git a/.ci/magician/github/REVIEWER_ASSIGNMENT_COMMENT.md b/tools/magician/github/REVIEWER_ASSIGNMENT_COMMENT.md similarity index 100% rename from .ci/magician/github/REVIEWER_ASSIGNMENT_COMMENT.md rename to tools/magician/github/REVIEWER_ASSIGNMENT_COMMENT.md diff --git a/.ci/magician/github/get.go b/tools/magician/github/get.go similarity index 100% rename from .ci/magician/github/get.go rename to tools/magician/github/get.go diff --git a/.ci/magician/github/init.go b/tools/magician/github/init.go similarity index 100% rename from .ci/magician/github/init.go rename to tools/magician/github/init.go diff --git a/.ci/magician/github/integration_test.go b/tools/magician/github/integration_test.go similarity index 100% rename from .ci/magician/github/integration_test.go rename to tools/magician/github/integration_test.go diff --git a/.ci/magician/github/interface_conversion.go b/tools/magician/github/interface_conversion.go similarity index 100% rename from .ci/magician/github/interface_conversion.go rename to tools/magician/github/interface_conversion.go diff --git a/.ci/magician/github/membership.go b/tools/magician/github/membership.go similarity index 100% rename from .ci/magician/github/membership.go rename to tools/magician/github/membership.go diff --git a/.ci/magician/github/membership_data.go b/tools/magician/github/membership_data.go similarity index 100% rename from .ci/magician/github/membership_data.go rename to tools/magician/github/membership_data.go diff --git a/.ci/magician/github/membership_test.go b/tools/magician/github/membership_test.go similarity index 100% rename from .ci/magician/github/membership_test.go rename to tools/magician/github/membership_test.go diff --git a/.ci/magician/github/reviewer_assignment.go b/tools/magician/github/reviewer_assignment.go similarity index 100% rename from .ci/magician/github/reviewer_assignment.go rename to tools/magician/github/reviewer_assignment.go diff --git a/.ci/magician/github/reviewer_assignment_test.go b/tools/magician/github/reviewer_assignment_test.go similarity index 100% rename from .ci/magician/github/reviewer_assignment_test.go rename to tools/magician/github/reviewer_assignment_test.go diff --git a/.ci/magician/github/set.go b/tools/magician/github/set.go similarity index 100% rename from .ci/magician/github/set.go rename to tools/magician/github/set.go diff --git a/.ci/magician/go.mod b/tools/magician/go.mod similarity index 100% rename from .ci/magician/go.mod rename to tools/magician/go.mod diff --git a/.ci/magician/go.sum b/tools/magician/go.sum similarity index 100% rename from .ci/magician/go.sum rename to tools/magician/go.sum diff --git a/.ci/magician/main.go b/tools/magician/main.go similarity index 100% rename from .ci/magician/main.go rename to tools/magician/main.go diff --git a/.ci/magician/provider/version.go b/tools/magician/provider/version.go similarity index 100% rename from .ci/magician/provider/version.go rename to tools/magician/provider/version.go diff --git a/.ci/magician/source/repo.go b/tools/magician/source/repo.go similarity index 100% rename from .ci/magician/source/repo.go rename to tools/magician/source/repo.go diff --git a/.ci/magician/teamcity/get.go b/tools/magician/teamcity/get.go similarity index 100% rename from .ci/magician/teamcity/get.go rename to tools/magician/teamcity/get.go diff --git a/.ci/magician/teamcity/init.go b/tools/magician/teamcity/init.go similarity index 100% rename from .ci/magician/teamcity/init.go rename to tools/magician/teamcity/init.go diff --git a/.ci/magician/utility/utils.go b/tools/magician/utility/utils.go similarity index 100% rename from .ci/magician/utility/utils.go rename to tools/magician/utility/utils.go diff --git a/.ci/magician/utility/utils_test.go b/tools/magician/utility/utils_test.go similarity index 100% rename from .ci/magician/utility/utils_test.go rename to tools/magician/utility/utils_test.go diff --git a/.ci/magician/vcr/interfaces.go b/tools/magician/vcr/interfaces.go similarity index 100% rename from .ci/magician/vcr/interfaces.go rename to tools/magician/vcr/interfaces.go diff --git a/.ci/magician/vcr/tester.go b/tools/magician/vcr/tester.go similarity index 100% rename from .ci/magician/vcr/tester.go rename to tools/magician/vcr/tester.go From 7405ab33adc92c040ec5467caf3bb8dd77dbfcae Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Mon, 2 Jun 2025 16:24:56 -0700 Subject: [PATCH 4/4] Replace paths --- tools/magician/cmd/mock_runner_test.go | 40 +++++++++---------- .../magician/cmd/vcr_cassette_update_test.go | 26 ++++++------ tools/magician/go.mod | 2 +- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/tools/magician/cmd/mock_runner_test.go b/tools/magician/cmd/mock_runner_test.go index 0d56d032f459..d90b23601767 100644 --- a/tools/magician/cmd/mock_runner_test.go +++ b/tools/magician/cmd/mock_runner_test.go @@ -69,26 +69,26 @@ func NewMockRunner() MockRunner { "/mock/dir/magic-modules/tools/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/terraform-google-conversion /mock/dir/tgc] map[]": "", "/mock/dir/magic-modules/tools/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/terraform-provider-google /mock/dir/tpg] map[]": "", "/mock/dir/magic-modules/tools/magician git [clone -b auto-pr-123456 https://modular-magician:*******@github.com/modular-magician/terraform-provider-google-beta /mock/dir/tpgb] map[]": "", - "/mock/dir/magic-modules/tools/diff-processor bin/diff-processor [breaking-changes] map[]": "", - "/mock/dir/magic-modules/tools/diff-processor make [build] " + sortedEnvString(diffProcessorEnv): "", - "/mock/dir/magic-modules/tools/diff-processor bin/diff-processor [schema-diff] map[]": "{\"AddedResources\": [\"google_alloydb_instance\"]}", - "/mock/dir/magic-modules/tools/diff-processor bin/diff-processor [detect-missing-tests /mock/dir/tpgb/google-beta/services] map[]": `{"google_folder_access_approval_settings":{"SuggestedTest":"resource \"google_folder_access_approval_settings\" \"primary\" {\n uncovered_field = # value needed\n}","Tests":["a","b","c"]}}`, - "/mock/dir/magic-modules/tools/diff-processor bin/diff-processor [detect-missing-docs /mock/dir/tpgb] map[]": `{"Resource":[],"DataSource":[]}`, - "/mock/dir/tgc git [diff origin/auto-pr-123456-old origin/auto-pr-123456 --shortstat] map[]": " 1 file changed, 10 insertions(+)\n", - "/mock/dir/tgc git [fetch origin auto-pr-123456-old] map[]": "", - "/mock/dir/tfoics git [diff origin/auto-pr-123456-old origin/auto-pr-123456 --shortstat] map[]": "", - "/mock/dir/tfoics git [fetch origin auto-pr-123456-old] map[]": "", - "/mock/dir/tpg git [diff origin/auto-pr-123456-old origin/auto-pr-123456 --shortstat] map[]": " 2 files changed, 40 insertions(+)\n", - "/mock/dir/tpg git [fetch origin auto-pr-123456-old] map[]": "", - "/mock/dir/tpgb find [. -type f -name *.go -exec sed -i.bak s~github.com/hashicorp/terraform-provider-google-beta~google/provider/new~g {} +] map[]": "", - "/mock/dir/tpgb git [diff origin/auto-pr-123456-old origin/auto-pr-123456 --shortstat] map[]": " 2 files changed, 40 insertions(+)\n", - "/mock/dir/tpgb git [fetch origin auto-pr-123456-old] map[]": "", - "/mock/dir/tpgb sed [-i.bak s|github.com/hashicorp/terraform-provider-google-beta|google/provider/new|g go.mod] map[]": "", - "/mock/dir/tpgb sed [-i.bak s|github.com/hashicorp/terraform-provider-google-beta|google/provider/new|g go.sum] map[]": "", - "/mock/dir/tpgbold find [. -type f -name *.go -exec sed -i.bak s~github.com/hashicorp/terraform-provider-google-beta~google/provider/old~g {} +] map[]": "", - "/mock/dir/tpgbold git [checkout origin/auto-pr-123456-old] map[]": "", - "/mock/dir/tpgbold sed [-i.bak s|github.com/hashicorp/terraform-provider-google-beta|google/provider/old|g go.mod] map[]": "", - "/mock/dir/tpgbold sed [-i.bak s|github.com/hashicorp/terraform-provider-google-beta|google/provider/old|g go.sum] map[]": "", + "/mock/dir/magic-modules/tools/diff-processor bin/diff-processor [breaking-changes] map[]": "", + "/mock/dir/magic-modules/tools/diff-processor make [build] " + sortedEnvString(diffProcessorEnv): "", + "/mock/dir/magic-modules/tools/diff-processor bin/diff-processor [schema-diff] map[]": "{\"AddedResources\": [\"google_alloydb_instance\"]}", + "/mock/dir/magic-modules/tools/diff-processor bin/diff-processor [detect-missing-tests /mock/dir/tpgb/google-beta/services] map[]": `{"google_folder_access_approval_settings":{"SuggestedTest":"resource \"google_folder_access_approval_settings\" \"primary\" {\n uncovered_field = # value needed\n}","Tests":["a","b","c"]}}`, + "/mock/dir/magic-modules/tools/diff-processor bin/diff-processor [detect-missing-docs /mock/dir/tpgb] map[]": `{"Resource":[],"DataSource":[]}`, + "/mock/dir/tgc git [diff origin/auto-pr-123456-old origin/auto-pr-123456 --shortstat] map[]": " 1 file changed, 10 insertions(+)\n", + "/mock/dir/tgc git [fetch origin auto-pr-123456-old] map[]": "", + "/mock/dir/tfoics git [diff origin/auto-pr-123456-old origin/auto-pr-123456 --shortstat] map[]": "", + "/mock/dir/tfoics git [fetch origin auto-pr-123456-old] map[]": "", + "/mock/dir/tpg git [diff origin/auto-pr-123456-old origin/auto-pr-123456 --shortstat] map[]": " 2 files changed, 40 insertions(+)\n", + "/mock/dir/tpg git [fetch origin auto-pr-123456-old] map[]": "", + "/mock/dir/tpgb find [. -type f -name *.go -exec sed -i.bak s~github.com/hashicorp/terraform-provider-google-beta~google/provider/new~g {} +] map[]": "", + "/mock/dir/tpgb git [diff origin/auto-pr-123456-old origin/auto-pr-123456 --shortstat] map[]": " 2 files changed, 40 insertions(+)\n", + "/mock/dir/tpgb git [fetch origin auto-pr-123456-old] map[]": "", + "/mock/dir/tpgb sed [-i.bak s|github.com/hashicorp/terraform-provider-google-beta|google/provider/new|g go.mod] map[]": "", + "/mock/dir/tpgb sed [-i.bak s|github.com/hashicorp/terraform-provider-google-beta|google/provider/new|g go.sum] map[]": "", + "/mock/dir/tpgbold find [. -type f -name *.go -exec sed -i.bak s~github.com/hashicorp/terraform-provider-google-beta~google/provider/old~g {} +] map[]": "", + "/mock/dir/tpgbold git [checkout origin/auto-pr-123456-old] map[]": "", + "/mock/dir/tpgbold sed [-i.bak s|github.com/hashicorp/terraform-provider-google-beta|google/provider/old|g go.mod] map[]": "", + "/mock/dir/tpgbold sed [-i.bak s|github.com/hashicorp/terraform-provider-google-beta|google/provider/old|g go.sum] map[]": "", }, cwd: "/mock/dir/magic-modules/tools/magician", dirStack: list.New(), diff --git a/tools/magician/cmd/vcr_cassette_update_test.go b/tools/magician/cmd/vcr_cassette_update_test.go index 31af44eb410b..fdb1448c9763 100644 --- a/tools/magician/cmd/vcr_cassette_update_test.go +++ b/tools/magician/cmd/vcr_cassette_update_test.go @@ -313,8 +313,8 @@ func TestExecVCRCassetteUpdate(t *testing.T) { cmdResults: make(map[string]string), expectedCalls: map[string][]ParameterList{ "Run": { - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "gs://ci-vcr-cassettes/beta/fixtures/*", "/mock/dir/magic-modules/.ci/magician/cassettes/beta"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/.ci/magician/cassettes/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/main_cassettes_backup/fixtures/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "gs://ci-vcr-cassettes/beta/fixtures/*", "/mock/dir/magic-modules/tools/magician/cassettes/beta"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/tools/magician/cassettes/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/main_cassettes_backup/fixtures/"}, map[string]string(nil)}, {"/mock/dir/magic-modules/tools/magician", "git", []string{"clone", "https://hashicorp:token@github.com/hashicorp/terraform-provider-google-beta", "gopath/src/github.com/hashicorp/terraform-provider-google-beta"}, map[string]string(nil)}, {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"list", "./..."}, map[string]string(nil)}, {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"test", "", "-parallel", "32", "-v", "-run=TestAcc", "-timeout", "240m", "-ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc", "-vet=off"}, map[string]string{ @@ -331,22 +331,22 @@ func TestExecVCRCassetteUpdate(t *testing.T) { "VCR_MODE": "REPLAYING", "VCR_PATH": "/mock/dir/magic-modules/tools/magician/cassettes/beta", }}, - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/replaying/"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/tools/magician/testlogs/replaying_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/replaying/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/tools/magician/testlogs/replaying/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, }, }, }, { name: "replay failed then record", cmdResults: map[string]string{ - "gopath/src/github.com/hashicorp/terraform-provider-google-beta go [test -parallel 32 -v -run=TestAcc -timeout 240m -ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc -vet=off] map[ACCTEST_PARALLELISM:32 GOOGLE_APPLICATION_CREDENTIALS:/mock/dir/magic-modules/tools/magician/sa_key.json GOOGLE_CREDENTIALS:sa_key GOOGLE_TEST_DIRECTORY: SA_KEY:sa_key TF_ACC:1 TF_LOG:DEBUG TF_LOG_PATH_MASK:/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/%s.log TF_LOG_SDK_FRAMEWORK:INFO TF_SCHEMA_PANIC_ON_ERROR:1 VCR_MODE:REPLAYING VCR_PATH:/mock/dir/magic-modules/.ci/magician/cassettes/beta]": "--- FAIL: TestAccContainerNodePool_defaultDriverInstallation (590.29s)", - "gopath/src/github.com/hashicorp/terraform-provider-google-beta go [test -parallel 1 -v -run=TestAccContainerNodePool_defaultDriverInstallation$ -timeout 240m -ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc -vet=off] map[ACCTEST_PARALLELISM:1 GOOGLE_APPLICATION_CREDENTIALS:/mock/dir/magic-modules/tools/magician/sa_key.json GOOGLE_CREDENTIALS:sa_key GOOGLE_TEST_DIRECTORY: SA_KEY:sa_key TF_ACC:1 TF_LOG:DEBUG TF_LOG_PATH_MASK:/mock/dir/magic-modules/.ci/magician/testlogs/recording/beta/%s.log TF_LOG_SDK_FRAMEWORK:INFO TF_SCHEMA_PANIC_ON_ERROR:1 VCR_MODE:RECORDING VCR_PATH:/mock/dir/magic-modules/.ci/magician/cassettes/beta]": "--- PASS: TestAccContainerNodePool_defaultDriverInstallation (590.29s)", + "gopath/src/github.com/hashicorp/terraform-provider-google-beta go [test -parallel 32 -v -run=TestAcc -timeout 240m -ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc -vet=off] map[ACCTEST_PARALLELISM:32 GOOGLE_APPLICATION_CREDENTIALS:/mock/dir/magic-modules/tools/magician/sa_key.json GOOGLE_CREDENTIALS:sa_key GOOGLE_TEST_DIRECTORY: SA_KEY:sa_key TF_ACC:1 TF_LOG:DEBUG TF_LOG_PATH_MASK:/mock/dir/magic-modules/tools/magician/testlogs/replaying/beta/%s.log TF_LOG_SDK_FRAMEWORK:INFO TF_SCHEMA_PANIC_ON_ERROR:1 VCR_MODE:REPLAYING VCR_PATH:/mock/dir/magic-modules/tools/magician/cassettes/beta]": "--- FAIL: TestAccContainerNodePool_defaultDriverInstallation (590.29s)", + "gopath/src/github.com/hashicorp/terraform-provider-google-beta go [test -parallel 1 -v -run=TestAccContainerNodePool_defaultDriverInstallation$ -timeout 240m -ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc -vet=off] map[ACCTEST_PARALLELISM:1 GOOGLE_APPLICATION_CREDENTIALS:/mock/dir/magic-modules/tools/magician/sa_key.json GOOGLE_CREDENTIALS:sa_key GOOGLE_TEST_DIRECTORY: SA_KEY:sa_key TF_ACC:1 TF_LOG:DEBUG TF_LOG_PATH_MASK:/mock/dir/magic-modules/tools/magician/testlogs/recording/beta/%s.log TF_LOG_SDK_FRAMEWORK:INFO TF_SCHEMA_PANIC_ON_ERROR:1 VCR_MODE:RECORDING VCR_PATH:/mock/dir/magic-modules/tools/magician/cassettes/beta]": "--- PASS: TestAccContainerNodePool_defaultDriverInstallation (590.29s)", }, expectedCalls: map[string][]ParameterList{ "Run": { // replay - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "gs://ci-vcr-cassettes/beta/fixtures/*", "/mock/dir/magic-modules/.ci/magician/cassettes/beta"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/.ci/magician/cassettes/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/main_cassettes_backup/fixtures/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "gs://ci-vcr-cassettes/beta/fixtures/*", "/mock/dir/magic-modules/tools/magician/cassettes/beta"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/tools/magician/cassettes/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/main_cassettes_backup/fixtures/"}, map[string]string(nil)}, {"/mock/dir/magic-modules/tools/magician", "git", []string{"clone", "https://hashicorp:token@github.com/hashicorp/terraform-provider-google-beta", "gopath/src/github.com/hashicorp/terraform-provider-google-beta"}, map[string]string(nil)}, {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"list", "./..."}, map[string]string(nil)}, {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"test", "", "-parallel", "32", "-v", "-run=TestAcc", "-timeout", "240m", "-ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc", "-vet=off"}, map[string]string{ @@ -363,8 +363,8 @@ func TestExecVCRCassetteUpdate(t *testing.T) { "VCR_MODE": "REPLAYING", "VCR_PATH": "/mock/dir/magic-modules/tools/magician/cassettes/beta", }}, - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/replaying/"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/replaying/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/tools/magician/testlogs/replaying_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/replaying/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/tools/magician/testlogs/replaying/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, // record {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"list", "./..."}, map[string]string(nil)}, {"gopath/src/github.com/hashicorp/terraform-provider-google-beta", "go", []string{"test", "", "-parallel", "1", "-v", "-run=TestAccContainerNodePool_defaultDriverInstallation$", "-timeout", "240m", "-ldflags=-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc", "-vet=off"}, map[string]string{ @@ -381,9 +381,9 @@ func TestExecVCRCassetteUpdate(t *testing.T) { "VCR_MODE": "RECORDING", "VCR_PATH": "/mock/dir/magic-modules/tools/magician/cassettes/beta", }}, - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/recording_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/recording/"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/.ci/magician/testlogs/recording/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, - {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/.ci/magician/cassettes/beta/*", "gs://ci-vcr-cassettes/beta/fixtures/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/tools/magician/testlogs/recording_test.log", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/recording/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-h", "Content-Type:text/plain", "-q", "cp", "-r", "/mock/dir/magic-modules/tools/magician/testlogs/recording/beta/*", "gs://vcr-nightly/beta/2024-07-08/buildID/logs/build-log/"}, map[string]string(nil)}, + {"/mock/dir/magic-modules/tools/magician", "gsutil", []string{"-m", "-q", "cp", "/mock/dir/magic-modules/tools/magician/cassettes/beta/*", "gs://ci-vcr-cassettes/beta/fixtures/"}, map[string]string(nil)}, }, }, }, diff --git a/tools/magician/go.mod b/tools/magician/go.mod index c6e029ad9c04..8414cbfb3180 100644 --- a/tools/magician/go.mod +++ b/tools/magician/go.mod @@ -2,7 +2,7 @@ module magician go 1.23 -replace github.com/GoogleCloudPlatform/magic-modules/tools/issue-labeler => ../../tools/issue-labeler +replace github.com/GoogleCloudPlatform/magic-modules/tools/issue-labeler => ../issue-labeler require ( github.com/GoogleCloudPlatform/magic-modules/tools/issue-labeler v0.0.0-00010101000000-000000000000