-
Notifications
You must be signed in to change notification settings - Fork 13
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
Use buildplanner ImpactReport endpoint to show change summary. #3419
Conversation
mitchell-as
commented
Jul 29, 2024
•
edited by github-actions
bot
Loading
edited by github-actions
bot
DX-2955 Our change summary and cve summary use the buildplanner ImpactReport |
The ImpactReport sometimes has issues resolving one or both buildplans, so fall back on the old comparison if necessary.
319ad24
to
c79d6c0
Compare
Commits are not guaranteed to belong to projects yet (they could be local).
136db12
to
8d7542c
Compare
BeforeExpr []byte | ||
AfterExpr []byte |
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 cannot use commit IDs because at this time they must be publicly attached to the project. Local commit IDs will not work. I've filed PB-5177 for this.
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.
In addition to flagged code, I think this should also be updating this code here:
cli/internal/runbits/cves/cves.go
Line 43 in dd0c713
changeset := newBuildPlan.DiffArtifacts(oldBuildPlan, false) |
I'd also expect the DiffArtifacts()
function to be dropped as part of this PR.
// Fetch the impact report. | ||
beforeExpr, err := json.Marshal(oldCommit.BuildScript()) | ||
if err != nil { | ||
return errs.Wrap(err, "Unable to marshal old buildexpression") | ||
} | ||
|
||
afterExpr, err := json.Marshal(newCommit.BuildScript()) | ||
if err != nil { | ||
return errs.Wrap(err, "Unable to marshal buildexpression") | ||
} | ||
bpm := buildplanner.NewBuildPlannerModel(prime.Auth()) | ||
params := &buildplanner.ImpactReportParams{ | ||
Owner: prime.Project().Owner(), | ||
Project: prime.Project().Name(), | ||
BeforeExpr: beforeExpr, | ||
AfterExpr: afterExpr, | ||
} | ||
report, err := bpm.ImpactReport(params) | ||
if err != nil { | ||
return errs.Wrap(err, "Failed to fetch impact report") | ||
} |
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.
Can we add a model function for this that abstracts all of this away? We'll be doing the same thing in cves.go.
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've also changed the change and cve reports to accept an impact report so it's only computed once.
continue | ||
} | ||
|
||
if i.Before == nil { |
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.
May as well pair this up with the identical conditional on line 64.
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 would, but they're not identical 😱
9ae9268
to
7319be3
Compare
…ully utilized.
7319be3
to
0368182
Compare
Test failures are a mix of known issues and timeouts. They are not caused by this PR. |
type ImpactReportParams struct { | ||
Owner string | ||
Project string | ||
Before buildScripter |
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.
Using *buildplanner.Commit
would result in an import cycle.
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.
Assuming there isn't an import cycle with buildscripts you could pass in the buildscript instead? It looks like that's all you're accessing on the commit.
I'd like to find a way to address this without interfaces if we can find a feasible solution.
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.
Looking good! I think we're almost there.
internal/runbits/cves/cves.go
Outdated
if !c.prime.Auth().Authenticated() || len(ingredients) == 0 { | ||
logging.Debug("Skipping CVE reporting") | ||
return nil |
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.
Can we put the auth check at the top and the len()
check here? For the len check we don't need a debug entry.
This is pretty nitpicky I realize but it feels wrong to me to have both fire the same debug log, and especially for there not being any ingredients it doesn't seem worth logging at all.
|
||
buildPlan := newCommit.BuildPlan() | ||
|
||
func OutputChangeSummary(out output.Outputer, report *response.ImpactReportResult, rtCommit *buildplanner.Commit) { |
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 looks like we only use rtCommit
to retrieve the buildplan, so we should just pass the buildplan here.
type ImpactReportParams struct { | ||
Owner string | ||
Project string | ||
Before buildScripter |
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.
Assuming there isn't an import cycle with buildscripts you could pass in the buildscript instead? It looks like that's all you're accessing on the commit.
I'd like to find a way to address this without interfaces if we can find a feasible solution.
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.
Nice work!