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

Check all functions with workflow.Context as first parameter #1215

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

ndtretyak
Copy link
Contributor

Instead of checking only arguments of RegisterWorkflow consider all functions like func (workflow.Context, ...) ... as workflow definitions (or functions called from workflows).

Closes #1207

@ndtretyak ndtretyak requested a review from a team as a code owner August 29, 2023 07:07
@CLAassistant
Copy link

CLAassistant commented Aug 29, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cretz
Copy link
Member

cretz commented Aug 29, 2023

Nice, thanks! May need to sign CLA (sorry if CLA thing is acting up).

Can you show an example of the CLI output for:

func MyWorkflow(workflow.Context) error {
    doSomething()
}

func doSomething() {
  doSomethingElse()
}

func doSomethingElse() {
  time.Now()
}

I want to make sure that this still shows the tree, though I'm sure it does.

@ndtretyak
Copy link
Contributor Author

Well, I should have tried to run the CLI myself. It turned out that workflow.Context belongs to go.temporal.io/sdk/internal rather than go.temporal.io/sdk/workflow. But in unit tests this is not the case.

After adding an additional check for the internal package I got the following graph

go.temporal.io/sdk/contrib/tools/workflowcheck/workflow/testdata/src/a.MyWorkflow is non-deterministic, reason: calls non-deterministic function go.temporal.io/sdk/contrib/tools/workflowcheck/workflow/testdata/src/a.doSomething
  go.temporal.io/sdk/contrib/tools/workflowcheck/workflow/testdata/src/a.doSomething is non-deterministic, reason: calls non-deterministic function go.temporal.io/sdk/contrib/tools/workflowcheck/workflow/testdata/src/a.doSomethingElse
    go.temporal.io/sdk/contrib/tools/workflowcheck/workflow/testdata/src/a.doSomethingElse is non-deterministic, reason: calls non-deterministic function time.Now
      time.Now is non-deterministic, reason: declared non-deterministic

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Looks great to me! Will let @Quinn-With-Two-Ns take a look.

@Quinn-With-Two-Ns
Copy link
Contributor

LGTM makes more sense for it to work this way to me

@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit 9345e81 into temporalio:master Aug 30, 2023
6 checks passed
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.

Handle interfaces in workflowcheck
4 participants