artefacts-cli 0.7.0__tar.gz → 0.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. artefacts_cli-0.7.2/CHANGELOG.md +68 -0
  2. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/PKG-INFO +4 -2
  3. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/README.md +1 -1
  4. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/app.py +90 -50
  5. artefacts_cli-0.7.2/artefacts/cli/app_containers.py +165 -0
  6. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/containers/docker.py +5 -1
  7. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/ros2.py +98 -14
  8. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/utils.py +15 -1
  9. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/utils_ros.py +21 -15
  10. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/version.py +2 -2
  11. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts_cli.egg-info/PKG-INFO +4 -2
  12. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts_cli.egg-info/SOURCES.txt +2 -0
  13. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts_cli.egg-info/requires.txt +1 -0
  14. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/pyproject.toml +2 -0
  15. artefacts_cli-0.7.2/tests/cli/test_app_containers.py +36 -0
  16. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/cli/test_cli.py +20 -20
  17. artefacts_cli-0.7.2/tests/cli/test_ros2.py +84 -0
  18. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/cli/test_utils.py +15 -1
  19. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/conftest.py +6 -0
  20. artefacts_cli-0.7.2/tests/fixtures/bad_launch_test.py +0 -0
  21. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/fixtures/warp.yaml +19 -0
  22. artefacts_cli-0.7.0/artefacts/cli/app_containers.py +0 -99
  23. artefacts_cli-0.7.0/tests/cli/test_app_containers.py +0 -53
  24. artefacts_cli-0.7.0/tests/cli/test_ros2.py +0 -41
  25. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/README_INTERNAL.md +0 -0
  26. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/__init__.py +0 -0
  27. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/__init__.py +0 -0
  28. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/bagparser.py +0 -0
  29. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/constants.py +0 -0
  30. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/containers/__init__.py +0 -0
  31. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/containers/utils.py +0 -0
  32. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/errors.py +0 -0
  33. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/logger.py +0 -0
  34. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/other.py +0 -0
  35. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/parameters.py +0 -0
  36. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/cli/ros1.py +0 -0
  37. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts/wrappers/artefacts_ros1_meta.launch +0 -0
  38. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts.yaml +0 -0
  39. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts_cli.egg-info/dependency_links.txt +0 -0
  40. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts_cli.egg-info/entry_points.txt +0 -0
  41. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/artefacts_cli.egg-info/top_level.txt +0 -0
  42. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/bin/release +0 -0
  43. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/test_run_remote.yaml +0 -0
  44. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/CMakeLists.txt +0 -0
  45. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/launch/test_meta.launch +0 -0
  46. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/launch/test_turtle.launch +0 -0
  47. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/launch/turtle_odometry.launch +0 -0
  48. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/package.xml +0 -0
  49. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/setup.py +0 -0
  50. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/src/TestTurtle.py +0 -0
  51. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/src/__init__.py +0 -0
  52. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/src/turtle_odom.py +0 -0
  53. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/src/turtle_post_process.py +0 -0
  54. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/src/turtle_trajectory.py +0 -0
  55. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim1/ros_workspace/src/turtle_odometry/test/viz_turtle_odom.xml +0 -0
  56. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim2/launch_turtle.py +0 -0
  57. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/infra-tests/turtlesim2/sample_node.py +0 -0
  58. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/pytest.ini +0 -0
  59. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/setup.cfg +0 -0
  60. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/__init__.py +0 -0
  61. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/cli/__init__.py +0 -0
  62. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/cli/containers/__init__.py +0 -0
  63. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/cli/containers/test_utils.py +0 -0
  64. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/cli/test_config_validation.py +0 -0
  65. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/cli/test_other.py +0 -0
  66. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/cli/test_parameters.py +0 -0
  67. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/cli/test_ros1.py +0 -0
  68. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/cli/test_warp.py +0 -0
  69. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/fixtures/artefacts_deprecated.yaml +0 -0
  70. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/fixtures/artefacts_ros1.yaml +0 -0
  71. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/fixtures/warp-env-param.yaml +0 -0
  72. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/test_config_validation.py +0 -0
  73. {artefacts_cli-0.7.0 → artefacts_cli-0.7.2}/tests/utils/docker_mock.py +0 -0
@@ -0,0 +1,68 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ - Run in containers with only an artefacts.yaml configuration file. No need to
13
+ write a Dockerfile in many standard situations.
14
+
15
+ ### Changed
16
+
17
+ - New logging messages and format.
18
+
19
+
20
+ ## [0.7.2] - 2025-03-19
21
+
22
+ ### Fixed
23
+
24
+ - Fixed error handling (bug from misuse of Click's `ClickException`).
25
+
26
+ ### Changed
27
+
28
+ - Improved error handling and messages.
29
+
30
+
31
+ ## [0.7.1] - 2025-03-14
32
+
33
+ ### Added
34
+
35
+ - Partial CHANGELOG with information on the day we start SemVer and the current
36
+ 0.7.0. More detail to come inbetween, but we will focus on the future.
37
+
38
+ ### Changed
39
+
40
+ - Replace Ruff shield for the original Black one.
41
+
42
+
43
+ ## [0.7.0] - 2025-02-25
44
+
45
+ ### Added
46
+
47
+ - Default upload directory to automatically include output from the Artefacts
48
+ toolkit.
49
+
50
+ ### Changed
51
+
52
+ - Always rebuild container images before run. These incremental rebuilds avoid
53
+ existing confusion when running an updated code base without rebuilding.
54
+ - Separate CD workflow from PyPi publication testing: For reusability and
55
+ direct invocation.
56
+
57
+
58
+ ## [0.5.8] - 2024-08-19
59
+
60
+ ### Added
61
+
62
+ - Beginning of semantic versioning.
63
+ - Local metrics errors do not block publication of results.
64
+ - Introduction of Black formatting.
65
+
66
+ [unreleased]: https://github.com/art-e-fact/artefacts-client/compare/0.7.0...HEAD
67
+ [0.7.0]: https://github.com/art-e-fact/artefacts-client/releases/tag/0.7.0
68
+ [0.5.8]: https://github.com/art-e-fact/artefacts-client/releases/tag/0.5.8
@@ -1,14 +1,16 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: artefacts_cli
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Author-email: FD <fabian@artefacts.com>, AGC <alejandro@artefacts.com>, TN <tomo@artefacts.com>, EP <eric@artefacts.com>
5
5
  Project-URL: Homepage, https://github.com/art-e-fact/artefacts-client
6
6
  Project-URL: Bug Tracker, https://github.com/art-e-fact/artefacts-client/issues
7
+ Project-URL: Changelog, https://github.com/art-e-fact/artefacts-client/CHANGELOG.md
7
8
  Classifier: Programming Language :: Python :: 3
8
9
  Classifier: License :: OSI Approved :: Apache Software License
9
10
  Classifier: Operating System :: OS Independent
10
11
  Requires-Python: >=3.8
11
12
  Description-Content-Type: text/markdown
13
+ Requires-Dist: artefacts-c2d>=1.7.1
12
14
  Requires-Dist: artefacts-copava>=0.1.11
13
15
  Requires-Dist: click>=8.0.4
14
16
  Requires-Dist: gitignore_parser>=0.1.11
@@ -42,7 +44,7 @@ Requires-Dist: twine; extra == "dev"
42
44
  CLI to the Artefacts platform.
43
45
 
44
46
  [![Documentation](https://img.shields.io/badge/documentation-blue.svg?style=flat-square)](https://docs.artefacts.com/)
45
- [![Code style: Black-compatible with Ruff](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
47
+ [![Ruff Style](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
46
48
 
47
49
  ## Requirements
48
50
 
@@ -3,7 +3,7 @@
3
3
  CLI to the Artefacts platform.
4
4
 
5
5
  [![Documentation](https://img.shields.io/badge/documentation-blue.svg?style=flat-square)](https://docs.artefacts.com/)
6
- [![Code style: Black-compatible with Ruff](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
6
+ [![Ruff Style](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
7
7
 
8
8
  ## Requirements
9
9
 
@@ -71,7 +71,7 @@ def get_artefacts_api_url(project_profile):
71
71
 
72
72
 
73
73
  class APIConf:
74
- def __init__(self, project_name):
74
+ def __init__(self, project_name: str, job_name: str = None) -> None:
75
75
  config = get_conf_from_file()
76
76
  if project_name in config:
77
77
  profile = config[project_name]
@@ -96,7 +96,10 @@ class APIConf:
96
96
  self.headers["User-Agent"] = (
97
97
  f"ArtefactsClient/{__version__} ({platform.platform()}/{platform.python_version()})"
98
98
  )
99
- click.echo(f"Connecting to {self.api_url} using {auth_type}")
99
+ if job_name:
100
+ click.echo(f"[{job_name}] Connecting to {self.api_url} using {auth_type}")
101
+ else:
102
+ click.echo(f"Connecting to {self.api_url} using {auth_type}")
100
103
 
101
104
 
102
105
  def validate_artefacts_config(config_file: str) -> dict:
@@ -243,8 +246,8 @@ def hello(project_name):
243
246
  )
244
247
  @click.option(
245
248
  "--with-image",
246
- default="artefacts",
247
- help="[Experimental] Run the job using the image name passed here. Only used when running with --in-container set.",
249
+ default=None,
250
+ help="[Deprecated and unused from 0.8.0; Image names are now internally managed] Run the job using the image name passed here. Only used when running with --in-container set.",
248
251
  )
249
252
  @click.option(
250
253
  "--no-rebuild",
@@ -281,38 +284,37 @@ def run(
281
284
  * Directly in the shell by default.
282
285
  * Inside a packaged container when using the --in-container option.
283
286
  """
287
+ warpconfig = read_config(config)
288
+ project_id = warpconfig["project"]
289
+
284
290
  if in_container:
285
- image_exist = ctx.invoke(containers.check, name=with_image)
286
- if not no_rebuild or not image_exist:
287
- if image_exist:
288
- announce = "Rebuilding container image to prepare the run..."
289
- else:
290
- announce = "Building container image to prepare the run..."
291
- click.echo(announce)
291
+ click.echo("#" * 80)
292
+ click.echo(f"# Job {jobname}".ljust(79, " ") + "#")
293
+ click.echo("#" * 80)
294
+ click.echo(f"[{jobname}] Checking container image")
295
+ if not no_rebuild:
292
296
  ctx.invoke(
293
- containers.build, path=".", dockerfile="Dockerfile", name=with_image
297
+ containers.build,
298
+ root=".",
294
299
  )
295
- click.echo("Build complete.\n")
296
- click.echo("Starting the container run...")
300
+ click.echo(f"[{jobname}] Container image ready")
301
+ click.echo(f"[{jobname}] Run in container")
297
302
  return ctx.invoke(
298
303
  containers.run,
299
- image=with_image,
300
304
  jobname=jobname,
301
305
  config=config,
302
306
  with_gui=with_gui,
303
307
  )
304
308
 
305
- warpconfig = read_config(config)
306
-
307
- project_id = warpconfig["project"]
308
- api_conf = APIConf(project_id)
309
- click.echo(f"Starting tests for {project_id}")
309
+ api_conf = APIConf(project_id, jobname)
310
+ click.echo(f"[{jobname}] Starting tests")
310
311
  if jobname not in warpconfig["jobs"]:
311
- raise click.ClickException(f"Job {jobname} not defined")
312
+ click.secho(f"[{jobname}] Error: Job name not defined", err=True, bold=True)
313
+ raise click.Abort()
312
314
  jobconf = warpconfig["jobs"][jobname]
313
315
  job_type = jobconf.get("type", "test")
314
316
  if job_type not in ["test"]:
315
- click.echo(f"Job type not supported: f{job_type}")
317
+ click.echo(f"[{jobname}] Job type not supported: {job_type}")
316
318
  return
317
319
 
318
320
  framework = jobconf["runtime"].get("framework", None)
@@ -321,19 +323,19 @@ def run(
321
323
  if framework in DEPRECATED_FRAMEWORKS.keys():
322
324
  migrated_framework = DEPRECATED_FRAMEWORKS[framework]
323
325
  click.echo(
324
- f"The selected framework '{framework}' is deprecated. Using '{migrated_framework}' instead."
326
+ f"[{jobname}] The selected framework '{framework}' is deprecated. Using '{migrated_framework}' instead."
325
327
  )
326
328
  framework = migrated_framework
327
329
 
328
330
  if framework not in SUPPORTED_FRAMEWORKS:
329
331
  click.echo(
330
- f"WARNING: framework: '{framework}' is not officially supported. Attempting run."
332
+ f"[{jobname}] WARNING: framework: '{framework}' is not officially supported. Attempting run."
331
333
  )
332
334
 
333
335
  batch_index = os.environ.get("AWS_BATCH_JOB_ARRAY_INDEX", None)
334
336
  if batch_index is not None:
335
337
  batch_index = int(batch_index)
336
- click.echo(f"AWS BATCH ARRAY DETECTED, batch_index={batch_index}")
338
+ click.echo(f"[{jobname}] AWS BATCH ARRAY DETECTED, batch_index={batch_index}")
337
339
  scenarios, first = generate_scenarios(jobconf, batch_index)
338
340
  context = None
339
341
  execution_context = getpass.getuser() + "@" + platform.node()
@@ -356,30 +358,46 @@ def run(
356
358
  first,
357
359
  )
358
360
  except AuthenticationError:
359
- raise click.ClickException(
360
- "Unable to authenticate (Stage: Job initialisation), please check your project name and API key"
361
+ click.secho(
362
+ f"[{jobname}] Unable to authenticate (Stage: Job initialisation), please check your project name and API key",
363
+ err=True,
364
+ bold=True,
361
365
  )
366
+ raise click.Abort()
362
367
 
363
368
  job_success = True
364
369
  for scenario_n, scenario in enumerate(scenarios):
365
370
  click.echo(
366
- f"Starting scenario {scenario_n + 1}/{len(scenarios)}: {scenario['name']}"
371
+ f"[{jobname}] Starting scenario {scenario_n + 1}/{len(scenarios)}: {scenario['name']}"
367
372
  )
368
373
  try:
369
374
  run = warpjob.new_run(scenario)
370
375
  except AuthenticationError:
371
- raise click.ClickException(
372
- "Unable to authenticate (Stage: Job run), please check your project name and API key"
376
+ click.secho(
377
+ f"[{jobname}] Unable to authenticate (Stage: Job run), please check your project name and API key",
378
+ err=True,
379
+ bold=True,
373
380
  )
381
+ raise click.Abort()
374
382
  if framework is not None and framework.startswith("ros2:"):
375
383
  from artefacts.cli.ros2 import run_ros2_tests
384
+ from artefacts.cli.utils_ros import get_TestSuite_error_result
376
385
 
377
386
  if "ros_testfile" not in run.params:
378
- raise click.ClickException(
379
- "Test launch file not specified for ros2 project"
387
+ click.secho(
388
+ f"[{jobname}] Test launch file not specified for ros2 project",
389
+ err=True,
390
+ bold=True,
391
+ )
392
+ result = get_TestSuite_error_result(
393
+ scenario["name"],
394
+ "launch_test file not specified error",
395
+ f"Please specify a `ros_testfile` in the artefacts.yaml scenario configuration.",
380
396
  )
397
+ run.log_tests_results([result], False)
398
+ run.stop()
381
399
  if dryrun:
382
- click.echo("performing dry run")
400
+ click.echo(f"[{jobname}] Performing dry run")
383
401
  results, success = {}, True
384
402
  else:
385
403
  try:
@@ -388,25 +406,36 @@ def run(
388
406
  warpjob.stop()
389
407
  warpjob.log_tests_result(False)
390
408
  click.secho(e, bold=True, err=True)
391
- raise click.ClickException("artefacts failed to execute the tests")
409
+ click.secho(
410
+ f"[{jobname}] artefacts failed to execute the tests",
411
+ err=True,
412
+ bold=True,
413
+ )
414
+ raise click.Abort()
392
415
  if success is None:
393
416
  run.stop()
394
417
  warpjob.stop()
395
418
  warpjob.log_tests_result(job_success)
396
- raise click.ClickException(
397
- "Not able to execute tests. Make sure that ROS2 is sourced and that your launch file syntax is correct."
419
+ click.secho(
420
+ f"[{jobname}] Not able to execute tests. Make sure that ROS2 is sourced and that your launch file syntax is correct.",
421
+ err=True,
422
+ bold=True,
398
423
  )
424
+ raise click.Abort()
399
425
  if not success:
400
426
  job_success = False
401
427
  elif framework is not None and framework.startswith("ros1:"):
402
428
  from artefacts.cli.ros1 import run_ros1_tests
403
429
 
404
430
  if "ros_testfile" not in run.params:
405
- raise click.ClickException(
406
- "Test launch file not specified for ros1 project"
431
+ click.secho(
432
+ f"[{jobname}] Test launch file not specified for ros1 project",
433
+ err=True,
434
+ bold=True,
407
435
  )
436
+ raise click.Abort()
408
437
  if dryrun:
409
- click.echo("performing dry run")
438
+ click.echo(f"[{jobname}] Performing dry run")
410
439
  results, success = {}, True
411
440
  else:
412
441
  results, success = run_ros1_tests(run)
@@ -416,9 +445,14 @@ def run(
416
445
  from artefacts.cli.other import run_other_tests
417
446
 
418
447
  if "run" not in run.params:
419
- raise click.ClickException("run command not specified for scenario")
448
+ click.secho(
449
+ f"[{jobname}] run command not specified for scenario",
450
+ err=True,
451
+ bold=True,
452
+ )
453
+ raise click.Abort()
420
454
  if dryrun:
421
- click.echo("performing dry run")
455
+ click.echo(f"[{jobname}] Performing dry run")
422
456
  results, success = {}, True
423
457
  else:
424
458
  results, success = run_other_tests(run)
@@ -432,7 +466,7 @@ def run(
432
466
 
433
467
  run.stop()
434
468
  warpjob.log_tests_result(job_success)
435
- click.echo("Done")
469
+ click.echo(f"[{jobname}] Done")
436
470
  time.sleep(random.random() * 1)
437
471
 
438
472
  warpjob.stop()
@@ -553,17 +587,23 @@ def run_remote(config, description, jobname, skip_validation=False):
553
587
  f"Missing access! Please make sure your API key is added at {dashboard_url}/settings"
554
588
  )
555
589
 
556
- if (
557
- upload_urls_response.status_code == 401
558
- and result["message"] == "no linked repository"
559
- ):
590
+ if upload_urls_response.status_code == 402:
560
591
  raise click.ClickException(
561
- f"Missing linked GitHub repository. Please link a GitHub repository at {dashboard_url}/settings"
592
+ f"Billing issue, please go to {dashboard_url}/settings to correct: {result['error']}"
562
593
  )
563
594
 
564
- raise click.ClickException(
565
- f"Error getting project info: {result['message']}"
566
- )
595
+ if "message" in result:
596
+ raise click.ClickException(
597
+ f"Error getting project info: {result['message']}"
598
+ )
599
+ elif "error" in result:
600
+ raise click.ClickException(
601
+ f"Error getting project info: {result['error']}"
602
+ )
603
+ else:
604
+ raise click.ClickException(
605
+ f"Error getting project info: {upload_urls_response.status_code} {upload_urls_response.reason}. Response text: {upload_urls_response.text}."
606
+ )
567
607
 
568
608
  upload_urls = upload_urls_response.json()["upload_urls"]
569
609
  url = ""
@@ -0,0 +1,165 @@
1
+ import os
2
+ from pathlib import Path
3
+
4
+ import click
5
+
6
+ from c2d.core import Converter
7
+
8
+ from artefacts.cli.constants import DEFAULT_API_URL
9
+ from artefacts.cli.utils import config_validation, read_config
10
+ from artefacts.cli.containers.utils import ContainerMgr
11
+
12
+
13
+ @click.group()
14
+ @click.option("--debug/--no-debug", default=False)
15
+ @click.pass_context
16
+ def containers(ctx: click.Context, debug: bool):
17
+ ctx.ensure_object(dict)
18
+ ctx.obj["debug"] = debug
19
+
20
+
21
+ @containers.command()
22
+ @click.option(
23
+ "--path",
24
+ default=".",
25
+ help="[Deprecated since 0.8.0; please see --root] Path to the root of the project.",
26
+ )
27
+ @click.option(
28
+ "--root",
29
+ default=".",
30
+ help="Path to the root of the project.",
31
+ )
32
+ @click.option(
33
+ "--dockerfile",
34
+ default="Dockerfile",
35
+ help="Path to a custom Dockerfile. Defaults to Dockerfile under `path` (see option of the same name).",
36
+ )
37
+ @click.option(
38
+ "--name",
39
+ required=False,
40
+ help="[Deprecated since 0.8.0; not used and will disappear after 0.8.0] Name for the generated image",
41
+ )
42
+ @click.option(
43
+ "--config",
44
+ callback=config_validation,
45
+ default="artefacts.yaml",
46
+ help="Path to the Artefacts configuration file. It defaults to `./artefacts.yaml`",
47
+ )
48
+ @click.pass_context
49
+ def build(
50
+ ctx: click.Context,
51
+ path: str,
52
+ root: str,
53
+ dockerfile: str,
54
+ name: str,
55
+ config: str,
56
+ ):
57
+ try:
58
+ artefacts_config = read_config(config)
59
+ except FileNotFoundError:
60
+ raise click.ClickException(
61
+ f"Project config file not found: {config}. Please provide an Artefacts configuration file to proceed (running `artefacts init` allows to generate one)."
62
+ )
63
+ prefix = artefacts_config["project"].strip().lower()
64
+ dockerfiles = []
65
+ if os.path.exists(dockerfile):
66
+ for job_name in artefacts_config["jobs"]:
67
+ dockerfiles.append(
68
+ dict(
69
+ path=root,
70
+ dockerfile=dockerfile,
71
+ name=f"{prefix}/{job_name.strip().lower()}",
72
+ )
73
+ )
74
+ else:
75
+ # The split on `prefix` is to ensure there is no slash (project names are org/project) confusing the path across supported OS.
76
+ dest_root = (
77
+ Path.home()
78
+ / Path(".artefacts")
79
+ / Path("projects")
80
+ / Path(*(prefix.split("/")))
81
+ / Path("containers")
82
+ )
83
+ if not dest_root.exists():
84
+ click.echo(
85
+ f"No {dockerfile} found here. Let's generate one per scenario based on artefacts.yaml. They will be available under the `{dest_root}` folder and used from there."
86
+ )
87
+ # No condition on generating the Dockerfiles as:
88
+ # - Fast
89
+ # - We consider entirely managed, so any manual change should be ignored.
90
+ scenarios = Converter().process(config, as_text=False)
91
+ for idx, df in enumerate(scenarios.values()):
92
+ job_name = df.job_name.strip().lower()
93
+ dest = dest_root / Path(job_name)
94
+ dest.mkdir(parents=True, exist_ok=True)
95
+ _dockerfile = os.path.join(dest, "Dockerfile")
96
+ df.dump(_dockerfile)
97
+ click.echo(f"[{job_name}] Using generated Dockerfile at: {_dockerfile}")
98
+ dockerfiles.append(
99
+ dict(
100
+ path=root,
101
+ dockerfile=_dockerfile,
102
+ name=f"{prefix}/{job_name}",
103
+ )
104
+ )
105
+ handler = ContainerMgr()
106
+ if len(dockerfiles) > 0:
107
+ for specs in dockerfiles:
108
+ # No condition on building the images, as relatively fast when already exists, and straightforward logic.
109
+ image, _ = handler.build(**specs)
110
+ else:
111
+ click.echo("No Dockerfile, nothing to do.")
112
+
113
+
114
+ @containers.command()
115
+ @click.argument("name")
116
+ @click.pass_context
117
+ def check(ctx: click.Context, name: str):
118
+ if name is None:
119
+ name = "artefacts"
120
+ handler = ContainerMgr()
121
+ result = handler.check(name)
122
+ if ctx.parent is None:
123
+ # Print only if the command is called directly.
124
+ print(f"Package {name} exists and ready to use.")
125
+ return result
126
+
127
+
128
+ @containers.command()
129
+ @click.argument("jobname")
130
+ @click.option(
131
+ "--config",
132
+ callback=config_validation,
133
+ default="artefacts.yaml",
134
+ help="Path to the Artefacts configuration file. It defaults to `./artefacts.yaml`",
135
+ )
136
+ @click.option(
137
+ "--with-gui",
138
+ "with_gui",
139
+ default=False,
140
+ help="Show any GUI if any is created by the test runs. By default, UI elements are run but hidden---only test logs are returned. Please note GUI often assume an X11 environment, typically with Qt, so this may not work without a appropriate environment.",
141
+ )
142
+ @click.pass_context
143
+ def run(ctx: click.Context, jobname: str, config: str, with_gui: bool):
144
+ try:
145
+ artefacts_config = read_config(config)
146
+ except FileNotFoundError:
147
+ raise click.ClickException(f"Project config file not found: {config}")
148
+ project = artefacts_config["project"]
149
+ handler = ContainerMgr()
150
+ params = dict(
151
+ image=f"{project.strip().lower()}/{jobname}",
152
+ project=project,
153
+ jobname=jobname,
154
+ with_gui=with_gui,
155
+ # Hidden settings primarily useful to Artefacts developers
156
+ api_url=os.environ.get("ARTEFACTS_API_URL", DEFAULT_API_URL),
157
+ api_key=os.environ.get("ARTEFACTS_KEY", None),
158
+ )
159
+ container, logs = handler.run(**params)
160
+ if container:
161
+ print(f"Package run complete: Container Id for inspection: {container['Id']}")
162
+ else:
163
+ print("Package run failed:")
164
+ for entry in logs:
165
+ print("\t- " + entry)
@@ -22,6 +22,10 @@ class DockerManager(CMgr):
22
22
 
23
23
  def build(self, **kwargs) -> Tuple[str, Generator]:
24
24
  kwargs["tag"] = kwargs.pop("name")
25
+ # Ensure `path` is a string, the Docker package does not support pathlib.
26
+ kwargs["path"] = str(kwargs.pop("path"))
27
+ # Remove intermediate containers
28
+ kwargs["rm"] = True
25
29
  logs = []
26
30
  img_id = None
27
31
  for entry in self.client.build(**kwargs):
@@ -32,7 +36,7 @@ class DockerManager(CMgr):
32
36
  if "stream" in data:
33
37
  line = data["stream"].strip()
34
38
  if not line.startswith("---") and len(line) > 0:
35
- print(line)
39
+ print(f"[{kwargs['tag'].split('/')[-1]}] {line}")
36
40
  logs.append(line)
37
41
  elif "aux" in data and "ID" in data["aux"]:
38
42
  img_id = data["aux"]["ID"]