Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple manual approvals #2802

Merged
merged 46 commits into from
Nov 26, 2021
Merged

Support multiple manual approvals #2802

merged 46 commits into from
Nov 26, 2021

Conversation

ono-max
Copy link
Member

@ono-max ono-max commented Nov 19, 2021

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #1569

Does this PR introduce a user-facing change?:

Support multiple manual approvals

@pipecd-bot
Copy link
Collaborator

GO_LINTER

The following files are not gofmt-ed. By commenting /golinter fmt, the formatted one will be appended to this pull request automatically.

pkg/app/piped/executor/waitapproval/waitapproval.go
--- pkg/app/piped/executor/waitapproval/waitapproval.go.orig
+++ pkg/app/piped/executor/waitapproval/waitapproval.go
@@ -30,9 +30,9 @@
 )
 
 const (
-	approvedByKey    = "ApprovedBy"
-	minApproverNum   = "MinApproverNum"
-	approversKey     = "CurrentApprovers"
+	approvedByKey  = "ApprovedBy"
+	minApproverNum = "MinApproverNum"
+	approversKey   = "CurrentApprovers"
 )
 
 type Executor struct {
pkg/app/piped/executor/waitapproval/waitapproval_test.go
--- pkg/app/piped/executor/waitapproval/waitapproval_test.go.orig
+++ pkg/app/piped/executor/waitapproval/waitapproval_test.go
@@ -18,12 +18,13 @@
 	"context"
 	"testing"
 
+	"github.com/stretchr/testify/assert"
+	"google.golang.org/grpc"
+
 	"github.com/pipe-cd/pipe/pkg/app/api/service/pipedservice"
 	"github.com/pipe-cd/pipe/pkg/app/piped/executor"
 	"github.com/pipe-cd/pipe/pkg/app/piped/metadatastore"
 	"github.com/pipe-cd/pipe/pkg/model"
-	"github.com/stretchr/testify/assert"
-	"google.golang.org/grpc"
 )
 
 func (c *fakeAPIClient) SaveDeploymentMetadata(ctx context.Context, req *pipedservice.SaveDeploymentMetadataRequest, opts ...grpc.CallOption) (*pipedservice.SaveDeploymentMetadataResponse, error) {
pkg/config/deployment.go
--- pkg/config/deployment.go.orig
+++ pkg/config/deployment.go
@@ -365,9 +365,9 @@
 type WaitApprovalStageOptions struct {
 	// The maximum length of time to wait before giving up.
 	// Defaults to 6h.
-	Timeout   Duration `json:"timeout"`
-	Approvers []string `json:"approvers"`
-	MinApproverNum int `json:"minApproverNum"`
+	Timeout        Duration `json:"timeout"`
+	Approvers      []string `json:"approvers"`
+	MinApproverNum int      `json:"minApproverNum"`
 }
 
 // AnalysisStageOptions contains all configurable values for a K8S_ANALYSIS stage.

Copy link
Collaborator

@pipecd-bot pipecd-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GO_LINTER

Some issues were detected while linting go source files in your changes.

pkg/app/piped/executor/waitapproval/waitapproval.go Outdated Show resolved Hide resolved
pkg/app/piped/executor/waitapproval/waitapproval_test.go Outdated Show resolved Hide resolved
pkg/app/piped/executor/waitapproval/waitapproval_test.go Outdated Show resolved Hide resolved
pkg/app/piped/executor/waitapproval/waitapproval_test.go Outdated Show resolved Hide resolved
pkg/app/piped/executor/waitapproval/waitapproval_test.go Outdated Show resolved Hide resolved
@pipecd-bot
Copy link
Collaborator

GO_LINTER

The following files are not gofmt-ed. By commenting /golinter fmt, the formatted one will be appended to this pull request automatically.

pkg/app/piped/executor/waitapproval/waitapproval.go
--- pkg/app/piped/executor/waitapproval/waitapproval.go.orig
+++ pkg/app/piped/executor/waitapproval/waitapproval.go
@@ -30,9 +30,9 @@
 )
 
 const (
-	approvedByKey    = "ApprovedBy"
-	minApproverNum   = "MinApproverNum"
-	approversKey     = "CurrentApprovers"
+	approvedByKey  = "ApprovedBy"
+	minApproverNum = "MinApproverNum"
+	approversKey   = "CurrentApprovers"
 )
 
 type Executor struct {
pkg/app/piped/executor/waitapproval/waitapproval_test.go
--- pkg/app/piped/executor/waitapproval/waitapproval_test.go.orig
+++ pkg/app/piped/executor/waitapproval/waitapproval_test.go
@@ -18,12 +18,13 @@
 	"context"
 	"testing"
 
+	"github.com/stretchr/testify/assert"
+	"google.golang.org/grpc"
+
 	"github.com/pipe-cd/pipe/pkg/app/api/service/pipedservice"
 	"github.com/pipe-cd/pipe/pkg/app/piped/executor"
 	"github.com/pipe-cd/pipe/pkg/app/piped/metadatastore"
 	"github.com/pipe-cd/pipe/pkg/model"
-	"github.com/stretchr/testify/assert"
-	"google.golang.org/grpc"
 )
 
 func (c *fakeAPIClient) SaveDeploymentMetadata(_ context.Context, req *pipedservice.SaveDeploymentMetadataRequest, _ ...grpc.CallOption) (*pipedservice.SaveDeploymentMetadataResponse, error) {

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.88%. This pull request decreases coverage by -0.03%.

File Function Base Head Diff
pkg/app/piped/executor/waitapproval/waitapproval.go Register -- 66.67% +66.67%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.Execute -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.checkApproval -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.reportApproved -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.reportRequiringApproval -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.getMentionedAccounts -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.validateApproverNum -- 86.36% +86.36%

@pipecd-bot
Copy link
Collaborator

GO_LINTER

The following files are not gofmt-ed. By commenting /golinter fmt, the formatted one will be appended to this pull request automatically.

pkg/app/piped/executor/waitapproval/waitapproval_test.go
--- pkg/app/piped/executor/waitapproval/waitapproval_test.go.orig
+++ pkg/app/piped/executor/waitapproval/waitapproval_test.go
@@ -18,12 +18,13 @@
 	"context"
 	"testing"
 
+	"github.com/stretchr/testify/assert"
+	"google.golang.org/grpc"
+
 	"github.com/pipe-cd/pipe/pkg/app/api/service/pipedservice"
 	"github.com/pipe-cd/pipe/pkg/app/piped/executor"
 	"github.com/pipe-cd/pipe/pkg/app/piped/metadatastore"
 	"github.com/pipe-cd/pipe/pkg/model"
-	"github.com/stretchr/testify/assert"
-	"google.golang.org/grpc"
 )
 
 type fakeLogPersister struct{}
@@ -67,7 +68,6 @@
 	c.stages[req.StageId] = md
 	return &pipedservice.SaveStageMetadataResponse{}, nil
 }
-
 
 func TestValidateApproverNum(t *testing.T) {
 	ac := &fakeAPIClient{

@pipecd-bot
Copy link
Collaborator

GO_LINTER

The following files are not gofmt-ed. By commenting /golinter fmt, the formatted one will be appended to this pull request automatically.

pkg/app/piped/executor/waitapproval/waitapproval_test.go
--- pkg/app/piped/executor/waitapproval/waitapproval_test.go.orig
+++ pkg/app/piped/executor/waitapproval/waitapproval_test.go
@@ -18,12 +18,13 @@
 	"context"
 	"testing"
 
+	"github.com/stretchr/testify/assert"
+	"google.golang.org/grpc"
+
 	"github.com/pipe-cd/pipe/pkg/app/api/service/pipedservice"
 	"github.com/pipe-cd/pipe/pkg/app/piped/executor"
 	"github.com/pipe-cd/pipe/pkg/app/piped/metadatastore"
 	"github.com/pipe-cd/pipe/pkg/model"
-	"github.com/stretchr/testify/assert"
-	"google.golang.org/grpc"
 )
 
 type fakeLogPersister struct{}

@ono-max
Copy link
Member Author

ono-max commented Nov 19, 2021

/golinter fmt

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.88%. This pull request decreases coverage by -0.03%.

File Function Base Head Diff
pkg/app/piped/executor/waitapproval/waitapproval.go Register -- 66.67% +66.67%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.Execute -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.checkApproval -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.reportApproved -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.reportRequiringApproval -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.getMentionedAccounts -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.validateApproverNum -- 86.36% +86.36%

@ono-max
Copy link
Member Author

ono-max commented Nov 19, 2021

@nghialv

Updated 👍
However, I could not implement only the line breaks among your suggestion. It would be great if you advise me.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.84%. This pull request decreases coverage by -0.07%.

File Function Base Head Diff
pkg/app/piped/executor/waitapproval/waitapproval.go Register -- 66.67% +66.67%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.Execute -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.checkApproval -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.reportApproved -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.reportRequiringApproval -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.getMentionedAccounts -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.validateApproverNum -- 100.00% +100.00%

@nghialv
Copy link
Member

nghialv commented Nov 19, 2021

Thank you. Let me check it now.

Co-authored-by: Le Van Nghia <nghialv2607@gmail.com>
@pipecd-bot
Copy link
Collaborator

GO_LINTER

The golinter build is completed with FAILURE. The build will be triggered again when you push any other commits. Or you can trigger it manually by /golinter trigger command right now.

You can check the build log from here.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.96%. This pull request increases coverage by 0.05%.

File Function Base Head Diff
pkg/app/piped/executor/waitapproval/waitapproval.go Register -- 66.67% +66.67%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.Execute -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.checkApproval -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.reportApproved -- 75.00% +75.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.reportRequiringApproval -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.getMentionedAccounts -- 42.86% +42.86%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.validateApproverNum -- 75.00% +75.00%
pkg/config/deployment.go WaitApprovalStageOptions.Validate -- 100.00% +100.00%

ono-max and others added 2 commits November 26, 2021 17:54
Co-authored-by: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com>
@pipecd-bot
Copy link
Collaborator

GO_LINTER

The golinter build is completed with FAILURE. The build will be triggered again when you push any other commits. Or you can trigger it manually by /golinter trigger command right now.

You can check the build log from here.

@pipecd-bot
Copy link
Collaborator

GO_LINTER

The golinter build is completed with FAILURE. The build will be triggered again when you push any other commits. Or you can trigger it manually by /golinter trigger command right now.

You can check the build log from here.

Co-authored-by: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com>
@pipecd-bot
Copy link
Collaborator

GO_LINTER

The golinter build is completed with FAILURE. The build will be triggered again when you push any other commits. Or you can trigger it manually by /golinter trigger command right now.

You can check the build log from here.

@pipecd-bot
Copy link
Collaborator

GO_LINTER

The golinter build is completed with FAILURE. The build will be triggered again when you push any other commits. Or you can trigger it manually by /golinter trigger command right now.

You can check the build log from here.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.97%. This pull request increases coverage by 0.06%.

File Function Base Head Diff
pkg/app/piped/executor/waitapproval/waitapproval.go Register -- 66.67% +66.67%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.Execute -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.checkApproval -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.reportApproved -- 75.00% +75.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.reportRequiringApproval -- 0.00% +0.00%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.getMentionedAccounts -- 42.86% +42.86%
pkg/app/piped/executor/waitapproval/waitapproval.go Executor.validateApproverNum -- 75.00% +75.00%
pkg/config/deployment.go WaitApprovalStageOptions.Validate -- 100.00% +100.00%
pkg/config/deployment.go GenericDeploymentSpec.Validate 56.25% 57.89% +1.64%

@khanhtc1202
Copy link
Member

/golinter trigger

@khanhtc1202
Copy link
Member

Nice work, lets go with this 🚀
/lgtm

@nghialv
Copy link
Member

nghialv commented Nov 26, 2021

Nice.
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by nghialv.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@nakabonne
Copy link
Member

Holy cow! It blew my mind definitely!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support mutiple manual approvals
5 participants