Skip to content

add a --wait flag#234

Closed
cnolanminich wants to merge 31 commits intomainfrom
add-wait-param
Closed

add a --wait flag#234
cnolanminich wants to merge 31 commits intomainfrom
add-wait-param

Conversation

@cnolanminich
Copy link
Contributor

@cnolanminich cnolanminich commented Aug 11, 2025

Adds support to dagster-cloud-actions/utils/run for the --wait flag (which was the only parameter not supported by the GitHub action that was in the dagster-cloud job launch. This way, if the action is used as part of a CI workload, the CI can wait until that Dagster job is complete (common for example with dbt slim CI setups)

Test plan

  • Added new unit tests to mock the run output for a sigle-line output (--wait flag not present or false on the github action) and multi-line (when --wait is present).
  • Deployed to the add-wait-param tag for the dagster-cloud-action package in GitHub and tested in hooli to validate that it works on a real invocation with both wait: true and wait not specified (the default).

I didn't add support for --interval but I have uncommitted code that adds it, I just didn't do so here because it's untested. Happy to push that up for completeness

@cnolanminich cnolanminich requested a review from Copilot August 11, 2025 20:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a --wait flag feature to enable synchronous waiting for Dagster jobs to complete, supporting CI processes that need to wait for job completion before proceeding.

  • Adds a new wait input parameter to action configurations with appropriate descriptions
  • Implements conditional logic to pass the --wait flag to the underlying Dagster CLI command
  • Provides proper parameter forwarding between action layers

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
actions/utils/run/action.yml Adds the wait input parameter definition with default value and description
actions/launch_job/action.yml Adds the wait input parameter and forwards it to the utils/run action
src/run.sh Implements the conditional logic to append --wait flag based on the input parameter

src/run.sh Outdated
--tags "${INPUT_TAGS_JSON}" \
--config-json "${INPUT_CONFIG_JSON}"
--config-json "${INPUT_CONFIG_JSON}" \
$(if [ "$(echo "${INPUT_WAIT}" | tr '[:upper:]' '[:lower:]')" = "true" ]; then echo "--wait"; fi)
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

The condition logic is overly complex with nested quotes and command substitution. Consider simplifying to: $([ "${INPUT_WAIT,,}" = "true" ] && echo "--wait") or use a case statement for better readability.

Suggested change
$(if [ "$(echo "${INPUT_WAIT}" | tr '[:upper:]' '[:lower:]')" = "true" ]; then echo "--wait"; fi)
$([ "${INPUT_WAIT,,}" = "true" ] && echo "--wait")

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Aug 11, 2025

Your pull request is automatically being deployed to Dagster Cloud.

Location Status Link Updated
from_gh_action View in Cloud Aug 18, 2025 at 08:59 PM (UTC)

- Add wait input to launch_job and utils/run actions
- Modify run.sh to conditionally include --wait flag
- Add debug output to troubleshoot wait functionality
- Support various boolean input formats (true, 1, yes, on)
This reverts commit 674e513.
- Add debug output to troubleshoot command execution
- Handle different output formats from dagster-cloud CLI when --wait is used
- Extract run ID from status messages like 'Run <id> is in progress'
- Fix GITHUB_OUTPUT format issue
- Test run script without wait flag (default behavior)
- Test run script with wait flag enabled (multi-line output)
- Test various truthy values for wait parameter
- Test backwards compatibility when INPUT_WAIT is not set
- Maintain original test for backwards compatibility
- Handle extraction of run ID from both single line and multi-line outputs
- Make run ID regex more flexible to handle both UUIDs and test strings
- Change from strict 36-char UUID pattern to more permissive alphanumeric pattern
- Allows tests to pass with mock data like 'some-run' while still working with real UUIDs
@cnolanminich
Copy link
Contributor Author

Tested with both the wait: true and wait removed (existing behavior) and added tests. Also tested on https://github.com/dagster-io/hooli-data-eng-pipelines/pull/186/files to make sure it worked as expected on both wait: true and no wait specified.

@cnolanminich cnolanminich marked this pull request as ready for review August 13, 2025 13:32
@cnolanminich cnolanminich requested a review from gibsondan August 13, 2025 13:33
Copy link
Member

@gibsondan gibsondan left a comment

Choose a reason for hiding this comment

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

nice!

src/run.sh Outdated
Comment on lines 27 to 31
--repository "${INPUT_REPOSITORY_NAME}" \
--job "${INPUT_JOB_NAME}" \
--tags "${INPUT_TAGS_JSON}" \
--config-json "${INPUT_CONFIG_JSON}"
--config-json "${INPUT_CONFIG_JSON}" \
${wait_flag} 2>&1
Copy link
Member

Choose a reason for hiding this comment

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

does this stream out the output to the github action logs while the command is running? Just thinking of runs that take a while, would be nice to get that live feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gibsondan great suggestion! I added the interval and the streaming the log output -- can't test it since I can't release a new version now -- do you want me to request access to test end-to-end before this would get released?


# Add interval flag if set
if [ -n "${interval_flag}" ]; then
cmd_args+=(${interval_flag}) # This will split --interval and the value
Copy link

Choose a reason for hiding this comment

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

There's a potential issue with how the interval flag is being added to the command arguments array. The unquoted ${interval_flag} will undergo word splitting by the shell, which could cause problems if the interval value contains spaces or special characters.

Consider either:

  1. Keeping it quoted to preserve it as a single element:

    cmd_args+=("${interval_flag}")
  2. Or if the intention is to split --interval and its value into separate array elements, explicitly handle that:

    if [ -n "${INPUT_INTERVAL}" ]; then
        cmd_args+=("--interval" "${INPUT_INTERVAL}")
    fi

The second approach is likely more robust for command-line argument handling.

Suggested change
cmd_args+=(${interval_flag}) # This will split --interval and the value
if [ -n "${INPUT_INTERVAL}" ]; then
cmd_args+=("--interval" "${INPUT_INTERVAL}")
fi

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

@cnolanminich
Copy link
Contributor Author

closing in favor of #235

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