-
Notifications
You must be signed in to change notification settings - Fork 289
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
Even More Pipeline Parsing Fixes #2253
Conversation
8b5fe95
to
fef91e3
Compare
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.
LGTM, but I think there's a stray file you didn't intend to commit?
.buildkite/steps/test-go-fmt.sh
Outdated
@@ -10,6 +10,8 @@ fi | |||
|
|||
if [[ $(go mod tidy -v 2> >(wc -c)) != 0 ]]; then # go mod tidy -v outputs to stderr for some reason | |||
echo "The go.mod file is out of sync with the source code" | |||
echo "go mod tidy had output:" | |||
go mod tidy -v |
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.
💜
|
||
case o.Contains("trigger"): | ||
step = make(TriggerStep) | ||
func stepFromMap(o *ordered.MapSA) (Step, error) { |
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!
24a2aa6
to
46492d5
Compare
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.
Thanks for tackling this!
0b9acba
to
4d3a73b
Compare
4d3a73b
to
4746e6a
Compare
internal/pipeline/step.go
Outdated
@@ -29,6 +30,29 @@ type Step interface { | |||
selfInterpolater | |||
} | |||
|
|||
type ScalarStep string |
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.
My feelings about the types here: I kinda want for it so that the types are easy to assemble in order to produce pipelines with Go. "ScalarStep" describes "a shape of data" more than "a type of step", and also overlaps semantic meaning with WaitStep and InputStep. But it's not too hard to use.
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.
yeah, i had this thought as well... the other idea i had was something like
type WaitStep struct {
Scalar string `yaml:"-"`
RemainingFields map[string]any `yaml:",inline"`
}
and then have the marshal return the value of scalar
if it's defined, and a regular marshal if not. is that something that feels better to you?
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.
Yeah sort of. I feel like if someone wants to write WaitStep{}
it should marshal as "wait"
, because that's the kind of step it is. And then when we parse "wait"
we should provide WaitStep{}
, so that there's a canonical representation.
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.
this is updated in a9621be - would love your thoughts!
a3e261f
to
a9621be
Compare
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.
Good stuff!
// In the buildkite pipeline yaml, some step types (broadly, wait steps, input steps and block steps) can be represented | ||
// either by a scalar string (ie "wait") or by a mapping with keys and values and such | ||
// | ||
// This behaviour is difficult to cleanly model in go, which leads to the somewhat odd structure of the structs defined | ||
// in this file - each type (WaitStep, InputStep) has a Scalar field which is set to the scalar value if the step was | ||
// if, during pipeline parsing, the step was represented as a scalar, and is left empty if the step was represented as | ||
// a mapping. In essence, if one of the fields of these structs is filled, the other should be empty. | ||
// | ||
// In reading this file, you may have noticed that I mentioned that there are three types of step that can be represented | ||
// as a scalar, but there are only two structs defined here. This is because the third type, block steps, are represented | ||
// in exactly the same way as input steps, so they can share the same struct. This is liable to change in the future, | ||
// as conceptually they're different types, and it makes sense to have them as different types in go as well. | ||
// | ||
// Also also! The implementations for WaitStep and InputStep **almost**, but not quite identical. This is due to the behaviour | ||
// of marshalling an empty struct into into JSON. For WaitStep, it makes sense that the empty &WaitStep{} struct marshals | ||
// to "wait", but with InputStep, there's no way to tell whether it should be marshalled to "input" or "block", which | ||
// have very different behaviour on the backend. |
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.
Excellent commentary 👏👏
a9621be
to
de460b3
Compare
de460b3
to
07d96f1
Compare
This PR: Fixes two issues in the pipeline parser:
type: "block"
). We should also support these steps.