Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/src/etos_client/etos/v0/schema/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class RequestSchema(BaseModel):

artifact_id: Optional[str]
artifact_identity: Optional[str]
parent_activity: Optional[str]
test_suite_url: str
dataset: Optional[Union[dict, list]] = {}
execution_space_provider: Optional[str] = "default"
Expand All @@ -38,6 +39,7 @@ def from_args(cls, args: dict) -> "RequestSchema":
return RequestSchema(
artifact_id=args["--identity"],
artifact_identity=args["--identity"],
parent_activity=args["--parent-activity"] or None,
test_suite_url=args["--test-suite"],
dataset=args["--dataset"],
execution_space_provider=args["--execution-space-provider"] or "default",
Expand Down
19 changes: 19 additions & 0 deletions cli/src/etos_client/etos/v0/subcommands/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import sys
import os
import logging
import json
from json import JSONDecodeError
from typing import Optional
import warnings

from etos_client.types.result import Conclusion, Verdict
Expand All @@ -38,6 +41,7 @@ class Start(SubCommand):
-h, --help Show this help message and exit
-i IDENTITY, --identity IDENTITY Artifact created identity purl or ID to execute test suite on.
-s TEST_SUITE, --test-suite TEST_SUITE Test suite execute. Either URL or name.
-p PARENT_ACTIVITY, --parent-activity PARENT_ACTIVITY Activity for the TERCC to link to as the cause of the test execution.
--no-tty This parameter is no longer in use.
-w WORKSPACE, --workspace WORKSPACE Which workspace to do all the work in.
-a ARTIFACT_DIR, --artifact-dir ARTIFACT_DIR Where test artifacts should be stored. Relative to workspace.
Expand All @@ -56,6 +60,18 @@ class Start(SubCommand):
name="start", description="Start an ETOSv0 testrun.", version="v0"
)

def activity_triggered(self, argv: list[str]) -> Optional[str]:
"""Get an activity triggered event ID from environment or arguments."""
if ("-p" not in argv and "--parent-activity" not in argv) and os.getenv(
"EIFFEL_ACTIVITY_TRIGGERED"
) is not None:
try:
actt = json.loads(os.getenv("EIFFEL_ACTIVITY_TRIGGERED", ""))
return actt["meta"]["id"]
except (JSONDecodeError, IndexError):
self.logger.warning("Could not load EIFFEL_ACTIVITY_TRIGGERED from environment due it not being formatted JSON")
return None

def parse_args(self, argv: list[str]) -> dict:
"""Parse arguments for etosctl testrun start."""
if ("-i" not in argv and "--identity" not in argv) and os.getenv("IDENTITY") is not None:
Expand All @@ -64,6 +80,9 @@ def parse_args(self, argv: list[str]) -> dict:
"TEST_SUITE"
) is not None:
argv.extend(["--test-suite", os.getenv("TEST_SUITE", "")])
parent_activity_id = self.activity_triggered(argv)
if parent_activity_id is not None:
argv.extend(["--parent-activity", parent_activity_id])
return super().parse_args(argv)

def run(self, args: dict) -> None:
Expand Down