Skip to content

Commit

Permalink
Merge pull request #12680 from Sawthis/r-tide-2
Browse files Browse the repository at this point in the history
Remove tide from Automated Approver
  • Loading branch information
IwonaLanger authored Feb 14, 2025
2 parents edc048e + ae60674 commit e5449f4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cmd/external-plugins/automated-approver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To identify PRs that must be approved by the tool, Automated Approver evaluates
- PR required labels
- PR changed files

If a PR meets the conditions, the tool checks if the PR tests are finished. The `Tide` context is an exception: the `pending` status for `Tide` is ignored. The tool uses a backoff algorithm for sleep duration between subsequent status checks. A `wait-for-statuses-timeout` flag defines a timeout period while waiting for statuses to finish and reports its state back to GitHub. Once the tests are finished, it checks whether they were successful. Currently, the tool doesn't support optional tests. When all checks and conditions are met, the tool approves the PR.
If a PR meets the conditions, the tool checks if the PR tests are finished. The tool uses a backoff algorithm for sleep duration between subsequent status checks. A `wait-for-statuses-timeout` flag defines a timeout period while waiting for statuses to finish and reports its state back to GitHub. Once the tests are finished, it checks whether they were successful. Currently, the tool doesn't support optional tests. When all checks and conditions are met, the tool approves the PR.

Automated Approver uses the identity of a dedicated GitHub user to approve PRs. Depending on repository configuration, the user must have `write` permission on the repository, must be added to repository collaborators, and as a code owner in the `CODEOWNERS` file.

Expand Down
7 changes: 3 additions & 4 deletions cmd/external-plugins/automated-approver/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ func (hb *HandlerBackend) ReadConfig() error {
}

// checkPrStatuses checks if all statuses are in success state.
// Tide required status check is not taken into account. It will be always pending until PR is ready to merge.
// Timeout limits time waiting for statuses became success.
func (hb *HandlerBackend) checkPrStatuses(ctx context.Context, logger *zap.SugaredLogger, prOrg, prRepo, prHeadSha string, prNumber int) error {
defer logger.Sync()
Expand All @@ -240,8 +239,8 @@ func (hb *HandlerBackend) checkPrStatuses(ctx context.Context, logger *zap.Sugar
logger.Error(gherr.Error())
return gherr
}
// Don't check if pr checks status is success as that means all context are success, even tide context.
// That means a pr was already approved and is ready for merge, because tide context transition to success
// Don't check if pr checks status is success as that means all context are success.
// That means a pr was already approved and is ready for merge.
// when pr is ready for merge.
logger.Debugf("Pull request %d status: %s", prNumber, prStatuses.State)
switch prState := prStatuses.State; prState {
Expand All @@ -252,7 +251,7 @@ func (hb *HandlerBackend) checkPrStatuses(ctx context.Context, logger *zap.Sugar
for _, prStatus := range prStatuses.Statuses {
if prStatus.State == "failure" {
return backoff.Permanent(fmt.Errorf("pull request status check %s failed", prStatus.Context))
} else if prStatus.State == "pending" && prStatus.Context != "tide" {
} else if prStatus.State == "pending" {
statusErr := fmt.Errorf("pull request status check %s is pending", prStatus.Context)
logger.Debug(statusErr.Error())
return statusErr
Expand Down
12 changes: 0 additions & 12 deletions cmd/external-plugins/automated-approver/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ var _ = Describe("automated-approver", func() {
prHeadSha: {
State: github.StatePending,
Statuses: []github.Status{
{
State: github.StatusPending,
Context: "tide",
},
{
State: github.StatusSuccess,
Context: "test1",
Expand Down Expand Up @@ -210,10 +206,6 @@ var _ = Describe("automated-approver", func() {
ghc.CombinedStatuses[oldPrHeadSha] = &github.CombinedStatus{
State: github.StatePending,
Statuses: []github.Status{
{
State: github.StatusPending,
Context: "tide",
},
{
State: github.StatusSuccess,
Context: "test1",
Expand Down Expand Up @@ -253,10 +245,6 @@ var _ = Describe("automated-approver", func() {
prHeadSha: {
State: github.StatePending,
Statuses: []github.Status{
{
State: github.StatusPending,
Context: "tide",
},
{
State: github.StatusFailure,
Context: "test1",
Expand Down
22 changes: 11 additions & 11 deletions pkg/image-url-helper/missing/missing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,31 @@ func TestImageMissing(t *testing.T) {
{
name: "Existing image with tag",
image: createComponentImage(common.Image{
ContainerRegistryURL: "eu.gcr.io/kyma-project",
ContainerRepositoryPath: "tpi",
Name: "k8s-tools",
Version: "20220516-9f87ea89",
ContainerRegistryURL: "europe-docker.pkg.dev/kyma-project",
ContainerRepositoryPath: "prod",
Name: "automated-approver",
Version: "v20250213-8adb8ce9",
SHA: "",
}),
expected: false,
},
{
name: "Existing image with SHA",
image: createComponentImage(common.Image{
ContainerRegistryURL: "eu.gcr.io/kyma-project",
ContainerRepositoryPath: "tpi",
Name: "k8s-tools",
ContainerRegistryURL: "europe-docker.pkg.dev/kyma-project",
ContainerRepositoryPath: "prod",
Name: "automated-approver",
Version: "",
SHA: "02317e1d351951f85b96bef7f058fc40181e3b93ac4109f3f4858a8e36ec0962",
SHA: "1109d8e8187bcf502f0e950af18708030b2ef908907fd33b8b4cd485edcda077",
}),
expected: false,
},
{
name: "Nonexistent image",
image: createComponentImage(common.Image{
ContainerRegistryURL: "eu.gcr.io/kyma-project",
ContainerRepositoryPath: "tpi",
Name: "k8s-tools",
ContainerRegistryURL: "europe-docker.pkg.dev/kyma-project",
ContainerRepositoryPath: "prod",
Name: "automated-approver",
Version: "missing-image",
SHA: "",
}),
Expand Down

0 comments on commit e5449f4

Please sign in to comment.