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

Add the ability to trigger the deployment on changes of the specified paths #1250

Merged
merged 3 commits into from Dec 15, 2020

Conversation

nghialv
Copy link
Member

@nghialv nghialv commented Dec 15, 2020

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #979

Does this PR introduce a user-facing change?:

Add the ability to trigger the deployment on changes of the specified paths

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.69%. This pull request increases coverage by 0.15%.

File Function Base Head Diff
pkg/app/piped/trigger/trigger.go loadDeploymentConfiguration -- 0.00% +0.00%
pkg/model/deployment.go DeploymentStatusesFromStrings -- 0.00% +0.00%
pkg/model/deployment.go DeploymentStatusStrings -- 0.00% +0.00%
pkg/app/piped/trigger/trigger.go isTouchedByChangedFiles 100.00% 91.67% -8.33%
pkg/filematcher/filematcher.go PatternMatcher.MatchesAny 0.00% 100.00% +100.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/app/piped/trigger/trigger.go Trigger.checkApplication 0.00% 0.00% +0.00%
pkg/app/pipectl/cmd/application/add.go newAddCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/add.go add.run 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/application.go NewCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/sync.go newSyncCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/sync.go sync.run 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/sync.go makeStatuses 100.00% -- -100.00%
pkg/app/pipectl/cmd/application/sync.go availableStatuses 100.00% -- -100.00%
pkg/app/pipectl/cmd/deployment/deployment.go NewCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go newWaitStatusCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go waitStatus.run 0.00% -- +-0.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go makeStatuses 100.00% -- -100.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go availableStatuses 100.00% -- -100.00%
pkg/app/piped/trigger/deployment.go Trigger.loadDeploymentConfiguration 0.00% -- +-0.00%

Comment on lines +434 to +440
for _, change := range changes {
matcher, err := filematcher.NewPatternMatcher([]string{change})
if err != nil {
return false, err
}
if matcher.MatchesAny(changedFiles) {
return true, nil
Copy link
Member

Choose a reason for hiding this comment

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

Sorry if I'm dumb but is it needed to perform for loop? We just give all patterns to it, right?

		matcher, err := filematcher.NewPatternMatcher([]string{changes})
		if err != nil {
			return false, err
		}
		if matcher.MatchesAny(changedFiles) {

Copy link
Member Author

Choose a reason for hiding this comment

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

We can give all patterns to filematcher and parse all of them before checking.
But by doing one by one we can have fast-return and reduce the number of unneeded regex parsing.
(In the future we can enable the regex cache too.)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that makes sense! Okay, let's keep it as is.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.69%. This pull request increases coverage by 0.15%.

File Function Base Head Diff
pkg/app/piped/trigger/trigger.go loadDeploymentConfiguration -- 0.00% +0.00%
pkg/model/deployment.go DeploymentStatusesFromStrings -- 0.00% +0.00%
pkg/model/deployment.go DeploymentStatusStrings -- 0.00% +0.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/app/piped/trigger/trigger.go Trigger.checkApplication 0.00% 0.00% +0.00%
pkg/app/piped/trigger/trigger.go isTouchedByChangedFiles 100.00% 91.67% -8.33%
pkg/filematcher/filematcher.go PatternMatcher.MatchesAny 0.00% 100.00% +100.00%
pkg/app/pipectl/cmd/application/add.go newAddCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/add.go add.run 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/application.go NewCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/sync.go newSyncCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/sync.go sync.run 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/sync.go makeStatuses 100.00% -- -100.00%
pkg/app/pipectl/cmd/application/sync.go availableStatuses 100.00% -- -100.00%
pkg/app/pipectl/cmd/deployment/deployment.go NewCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go newWaitStatusCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go waitStatus.run 0.00% -- +-0.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go makeStatuses 100.00% -- -100.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go availableStatuses 100.00% -- -100.00%
pkg/app/piped/trigger/deployment.go Trigger.loadDeploymentConfiguration 0.00% -- +-0.00%

Co-authored-by: Ryo Nakao <ryo@nakao.dev>
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.69%. This pull request increases coverage by 0.15%.

File Function Base Head Diff
pkg/app/piped/trigger/trigger.go loadDeploymentConfiguration -- 0.00% +0.00%
pkg/model/deployment.go DeploymentStatusesFromStrings -- 0.00% +0.00%
pkg/model/deployment.go DeploymentStatusStrings -- 0.00% +0.00%
pkg/app/piped/logpersister/stagelogpersister.go stageLogPersister.flushFromLastCheckpoint 50.00% 61.11% +11.11%
pkg/app/piped/trigger/trigger.go Trigger.checkApplication 0.00% 0.00% +0.00%
pkg/app/piped/trigger/trigger.go isTouchedByChangedFiles 100.00% 91.67% -8.33%
pkg/filematcher/filematcher.go PatternMatcher.MatchesAny 0.00% 100.00% +100.00%
pkg/app/pipectl/cmd/application/add.go newAddCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/add.go add.run 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/application.go NewCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/sync.go newSyncCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/sync.go sync.run 0.00% -- +-0.00%
pkg/app/pipectl/cmd/application/sync.go makeStatuses 100.00% -- -100.00%
pkg/app/pipectl/cmd/application/sync.go availableStatuses 100.00% -- -100.00%
pkg/app/pipectl/cmd/deployment/deployment.go NewCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go newWaitStatusCommand 0.00% -- +-0.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go waitStatus.run 0.00% -- +-0.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go makeStatuses 100.00% -- -100.00%
pkg/app/pipectl/cmd/deployment/waitstatus.go availableStatuses 100.00% -- -100.00%
pkg/app/piped/trigger/deployment.go Trigger.loadDeploymentConfiguration 0.00% -- +-0.00%

@nakabonne
Copy link
Member

/lgtm

@khanhtc1202
Copy link
Member

Thanks 🚀
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by khanhtc1202.

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.

@pipecd-bot pipecd-bot merged commit 3f264b4 into master Dec 15, 2020
@pipecd-bot pipecd-bot deleted the on-changes branch December 15, 2020 05:22
@pipecd-bot pipecd-bot mentioned this pull request Dec 16, 2020
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.

Unable to trigger by the dependent directory
4 participants