-
Notifications
You must be signed in to change notification settings - Fork 20
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
Allow goals to receive implementations and listeners #504
Changes from 16 commits
e159fef
a7ea850
28f1b21
dadd8cd
8c5d2ad
e231135
32b80f4
bf30f3c
c9e205a
31ab913
5820ece
685c9cf
9ed4636
a9f3c7c
3ae7609
43d581b
4b36f70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,11 +30,12 @@ import { SdmGoalEvent } from "../../api/goal/SdmGoalEvent"; | |
import { | ||
GoalRootType, | ||
SdmGoalFulfillment, | ||
SdmGoalFulfillmentMethod, | ||
SdmGoalKey, | ||
SdmGoalMessage, | ||
SdmProvenance, | ||
} from "../../api/goal/SdmGoalMessage"; | ||
import { GoalImplementation } from "../../api/goal/support/SdmGoalImplementationMapper"; | ||
import { GoalImplementation } from "../../api/goal/support/GoalImplementationMapper"; | ||
import { | ||
OnAnyRequestedSdmGoal, | ||
OnPushToAnyBranch, | ||
|
@@ -100,7 +101,7 @@ export function goalCorrespondsToSdmGoal(goal: Goal, sdmGoal: SdmGoalKey): boole | |
|
||
export function constructSdmGoalImplementation(gi: GoalImplementation): SdmGoalFulfillment { | ||
return { | ||
method: "SDM fulfill on requested", | ||
method: SdmGoalFulfillmentMethod.Sdm, | ||
name: gi.implementationName, | ||
}; | ||
} | ||
|
@@ -115,8 +116,8 @@ export function constructSdmGoal(ctx: HandlerContext, parameters: { | |
url?: string, | ||
fulfillment?: SdmGoalFulfillment, | ||
}): SdmGoalMessage { | ||
const {goalSet, goal, goalSetId, state, id, providerId, url} = parameters; | ||
const fulfillment = parameters.fulfillment || {method: "other", name: "unspecified"}; | ||
const { goalSet, goal, goalSetId, state, id, providerId, url } = parameters; | ||
const fulfillment = parameters.fulfillment || { method: SdmGoalFulfillmentMethod.Other, name: "unkown" }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spelling: unkown There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. |
||
|
||
if (!id.branch) { | ||
throw new Error(sprintf("Please provide a branch in the RemoteRepoRef %j", parameters)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright © 2018 Atomist, Inc. | ||
* | ||
* 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. | ||
*/ | ||
|
||
import { | ||
logger, | ||
Success, | ||
} from "@atomist/automation-client"; | ||
import { Fingerprint } from "@atomist/automation-client/project/fingerprint/Fingerprint"; | ||
import { | ||
ExecuteGoal, | ||
GoalInvocation, | ||
} from "../../api/goal/GoalInvocation"; | ||
import { FingerprintListener } from "../../api/listener/FingerprintListener"; | ||
import { FingerprinterRegistration } from "../../api/registration/FingerprinterRegistration"; | ||
import { computeFingerprints } from "./computeFingerprints"; | ||
import { createPushImpactListenerInvocation } from "./createPushImpactListenerInvocation"; | ||
import { relevantCodeActions } from "./relevantCodeActions"; | ||
|
||
/** | ||
* Execute fingerprinting and send fingerprints to Atomist | ||
* @param {FingerprinterRegistration} fingerprinters | ||
* @param listeners listeners to fingerprints | ||
*/ | ||
export function executeFingerprinting(fingerprinters: FingerprinterRegistration[], | ||
listeners: FingerprintListener[]): ExecuteGoal { | ||
return async (goalInvocation: GoalInvocation) => { | ||
const { configuration, id, credentials, context } = goalInvocation; | ||
if (fingerprinters.length === 0) { | ||
return Success; | ||
} | ||
|
||
logger.debug("About to fingerprint %j using %d fingerprinters", id, fingerprinters.length); | ||
await configuration.sdm.projectLoader.doWithProject({ credentials, id, readOnly: true }, async project => { | ||
const cri = await createPushImpactListenerInvocation(goalInvocation, project); | ||
const relevantFingerprinters: FingerprinterRegistration[] = await relevantCodeActions(fingerprinters, cri); | ||
logger.info("Will invoke %d eligible fingerprinters of %d to %j", | ||
relevantFingerprinters.length, fingerprinters.length, cri.project.id); | ||
const fingerprints: Fingerprint[] = await computeFingerprints(cri, relevantFingerprinters.map(fp => fp.action)); | ||
await Promise.all(listeners.map(l => | ||
Promise.all(fingerprints.map(fingerprint => l({ | ||
id, | ||
context, | ||
credentials, | ||
addressChannels: cri.addressChannels, | ||
fingerprint, | ||
}))))); | ||
}); | ||
return Success; | ||
}; | ||
} |
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.
does this mean there are no more push tests on implementations? ... or that they aren't used?
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.
no, they are being used and evaluated when we SetOnGoalsOnPush. I added this here again last week which was a mistake.