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

Fix checkout/init change summaries #3496

Merged
merged 18 commits into from
Sep 20, 2024
Merged

Fix checkout/init change summaries #3496

merged 18 commits into from
Sep 20, 2024

Conversation

Naatan
Copy link
Member

@Naatan Naatan commented Sep 18, 2024

BugDX-3039 Sub-dependencies number is the same for all dependencies when checkout the project

Ran into several issues in fixing this:

  • Too many artifacts were being associated with an ingredient
  • Checkout/init summaries were not filtering out common dependencies
  • Common runtime dep calculation was plain broken
  • Once above was fixed; Languages were not getting dependency counts as they were considered "common deps"
  • Testing with buildplans was painful because slice ordering was inconsistent

@Naatan Naatan changed the base branch from master to version/0-46-0-RC1 September 18, 2024 21:21
@Naatan Naatan requested a review from MDrakos September 19, 2024 16:36
MDrakos
MDrakos previously approved these changes Sep 19, 2024
Copy link
Member

@MDrakos MDrakos left a comment

Choose a reason for hiding this comment

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

My comments and questions are all nits

@@ -45,7 +68,7 @@ func Unmarshal(data []byte) (*BuildPlan, error) {
}

func (b *BuildPlan) Marshal() ([]byte, error) {
return json.Marshal(b.raw)
return json.MarshalIndent(b.raw, "", " ")
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this has an effect on parsing, but MarshalIndent is for a more readable output. Was this for debugging and do we want to keep it?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was indeed for debugging, but I figured it would be worth keeping. It'll be useful if we're doing proxy debugging. And the extra whitespace really doesn't have a noticeable effect on performance.

@@ -212,7 +214,7 @@ func (b *BuildPlan) sanityCheck() error {
// Ensure all artifacts have an associated ingredient
// If this fails either the API is bugged or the hydrate logic is bugged
for _, a := range b.Artifacts() {
if len(a.Ingredients) == 0 {
if raw.IsStateToolMimeType(a.MimeType) && len(a.Ingredients) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

We're only concerned with state tool artifacts having ingredients now?

Copy link
Member Author

Choose a reason for hiding this comment

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

They're the only type of artifact that is guaranteed to have an ingredient, so the only thing we can reasonably validate.

Comment on lines 36 to 56
// Sort buildplan slices to ensure consistency, because the API does not guarantee a consistent ordering
sort.Slice(b.raw.Sources, func(i, j int) bool { return b.raw.Sources[i].NodeID < b.raw.Sources[j].NodeID })
sort.Slice(b.raw.Steps, func(i, j int) bool { return b.raw.Steps[i].StepID < b.raw.Steps[j].StepID })
sort.Slice(b.raw.Artifacts, func(i, j int) bool { return b.raw.Artifacts[i].NodeID < b.raw.Artifacts[j].NodeID })
sort.Slice(b.raw.Terminals, func(i, j int) bool { return b.raw.Terminals[i].Tag < b.raw.Terminals[j].Tag })
sort.Slice(b.raw.ResolvedRequirements, func(i, j int) bool {
return b.raw.ResolvedRequirements[i].Source < b.raw.ResolvedRequirements[j].Source
})
for _, t := range b.raw.Terminals {
sort.Slice(t.NodeIDs, func(i, j int) bool { return t.NodeIDs[i] < t.NodeIDs[j] })
}
for _, a := range b.raw.Artifacts {
sort.Slice(a.RuntimeDependencies, func(i, j int) bool { return a.RuntimeDependencies[i] < a.RuntimeDependencies[j] })
}
for _, step := range b.raw.Steps {
sort.Slice(step.Inputs, func(i, j int) bool { return step.Inputs[i].Tag < step.Inputs[j].Tag })
sort.Slice(step.Outputs, func(i, j int) bool { return step.Outputs[i] < step.Outputs[j] })
for _, input := range step.Inputs {
sort.Slice(input.NodeIDs, func(i, j int) bool { return input.NodeIDs[i] < input.NodeIDs[j] })
}
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: Might be nice to have this in a method similar to how you have b.cleanup() above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call!

artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001"}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002"}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003"}
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001", MimeType: types.XArtifactMimeType}
Copy link
Member

Choose a reason for hiding this comment

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

I added these mime types when I was trying to filter on them. Are they still needed?

@Naatan Naatan merged commit 948ebeb into version/0-46-0-RC1 Sep 20, 2024
7 of 8 checks passed
@Naatan Naatan deleted the nathan/DX-3039 branch September 20, 2024 17:11
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.

2 participants