Skip to content

feat: add cloud workflows quickstart - #2120

Merged
gcf-merge-on-green[bot] merged 6 commits into
masterfrom
grant_workflows_quickstart
Jan 8, 2021
Merged

gcf-merge-on-green[bot] merged 6 commits into
masterfrom
grant_workflows_quickstart

Conversation

@grant

@grant grant commented Dec 30, 2020 •

Copy link
Copy Markdown
Contributor

Inits canonical Cloud Workflows API quickstart sample.

  • Adds a README for new folder, workflows/quickstart
  • This sample...
    • Executes the Cloud Workflows quickstart (myfirstworkflow) using the Workflows client library
    • Awaits the results with exponential backoff
    • Includes test
      • GOOGLE_CLOUD_PROJECT=my-project npm test

Example test result:

  Cloud Workflows Quickstart Tests
Created execution: projects/392236462496/locations/us-central1/workflows/myFirstWorkflow/executions/685a01f4-3cae-4dcb-b0b4-c2965f95fc1a
Poll every second for result...
- Waiting for results...
Execution finished with state: SUCCEEDED
["Wednesday","Wednesday Night Wars","Wednesday 13","Wednesday Addams","Wednesday Campanella","Wednesdayite","Wednesday Martin","Wednesday Campanella discography","Wednesday Night Hockey (American TV program)","Wednesday Morning, 3 A.M."]
    ✓ should execute the quickstart (2196ms)


  1 passing (2s)

CC: @KrisBraun

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
@grant grant self-assigned this Dec 30, 2020
@grant
grant requested a review from fhinkel as a code owner December 30, 2020 22:47
@snippet-bot

snippet-bot Bot commented Dec 30, 2020 •

Copy link
Copy Markdown

Here is the summary of changes.

You added 2 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Dec 30, 2020
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Dec 30, 2020
@grant

grant commented Dec 31, 2020

Copy link
Copy Markdown
Contributor Author

CI failures are unrelated.

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
@grant
grant force-pushed the grant_workflows_quickstart branch from 35010c4 to 46aa63f Compare January 8, 2021 16:43
@grant
grant requested a review from grayside January 8, 2021 16:44
@grant

grant commented Jan 8, 2021 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review @grayside. I've addressed your comments. PTAL again.

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
@grant

grant commented Jan 8, 2021

Copy link
Copy Markdown
Contributor Author

run/system-package failure is unrelated.

// Execute workflow
try {
const createExecutionRes = await client.createExecution({
parent: client.workflowPath(projectId, location, workflow),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: save parent as a variable

@grant grant Jan 8, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's no reason to add a new variable/const, as the expression is not reused.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Right, but it may be more readable split apart. Preference is up to you.

Suggested change
parent: client.workflowPath(projectId, location, workflow),
const parent = client.workflowPath(projectId, location, workflow);
const createExecutionRes = await client.createExecution({parent});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it could be argued either way. Less variables on the stack / in autocompletion results one way.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since this is a quickstart the emphasis is not on readability to the same degree as a snippet, however the (often forgotten) rubric guideline is to avoid nesting complex initialization logic inside objects.

Comment thread workflows/quickstart/index.js Resolved
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

@grant grant left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, replied to comments with updated code.

// Execute workflow
try {
const createExecutionRes = await client.createExecution({
parent: client.workflowPath(projectId, location, workflow),

@grant grant Jan 8, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's no reason to add a new variable/const, as the expression is not reused.

Comment thread workflows/quickstart/index.js Resolved
@grant
grant requested a review from averikitsch January 8, 2021 19:37
@grant grant added the automerge Merge the pull request once unit tests and other checks pass. label Jan 8, 2021
@grant

grant commented Jan 8, 2021

Copy link
Copy Markdown
Contributor Author

Can an admin merge this PR?

@ace-n looks like there's a flaky Functions test.

@ace-n ace-n added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 8, 2021
@ace-n

ace-n commented Jan 8, 2021

Copy link
Copy Markdown
Contributor

I'll try re-running the tests for now, and merge if they continue to be flaky.

@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 8, 2021
@gcf-merge-on-green
gcf-merge-on-green Bot merged commit ebad45a into master Jan 8, 2021
@gcf-merge-on-green gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jan 8, 2021
@ace-n
ace-n deleted the grant_workflows_quickstart branch January 8, 2021 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants