Skip to content

Commit

Permalink
If using sema4ai-actions 0.7.0 or newer, the results of running an …
Browse files Browse the repository at this point in the history
…action are printed to the terminal.
  • Loading branch information
fabioz committed May 21, 2024
1 parent 8ef7a9f commit f7b0fb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion robocorp-code/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
Unreleased
-----------------------------

- Fixes when running actions:
- Improvements when running actions:
- Logs will show local variables (ROBOT_ROOT is no longer set).
- ROBOT_ARTIFACTS set to a better place for the log.html.
- If using `sema4ai-actions 0.7.0` or newer, the results of running an action
are printed to the terminal.

New in 1.22.2 (2024-05-20)
-----------------------------
Expand Down
14 changes: 12 additions & 2 deletions robocorp-code/src/robocorp_code/robo/launch_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,35 @@ def main():
from tempfile import gettempdir

cli = None
actions = None
try:
from sema4ai import actions
from sema4ai.actions import cli # noqa #type: ignore
except ImportError:
try:
# Backward compatibility
from robocorp.actions import cli # noqa #type: ignore

except ImportError:
pass

if cli is None:
raise # Raise the sema4ai.actions error

dir_path = Path(gettempdir()) / "sema4ai-actions-run"
dir_path = Path(gettempdir()) / "sema4ai-vscode-actions"
dir_path.mkdir(parents=True, exist_ok=True)

store_artifacts_at = create_and_rotate_directories(dir_path, "run-action", 20)
os.environ.pop("ROBOT_ROOT", None)
os.environ["ROBOT_ARTIFACTS"] = store_artifacts_at
return cli.main(sys.argv[1:], exit=True)

args = sys.argv[1:]
if actions is not None:
if actions.version_info >= [0, 7, 0]:
# Only available on newer versions of sema4ai-actions.
args.append("--print-result")

return cli.main(args, exit=True)


if __name__ == "__main__":
Expand Down

0 comments on commit f7b0fb9

Please sign in to comment.