Skip to content

Commit

Permalink
Launch generate comment magician command (#9611)
Browse files Browse the repository at this point in the history
* Use magician for generate comment

* Fix formatting of breaking changes

* Keep diff string empty

* Add missing newline

* Add copyright notices

* Add missing space

* Revert changes from running generate-comment
  • Loading branch information
trodge authored Dec 13, 2023
1 parent a149975 commit 06405ce
Show file tree
Hide file tree
Showing 31 changed files with 456 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .ci/gcb-generate-diffs-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,17 @@ steps:
- $_PR_NUMBER

- name: 'gcr.io/graphite-docker-images/go-plus'
entrypoint: '/workspace/.ci/scripts/go-plus/github-differ/generate_comment.sh'
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
id: diff
secretEnv: ["GITHUB_TOKEN"]
args:
- 'generate-comment'
env:
- BUILD_ID=$BUILD_ID
- PROJECT_ID=$PROJECT_ID
- BUILD_STEP=17
- COMMIT_SHA=$COMMIT_SHA
- PR_NUMBER=$_PR_NUMBER
args:
- $_PR_NUMBER

- name: 'gcr.io/graphite-docker-images/go-plus'
id: tgc-test
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cloudbuild/build_trigger.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cloudbuild

import (
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cloudbuild/community.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cloudbuild

import (
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cloudbuild/constants.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cloudbuild

const PROJECT_ID = "graphite-docker-images"
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cloudbuild/init.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cloudbuild

type Client struct {
Expand Down
16 changes: 14 additions & 2 deletions .ci/magician/cmd/community_checker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
* 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 cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cmd/community_checker_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cmd

import (
Expand Down
27 changes: 22 additions & 5 deletions .ci/magician/cmd/generate_comment.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cmd

import (
Expand Down Expand Up @@ -124,7 +139,9 @@ func execGenerateComment(buildID, projectID, buildStep, commit, prNumber, github
os.Exit(1)
}
}
diffs += "\n" + repoDiffs
if repoDiffs != "" {
diffs += "\n" + repoDiffs
}
}

var showBreakingChangesFailed bool
Expand Down Expand Up @@ -156,7 +173,7 @@ func execGenerateComment(buildID, projectID, buildStep, commit, prNumber, github
fmt.Println("Error computing TPG breaking changes: ", err)
showBreakingChangesFailed = true
}
versionedBreakingChanges[repo.Version] = output
versionedBreakingChanges[repo.Version] = strings.TrimSuffix(output, "\n")
err = addLabels(diffProcessorPath, githubToken, prNumber, r)
if err != nil {
fmt.Println("Error adding TPG labels to PR: ", err)
Expand Down Expand Up @@ -209,7 +226,7 @@ The breaking change detector crashed during execution. This is usually due to th
if diffs == "" {
message += "## Diff report\nYour PR hasn't generated any diffs, but I'll let you know if a future commit does."
} else {
message += "## Diff report\nYour PR generated some diffs in downstreams - here they are.\n" + diffs
message += "## Diff report\nYour PR generated some diffs in downstreams - here they are.\n" + diffs + "\n"
if missingTests != "" {
message += "\n" + missingTests + "\n"
}
Expand Down Expand Up @@ -344,14 +361,14 @@ func combineBreakingChanges(tpgBreaking, tpgbBreaking string) string {
allMessages = append(tpgUnique, tpgbMessages...)
}
if len(allMessages) > 0 {
return `Breaking Change(s) Detected
return `## Breaking Change(s) Detected
The following breaking change(s) were detected within your pull request.
* ` + strings.Join(allMessages, "\n* ") + `
If you believe this detection to be incorrect please raise the concern with your reviewer.
If you intend to make this change you will need to wait for a [major release](https://www.terraform.io/plugin/sdkv2/best-practices/versioning#example-major-number-increments) window.
An ` + "`override-breaking-change`" + `label can be added to allow merging.
An ` + "`override-breaking-change`" + ` label can be added to allow merging.
`
}
return ""
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cmd/generate_comment_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cmd/interfaces.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cmd

import (
Expand Down
16 changes: 14 additions & 2 deletions .ci/magician/cmd/membership_checker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
* 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 cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cmd/membership_checker_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cmd/mock_cloudbuild_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cmd

type mockCloudBuild struct {
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cmd/mock_github_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cmd

import "magician/github"
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cmd/mock_runner_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cmd

import (
Expand Down
16 changes: 14 additions & 2 deletions .ci/magician/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
* 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 cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cmd/test_tgc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cmd

import (
Expand Down
15 changes: 15 additions & 0 deletions .ci/magician/cmd/test_tgc_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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 cmd

import (
Expand Down
Loading

0 comments on commit 06405ce

Please sign in to comment.