-
Notifications
You must be signed in to change notification settings - Fork 170
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
fix: subscribed-scm-notifications should respect the event types and allow PR job of upstream pipeline #3095
Conversation
p.subscribedScmUrlsWithActions.forEach(subscribedScmUriWithAction => { | ||
const { scmUri: subscribedScmUri, actions: subscribedActions } = subscribedScmUriWithAction; | ||
|
||
if (pipelinesOnCommitBranch[0].scmUri === subscribedScmUri) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should check length of arr when selecting index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these lines should be sufficient to ensure that pipelinesOnCommitBranch
at least is a length of 1.
screwdriver/plugins/webhooks/helper.js
Lines 367 to 369 in c3d7ce4
if (pipelinesOnCommitBranch.length === 0) { | |
return currentRepoPipelines; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I have also added a comment that the subsequent block will only proceed when pipelinesOnCommitBranch
is a length of at least 1.
screwdriver/plugins/webhooks/helper.js
Lines 371 to 372 in c3d7ce4
// process the pipelinesWithSubscribedRepos only when the pipelinesOnCommitBranch is not empty | |
// pipelinesOnCommitBranch has the information to determine the triggering event of downstream subscribing repo |
if (uriTrimmer(scmConfig.scmUri) !== uriTrimmer(p.scmUri)) { | ||
subscribedConfigSha = sha; | ||
|
||
try { | ||
sha = await pipelineFactory.scm.getCommitSha({ | ||
configPipelineSha = await pipelineFactory.scm.getCommitSha({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configPipelineSha
is not defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is initialized
screwdriver/plugins/webhooks/helper.js
Line 497 in c3d7ce4
let configPipelineSha = ''; |
if (pipelinesOnCommitBranch.length === 0) { | ||
return currentRepoPipelines; | ||
} | ||
|
||
// process the pipelinesWithSubscribedRepos only when the pipelinesOnCommitBranch is not empty | ||
// pipelinesOnCommitBranch has the information to determine the triggering event of downstream subscribing repo | ||
pipelinesWithSubscribedRepos.forEach(p => { | ||
if (!Array.isArray(p.subscribedScmUrlsWithActions)) { | ||
return; | ||
} | ||
p.subscribedScmUrlsWithActions.forEach(subscribedScmUriWithAction => { | ||
const { scmUri: subscribedScmUri, actions: subscribedActions } = subscribedScmUriWithAction; | ||
|
||
if (pipelinesOnCommitBranch[0].scmUri === subscribedScmUri) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could probably refactor the loops into a function and return the filteredPipelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think as it stands, there is no reusable purpose for this section that can bring a benefit of putting into a function. So I would propose to keep it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments
@pritamstyz4ever - responded to your comments. |
branch: Promise.resolve('master') | ||
}) | ||
]); | ||
const pipelineMock2 = _.cloneDeep(pipelineMock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can write a simple deep clone instead of adding the entire lodash pkg I think
@@ -93,6 +93,7 @@ | |||
"js-yaml": "^3.14.1", | |||
"jsonwebtoken": "^9.0.0", | |||
"license-checker": "^25.0.1", | |||
"lodash": "^4.17.21", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used only in tests, move to dev-dependencies
Context
The feature of subscribed-scm-notifications is defective as such that:
With the current implementation, job A is triggered even during the commit event of
git@github.com:supra08/functional-workflow.git
.Objective
The fix includes:
License
I confirm that this contribution is made under a BSD license and that I have the authority necessary to make this contribution on behalf of its copyright owner.