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

feat: Invoking a sub-command from an operation workflow #2792

Conversation

didier-wenzek
Copy link
Contributor

@didier-wenzek didier-wenzek commented Mar 19, 2024

Proposed changes

  • Reference documentation for workflow sub-command execution
  • Trigger a sub-command and await its completion
  • Pass arguments to a sub-command
  • Inject sub-command outcome in the invoking command state
  • Give the ability to use a script to compute the sub-command init state.
  • Logging a sub-command in the same log file as the invoking command

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Follow-up tasks

Copy link
Contributor

github-actions bot commented Mar 20, 2024

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
432 0 3 432 100 0s

Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 40.16393% with 365 lines in your changes are missing coverage. Please review.

Project coverage is 76.3%. Comparing base (fc1da52) to head (25ca6e6).
Report is 5 commits behind head on main.

Additional details and impacted files
Files Coverage Δ
crates/common/mqtt_channel/src/topics.rs 86.2% <100.0%> (+0.3%) ⬆️
crates/core/tedge_api/src/commands.rs 86.8% <100.0%> (-0.2%) ⬇️
crates/core/tedge_api/src/lib.rs 100.0% <100.0%> (ø)
...s/core/tedge_agent/src/operation_file_cache/mod.rs 0.0% <0.0%> (ø)
crates/core/tedge_api/src/workflow/error.rs 0.0% <0.0%> (ø)
crates/core/tedge_api/src/workflow/on_disk.rs 40.9% <0.0%> (+3.4%) ⬆️
crates/core/tedge_api/src/mqtt_topics.rs 87.5% <87.5%> (-0.1%) ⬇️
crates/core/tedge_api/src/workflow/mod.rs 60.1% <0.0%> (-6.8%) ⬇️
crates/core/tedge_api/src/workflow/supervisor.rs 56.3% <34.6%> (-7.2%) ⬇️
crates/core/tedge_api/src/workflow/toml_config.rs 74.4% <0.0%> (-3.8%) ⬇️
... and 3 more

... and 4 files with indirect coverage changes

docs/src/references/agent/operation-workflow.md Outdated Show resolved Hide resolved
/// A set of values to be injected/extracted into/from a [GenericCommandState]
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
#[serde(try_from = "Option<Value>")]
pub enum StateExcerpt {
Copy link
Contributor

Choose a reason for hiding this comment

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

Some unit tests for the conversions to/from this struct would be good.

Copy link
Contributor

Choose a reason for hiding this comment

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

You seem to have missed this. Can be added in a follow-up PR as well, to avoid blocking this one.

crates/core/tedge_api/src/workflow/state.rs Show resolved Hide resolved
didier-wenzek and others added 22 commits April 25, 2024 09:34
- A super-command can trigger a sub-command defined by another workflow
- Data can be injected from the current super-command state payload into
  the sub-command init payload.
- Data can be injected back from the successful sub-command payload into
  the super-command current state payload.

Signed-off-by: Didier Wenzek <[email protected]>
AwaitHandlers will also be used to await the completion of a subcommand.

Signed-off-by: Didier Wenzek <[email protected]>
Extracting a value from a command state will be required for the next
which is to extract data from a command state and to inject this excerpt
into a sub-command state.

Signed-off-by: Didier Wenzek <[email protected]>
…kflow

The word *command* is easily confused with *script*.

Signed-off-by: Didier Wenzek <[email protected]>
Signed-off-by: Didier Wenzek <[email protected]>
Signed-off-by: Reuben Miller <[email protected]>
@didier-wenzek didier-wenzek force-pushed the feat/trigger-a-workflow-from-a-workflow branch from d6aef9a to 25ca6e6 Compare April 25, 2024 08:02
@didier-wenzek didier-wenzek added this pull request to the merge queue Apr 25, 2024
Merged via the queue into thin-edge:main with commit d5478ce Apr 25, 2024
32 checks passed
@didier-wenzek didier-wenzek deleted the feat/trigger-a-workflow-from-a-workflow branch April 25, 2024 08:54
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.

4 participants