toolforge-components-cli 0.0.5__tar.gz → 0.0.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: toolforge-components-cli
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: Toolforge components client
5
5
  License: GPLv3
6
6
  Author: Slavina Stefanova
@@ -37,6 +37,12 @@ This project uses Poetry for dependency management and packaging. To set up a de
37
37
  2. Clone the repository
38
38
  3. Run `poetry install`
39
39
 
40
+ ## Deployment
41
+
42
+ This package follows the standard procedure outlined here:
43
+
44
+ https://wikitech.wikimedia.org/wiki/Portal:Toolforge/Admin/Packaging#Using_existing_automation
45
+
40
46
  ## License
41
47
 
42
48
  This project is licensed under GPL-3.0-or-later. See the LICENSE file for details.
@@ -10,6 +10,12 @@ This project uses Poetry for dependency management and packaging. To set up a de
10
10
  2. Clone the repository
11
11
  3. Run `poetry install`
12
12
 
13
+ ## Deployment
14
+
15
+ This package follows the standard procedure outlined here:
16
+
17
+ https://wikitech.wikimedia.org/wiki/Portal:Toolforge/Admin/Packaging#Using_existing_automation
18
+
13
19
  ## License
14
20
 
15
21
  This project is licensed under GPL-3.0-or-later. See the LICENSE file for details.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "toolforge-components-cli"
3
- version = "0.0.5"
3
+ version = "0.0.7"
4
4
  description = "Toolforge components client"
5
5
  authors = ["Slavina Stefanova <sstefanova@wikimedia.org>"]
6
6
  license = "GPLv3"
@@ -107,14 +107,19 @@ def _display_deployment(deployment_data: dict, as_json: bool, prefix: str = "")
107
107
  + indent(text=deployment_data.get("long_status", "unknown"), prefix=" ")
108
108
  )
109
109
  if deployment_data.get("builds"):
110
- click.echo(
111
- "\n" + click.style("Builds:" if not prefix else "Builds:", bold=True)
112
- )
110
+ click.echo("\n" + click.style("Builds:", bold=True))
113
111
  for component, build in deployment_data["builds"].items():
114
112
  click.echo(
115
113
  f" {component}({_format_status(build['build_status'])}): {build['build_id']}"
116
114
  )
117
115
 
116
+ if deployment_data.get("runs"):
117
+ click.echo("\n" + click.style("Runs:", bold=True))
118
+ for component, run in deployment_data["runs"].items():
119
+ click.echo(
120
+ f" {component}({_format_status(run['run_status'])}): {run.get('run_long_status', '')}"
121
+ )
122
+
118
123
 
119
124
  @click.version_option(prog_name="Toolforge Components CLI")
120
125
  @click.group(
@@ -347,6 +352,24 @@ def deployment():
347
352
 
348
353
 
349
354
  @deployment.command(name="create", help="Create a new deployment.")
355
+ @click.option(
356
+ "--force-build",
357
+ is_flag=True,
358
+ default=False,
359
+ help=(
360
+ "If set, it will always rebuild the components, even if there's already a build for the "
361
+ "same commit."
362
+ ),
363
+ )
364
+ @click.option(
365
+ "--force-run",
366
+ is_flag=True,
367
+ default=False,
368
+ help=(
369
+ "If set, it will always rerun the components, even if none of the configuration options changed "
370
+ "(ex. delete + create the continuous job)"
371
+ ),
372
+ )
350
373
  @click.option(
351
374
  "--json",
352
375
  "as_json",
@@ -354,11 +377,19 @@ def deployment():
354
377
  help="If set, will output in JSON format",
355
378
  )
356
379
  @click.pass_context
357
- def deployment_create(ctx, as_json: bool) -> None:
380
+ def deployment_create(ctx, force_build: bool, force_run: bool, as_json: bool) -> None:
358
381
  components_client = ctx.obj["components_client"]
359
382
  display_messages = not as_json
360
383
 
361
- response = components_client.post("/deployment", display_messages=display_messages)
384
+ query_params: dict[str, str] = {}
385
+ if force_build:
386
+ query_params["force-build"] = "true"
387
+ if force_run:
388
+ query_params["force-run"] = "true"
389
+
390
+ response = components_client.post(
391
+ "/deployment", params=query_params, display_messages=display_messages
392
+ )
362
393
 
363
394
  if as_json:
364
395
  click.echo(json.dumps(response, indent=4))
@@ -372,6 +403,12 @@ def deployment_create(ctx, as_json: bool) -> None:
372
403
  click.echo(
373
404
  f" {component}({_format_status(build['build_status'])}): {build['build_id']}"
374
405
  )
406
+ if deployment_data.get("runs"):
407
+ click.echo("\nRuns:")
408
+ for component, run in deployment_data["runs"].items():
409
+ click.echo(
410
+ f" {component}({_format_status(run['run_status'])}): {run.get('run_long_status', '')}"
411
+ )
375
412
 
376
413
 
377
414
  def _format_headers(headers: list[str]) -> list[str]:
@@ -387,11 +424,20 @@ def _format_builds(builds: dict[str, dict[str, Any]]) -> str:
387
424
  return "\n".join(builds_strings)
388
425
 
389
426
 
427
+ def _format_runs(runs: dict[str, dict[str, Any]]) -> str:
428
+ runs_strings: list[str] = []
429
+ for component_name, run_info in runs.items():
430
+ runs_strings.append(
431
+ f"{component_name}({_format_status(run_info['run_status'])}): {run_info.get('run_long_status', '')}"
432
+ )
433
+ return "\n".join(runs_strings)
434
+
435
+
390
436
  def _format_status(status: str) -> str:
391
437
  fg_color = "yellow"
392
438
 
393
439
  if status in ("running", "pending"):
394
- fg_color = "white"
440
+ fg_color = "yellow"
395
441
  elif status == "failed":
396
442
  fg_color = "red"
397
443
  elif status == "successful":
@@ -424,14 +470,17 @@ def deployment_list(ctx, as_json: bool) -> None:
424
470
  deployment["deploy_id"],
425
471
  deployment["creation_time"],
426
472
  _format_status(deployment.get("status", "unknown")),
427
- _format_builds(deployment.get("builds", [])),
473
+ _format_builds(deployment.get("builds", {})),
474
+ _format_runs(deployment.get("runs", {})),
428
475
  ]
429
476
  for deployment in deployments
430
477
  ]
431
478
  click.echo(
432
479
  tabulate(
433
480
  formatted_deployments,
434
- headers=_format_headers(["ID", "Creation time", "Status", "Builds"]),
481
+ headers=_format_headers(
482
+ ["ID", "Creation time", "Status", "Builds", "Runs"]
483
+ ),
435
484
  )
436
485
  )
437
486