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

Build scripts should use buildexpression types. #2774

Merged
merged 6 commits into from
Oct 3, 2023

Conversation

mitchell-as
Copy link
Contributor

@mitchell-as mitchell-as commented Sep 27, 2023

StoryDX-1961 Unify BuildPlanner and Local Order Build Expression types

Initially build scripts and build expressions were developed in parallel. Now they should use common types.

Initially build scripts and build expressions were developed in parallel. Now they should use common types.
@mitchell-as
Copy link
Contributor Author

Test failures are due to nightly failures from what I can tell. Logs seem to indicate success as well as local tests.

@mitchell-as mitchell-as requested a review from MDrakos September 29, 2023 18:23
@mitchell-as mitchell-as marked this pull request as ready for review September 29, 2023 18:23
@mitchell-as
Copy link
Contributor Author

@MDrakos ping. I'd like to land this by the end of the day today.

Comment on lines +251 to +252
platforms=["12345", "67890"],
requirements=[{name="language/python"}]
Copy link
Member

Choose a reason for hiding this comment

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

Was this order messing with the tests? If so then we need to allow for arbitrary order of solve arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is why I filed DX-2221 (Implement a canonical/stable sort for buildscript output.) It doesn't have anything to do with build expressions, just with the order that the build scripts are written in.

In *In `parser:"'in' ':' @@"`
Let *Let `parser:"'let' ':' @@"`
In *In `parser:"'in' ':' @@"`
Expr *buildexpression.BuildExpression
Copy link
Member

Choose a reason for hiding this comment

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

It's not immediately clear to me why we're now embedding the expression within the script but this feels a bit off. Ideally, these two implementations would be separate as well as the code that does the translations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Originally I tried just that. However, I ended up writing a translator between participle-produced Go structs and build expression Go structs. That is very brittle and any changes to the build expression structs would need to be addressed in this package too -- it's one of the problems this ticket is trying to resolve.

One solution is to put participle tags into the build expressions and construct build scripts with that, but I figured build expressions should remain distinct from build scripts.

I found it's easiest to work directly with build expressions and JSON.

Comment on lines +85 to +87
func NewScriptFromBuildExpression(expr *buildexpression.BuildExpression) (*Script, error) {
return &Script{Expr: expr}, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this also create the Script? Is there a potential that a user calling a script method could get an error because the struct only has an expression assigned?

Copy link
Contributor Author

@mitchell-as mitchell-as Oct 3, 2023

Choose a reason for hiding this comment

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

Not yet. Any merges that need to take place will be done before writing to disk. That's how it was before, so I don't believe I've changed anything. There is no risk with this approach, as the participle fields are only used by other constructors.

pkg/platform/runtime/buildexpression/buildexpression.go Outdated Show resolved Hide resolved
@mitchell-as
Copy link
Contributor Author

I will follow up with PB about your question. Until I hear back, I've responded to your initial feedback. Thanks! Let me know if you think I need to change something or add documentation, etc.

@mitchell-as mitchell-as requested a review from MDrakos October 3, 2023 16:57
Build script/build expression equality is suspect at this time.
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.

Looking good, just one very minor thing.

}, script)
}

func TestComplex(t *testing.T) {
// Re-enable when multiple solves are supported in DX-2238.
func NoTestComplex(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Sorry to be nitpicky but can we do this with a t.Skip() for now? It just makes it more explicit imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call!

@mitchell-as mitchell-as merged commit 7b0308d into version/0-42-0-RC1 Oct 3, 2023
6 checks passed
@mitchell-as mitchell-as deleted the mitchell/dx-1961 branch October 3, 2023 19:11
mitchell-as added a commit that referenced this pull request Oct 3, 2023
This reverts commit 7b0308d, reversing
changes made to 30a336c.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants