-
Notifications
You must be signed in to change notification settings - Fork 990
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
Defer evaluation of a step's DisplayName until its condition is evaluated. #2313
Conversation
Congrats on one of your very first PRs as part of the runtime team 👏 Very clear issue descriptions also 👏 👏 👏 |
Thanks! I spent a couple hours trying to devise a unit test for this given our unit testing framework and had to give up. Thomas and I both looked at it. As best as I can tell, there's no great way in our unit testing framework to exercise this code path without extensive mocking -- that is, mocking to the point where you're not really proving anything meaningful. |
child PR: #2318
if (_didFullyEvaluateDisplayName || !string.IsNullOrEmpty(Action.DisplayName)) | ||
{ | ||
return false; | ||
return true; |
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 a subtle change in behavior, but fortunately there weren't many existing callers (mainly just unit tests) and even fewer existing callers that even bothered checking the return value
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.
The return value is IsDisplayNameSet
, and the out var says IsUpdated[JustNow]
.
Why do we need both? 🤔 Is it to avoid setting it again in StepsRunner.TryUpdateDisplayName()
?
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.
Consider code that invokes EvaluateDisplayName
multiple times and updates the TimelineRecord
based on whether the call "succeeded" or not.
Example:
if (EvaluateDisplayName(this.ExecutionContext.ExpressionValues, this.ExecutionContext))
{
this.ExecutionContext.UpdateTimelineRecordDisplayName(this.DisplayName);
}
.
.
.
if (EvaluateDisplayName(this.ExecutionContext.ExpressionValues, this.ExecutionContext))
{
this.ExecutionContext.UpdateTimelineRecordDisplayName(this.DisplayName);
}
Which TimelineRecord
update is accurate and which one is (at best) redundant?
Name = "action", | ||
Id = actionId, | ||
DisplayName = explicitDisplayName, | ||
DisplayNameToken = new BasicExpressionToken(null, null, null, "matrix.node"), |
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 this unit test, we're setting both DisplayName
and DisplayNameToken
.
… interface IStep (#2374)
// can make reasonable guarantees that they won't throw an exception. | ||
try | ||
{ | ||
if (this.Stage == ActionRunStage.Main && EvaluateDisplayName(this.ExecutionContext.ExpressionValues, this.ExecutionContext, out updated)) |
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.
Add a comment to clarify why we only attempt this on Stage == ActionRunStage.Main
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.
Its been a while but I believe a job consists of the following stages
- Job started
- We try to evaluate all display names here
- PreJobSteps
- No contexts have changed from the above, so no need to retry if we couldn't fully expand
- Main Steps
- Context may now have changed, lets update the display names before we start the steps
- Post Job Steps
- Name should have already been fully expanded, no need to try again.
- Job complete
- Nothing to do, job is done don't evaluate display names
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.
Thank 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.
LGTM
…::TryUpdateDisplayName
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
…ated. (actions#2313) * Defer evaluation of a step's DisplayName until its condition is evaluated. * Formalize TryUpdateDisplayName and EvaluateDisplayName as members of interface `IStep` (actions#2374)
…ated. (actions#2313) * Defer evaluation of a step's DisplayName until its condition is evaluated. * Formalize TryUpdateDisplayName and EvaluateDisplayName as members of interface `IStep` (actions#2374)
Proposed fix for #2309
This fix relocates the logic for expanding a step's display name.
In the previous implementation, the display name was evaluated as part of step execution. It was therefore possible for display names to remain unevaluated for steps that ended up being skipped.
With this change, we now evaluate the display name right before we evaluate the step's condition.
In this way, the display name gets updated even if the condition check results in the step being skipped.
Workflow used to Test
source: https://github.com/bbq-beets/jww3-2022a/blob/main/.github/workflows/verify-fix-2309.yml
Before
After