langlauf-cli 0.7.0__tar.gz → 0.9.0__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 (23) hide show
  1. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/PKG-INFO +6 -6
  2. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/README.md +4 -5
  3. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/commands/download.py +54 -2
  4. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/commands/upload.py +5 -8
  5. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/jenkins/builds.py +1 -1
  6. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/jenkins/pipelines.py +5 -26
  7. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/settings.py +4 -3
  8. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/ui/completion.py +178 -9
  9. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/pyproject.toml +49 -36
  10. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/LICENSE +0 -0
  11. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/commands/configure.py +0 -0
  12. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/commands/delete.py +0 -0
  13. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/commands/status.py +0 -0
  14. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/errors.py +0 -0
  15. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/history.py +0 -0
  16. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/jenkins/client.py +0 -0
  17. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/jenkins/stage_cache.py +0 -0
  18. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/main.py +0 -0
  19. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/output.py +0 -0
  20. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/ui/json_output.py +0 -0
  21. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/ui/pickers.py +0 -0
  22. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/ui/tables.py +0 -0
  23. {langlauf_cli-0.7.0 → langlauf_cli-0.9.0}/ll_cli/validation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langlauf-cli
3
- Version: 0.7.0
3
+ Version: 0.9.0
4
4
  Summary: A comprehensive multi-platform tool providing a consistent and easy-to-use interface to Langlauf's online services.
5
5
  License-File: LICENSE
6
6
  Author: Langlauf
@@ -9,6 +9,7 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Programming Language :: Python :: 3.12
10
10
  Classifier: Programming Language :: Python :: 3.13
11
11
  Classifier: Programming Language :: Python :: 3.14
12
+ Classifier: Programming Language :: Python :: 3.15
12
13
  Requires-Dist: api4jenkins (>=2.1.0,<3.0.0)
13
14
  Requires-Dist: inquirerpy (>=0.3.4,<0.4.0)
14
15
  Requires-Dist: platformdirs (>=4.9.6,<5.0.0)
@@ -46,9 +47,10 @@ Upgrade with `pipx upgrade langlauf-cli` / `uv tool upgrade langlauf-cli`.
46
47
  (this also fires on first interactive use when no credentials are
47
48
  configured yet). Re-run `ll-cli configure` any time to (re-)install it.
48
49
 
49
- Bash and zsh are supported. Completion is generated statically from the
50
- live command tree, so Tab is instant — re-run `ll-cli configure` after CLI
51
- changes to keep the script in sync.
50
+ Bash, zsh, fish, and PowerShell are supported; `ll-cli configure` installs
51
+ completion for the shell you're currently running in. Completion is generated
52
+ statically from the live command tree, so Tab is instant — re-run `ll-cli
53
+ configure` after CLI changes to keep the script in sync.
52
54
 
53
55
  ## Configure
54
56
 
@@ -78,5 +80,3 @@ vars (`SBOMAAS_URL`, `SBOMAAS_USER`, `SBOMAAS_TOKEN`, `SBOMAAS_TIMEOUT_*`). Shel
78
80
  env vars override the config file. `ll-cli configure --url ... --user ... --token ...`
79
81
  also works for non-interactive provisioning.
80
82
 
81
- See [`.env.example`](.env.example) for the full list of supported variables.
82
-
@@ -26,9 +26,10 @@ Upgrade with `pipx upgrade langlauf-cli` / `uv tool upgrade langlauf-cli`.
26
26
  (this also fires on first interactive use when no credentials are
27
27
  configured yet). Re-run `ll-cli configure` any time to (re-)install it.
28
28
 
29
- Bash and zsh are supported. Completion is generated statically from the
30
- live command tree, so Tab is instant — re-run `ll-cli configure` after CLI
31
- changes to keep the script in sync.
29
+ Bash, zsh, fish, and PowerShell are supported; `ll-cli configure` installs
30
+ completion for the shell you're currently running in. Completion is generated
31
+ statically from the live command tree, so Tab is instant — re-run `ll-cli
32
+ configure` after CLI changes to keep the script in sync.
32
33
 
33
34
  ## Configure
34
35
 
@@ -57,5 +58,3 @@ For CI / containers / one-off runs, the same settings are accepted as shell env
57
58
  vars (`SBOMAAS_URL`, `SBOMAAS_USER`, `SBOMAAS_TOKEN`, `SBOMAAS_TIMEOUT_*`). Shell
58
59
  env vars override the config file. `ll-cli configure --url ... --user ... --token ...`
59
60
  also works for non-interactive provisioning.
60
-
61
- See [`.env.example`](.env.example) for the full list of supported variables.
@@ -20,7 +20,7 @@ import time
20
20
 
21
21
  import rich.console
22
22
  import typer
23
- from typing import Annotated
23
+ from typing import Annotated, Literal
24
24
 
25
25
  from ll_cli import output
26
26
  from ll_cli.jenkins import builds
@@ -94,6 +94,28 @@ def _pick_build_by_version_match(
94
94
  )
95
95
 
96
96
 
97
+ def _classify_download_eligibility(
98
+ build_result: str | None,
99
+ fail_on_unstable: bool,
100
+ ) -> Literal["proceed", "warn_unstable", "refuse_unstable", "refuse_not_successful"]:
101
+ """Decide whether a finished run's result permits download, and how.
102
+
103
+ Split out from `download` as pure policy so it's unit-testable without a
104
+ live Jenkins (the gate runs after `ensure_connection`, and we don't mock).
105
+ UNSTABLE means a module stage (e.g. Symbols) failed soft but the SBOM / VDR /
106
+ report were still written and uploaded to D-Track — downloadable by default
107
+ (with a warning), unless --fail-on-unstable opts out. SUCCESS proceeds
108
+ silently; anything else (FAILURE / ABORTED / NOT_BUILT / None) is refused.
109
+ """
110
+ if build_result == "SUCCESS":
111
+ return "proceed"
112
+ if build_result == "UNSTABLE":
113
+ if fail_on_unstable:
114
+ return "refuse_unstable"
115
+ return "warn_unstable"
116
+ return "refuse_not_successful"
117
+
118
+
97
119
  def download(
98
120
  analysis_number: Annotated[
99
121
  int | None,
@@ -166,6 +188,16 @@ def download(
166
188
  "three to download all of them (the default).",
167
189
  ),
168
190
  ] = False,
191
+ fail_on_unstable: Annotated[
192
+ bool,
193
+ typer.Option(
194
+ "--fail-on-unstable",
195
+ help="Refuse to download from an UNSTABLE analysis run. By default "
196
+ "an UNSTABLE run (a build stage failed soft, but the SBOM, VDR, and "
197
+ "report were still produced) is downloaded with a warning; pass this "
198
+ "flag to abort on UNSTABLE instead.",
199
+ ),
200
+ ] = False,
169
201
  non_interactive: output.NonInteractiveOption = False,
170
202
  ) -> None:
171
203
  """Download the generated CycloneDX SBOM and vulnerability report for one analysis run.
@@ -188,6 +220,11 @@ def download(
188
220
  By default all three artifacts are saved (the CycloneDX SBOM, the
189
221
  vulnerability report PDF, and the VDR). Pass any of --cdx / --report /
190
222
  --vdr to restrict the download to just those kinds.
223
+
224
+ An UNSTABLE analysis run (a build stage failed soft, but the SBOM,
225
+ VDR, and report were still produced and uploaded) is downloaded by
226
+ default, with a warning. Pass --fail-on-unstable to refuse those
227
+ instead.
191
228
  """
192
229
  # --non-interactive forces the non-TTY path for the prompts below.
193
230
  output.set_non_interactive(non_interactive)
@@ -267,12 +304,27 @@ def download(
267
304
  f"{build.full_display_name}: RUNNING ({elapsed_seconds}s elapsed)"
268
305
  )
269
306
 
270
- if build.result != "SUCCESS":
307
+ download_eligibility = _classify_download_eligibility(build.result, fail_on_unstable)
308
+ if download_eligibility == "refuse_unstable":
309
+ typer.echo(
310
+ f"ERROR: Analysis run is UNSTABLE and --fail-on-unstable was given, "
311
+ f"refusing to download: {build.full_display_name} - {build.url}",
312
+ err=True,
313
+ )
314
+ raise typer.Abort()
315
+ if download_eligibility == "refuse_not_successful":
271
316
  typer.echo(
272
317
  f"ERROR: Cannot download artifacts, generation not successful: {build.full_display_name} - {build.url}",
273
318
  err=True,
274
319
  )
275
320
  raise typer.Abort()
321
+ if download_eligibility == "warn_unstable":
322
+ typer.echo(
323
+ f"WARNING: Analysis run is UNSTABLE — a build stage failed soft. "
324
+ f"Downloading anyway; some artifacts may be missing or incomplete: "
325
+ f"{build.full_display_name} - {build.url}",
326
+ err=True,
327
+ )
276
328
 
277
329
  try:
278
330
  outdir = outdir.resolve(strict=False)
@@ -94,13 +94,12 @@ def _ensure_jenkins_job_for_product(session: client.Session, target_product_name
94
94
  """Return the Jenkins job for `target_product_name`, creating it if missing.
95
95
 
96
96
  A missing job is created by copying the currently-selected product's config.xml
97
- (the template; see the create_job call below for why not copy_job). The copy inherits
98
- all of the template's parameters, so it's a valid SBOM pipeline by construction.
97
+ (the template; see the create_job call below for why not copy_job). The copy is a
98
+ buildable job like the template, so it's a valid SBOM pipeline by construction.
99
99
 
100
100
  An existing job is validated against session.available_pipelines —
101
- if the name resolves to a job that *isn't* a valid SBOM pipeline (wrong
102
- parameters / a folder / etc.), we abort with the same error path as
103
- when a `--product` typo doesn't match anything.
101
+ if the name resolves to a job that *isn't* a valid SBOM pipeline (a folder / etc.),
102
+ we abort with the same error path as when a `--product` typo doesn't match anything.
104
103
  """
105
104
  existing_job: Project | None = session.jenkins.get_job(target_product_name)
106
105
  if existing_job is not None:
@@ -228,11 +227,9 @@ def upload(
228
227
  f"'{target_product_name}' at '{session.jenkins.url}'"
229
228
  )
230
229
 
231
- # PRODUCT_NAME is still required by the pipeline but no longer user-tunable — it always
232
- # matches the target product (Jenkins job) name. PRODUCT_VERSION stays user-facing.
230
+ # PRODUCT_VERSION stays user-facing.
233
231
  # dict[str, object] because UPLOAD_FILE (a file-like object) is added below.
234
232
  build_parameters: dict[str, object] = {
235
- pipelines.GENERATE_SBOM_PARAMETER_PRODUCT_NAME: target_product_name,
236
233
  pipelines.GENERATE_SBOM_PARAMETER_PRODUCT_VERSION: resolved_product_version,
237
234
  }
238
235
 
@@ -147,7 +147,7 @@ def _build_summary_from_raw_build(
147
147
 
148
148
  Shared by every callsite that fetches builds[] data (one-shot or paged) so the field
149
149
  mapping lives in exactly one place. The `pipeline_name` is the Jenkins job name (e.g.
150
- `sbomaas_multi`); we treat it as the product_name for display purposes — the build's
150
+ `sbomaas_prod_pipeline`); we treat it as the product_name for display purposes — the build's
151
151
  own `PRODUCT_NAME` parameter is the legacy upload-derived value and is being phased
152
152
  out, so we deliberately don't read it.
153
153
  """
@@ -7,7 +7,7 @@ module top to use `Pipeline` / `get_pipeline_names` while building the session.
7
7
  """
8
8
 
9
9
  from dataclasses import dataclass
10
- from typing import TYPE_CHECKING, Any, NoReturn
10
+ from typing import TYPE_CHECKING, NoReturn
11
11
 
12
12
  from api4jenkins import Jenkins as SBOMaaSEndpoint # type: ignore[import-untyped]
13
13
  from api4jenkins.build import WorkflowRun # type: ignore[import-untyped]
@@ -23,12 +23,7 @@ if TYPE_CHECKING:
23
23
 
24
24
 
25
25
  GENERATE_SBOM_PARAMETER_UPLOAD_FILE = "UPLOAD_FILE"
26
- GENERATE_SBOM_PARAMETER_PRODUCT_NAME = "PRODUCT_NAME"
27
26
  GENERATE_SBOM_PARAMETER_PRODUCT_VERSION = "PRODUCT_VERSION"
28
- REQUIRED_GENERATE_SBOM_PARAMETERS = {
29
- GENERATE_SBOM_PARAMETER_UPLOAD_FILE: "StashedFileParameterDefinition",
30
- GENERATE_SBOM_PARAMETER_PRODUCT_NAME: "StringParameterDefinition",
31
- }
32
27
 
33
28
 
34
29
  @dataclass
@@ -37,27 +32,13 @@ class Pipeline:
37
32
  display_name: str = ""
38
33
 
39
34
 
40
- def _job_has_required_sbom_parameters(job: Any) -> bool:
41
- """True if the job declares every required SBOM parameter at the expected type."""
42
- matched_required_parameter_count = 0
43
- for parameter in job.get_parameters():
44
- parameter_name = parameter["name"]
45
- if parameter_name not in REQUIRED_GENERATE_SBOM_PARAMETERS:
46
- continue
47
- if parameter["type"] != REQUIRED_GENERATE_SBOM_PARAMETERS[parameter_name]:
48
- continue
49
- matched_required_parameter_count += 1
50
- return matched_required_parameter_count == len(REQUIRED_GENERATE_SBOM_PARAMETERS)
51
-
52
-
53
35
  def get_pipeline_names(jenkins: SBOMaaSEndpoint) -> list[Pipeline]:
54
36
  """
55
37
  Returns a list of existing, usable Pipelines with `full_name` and
56
38
  `display_name`.
57
39
  """
58
40
  pipelines: list[Pipeline] = []
59
- # A job is an SBOMaaS pipeline if it's buildable and declares the required
60
- # build parameters.
41
+ # Every buildable job is an SBOMaaS pipeline.
61
42
  for job in jenkins.iter():
62
43
  # Folders and other container items don't expose `buildable` at all
63
44
  # (api4jenkins raises AttributeError). hasattr skips them explicitly,
@@ -67,11 +48,9 @@ def get_pipeline_names(jenkins: SBOMaaSEndpoint) -> list[Pipeline]:
67
48
  continue
68
49
  if not job.buildable:
69
50
  continue
70
- # Extra optional parameters beyond the required set are fine.
71
- if _job_has_required_sbom_parameters(job):
72
- pipelines.append(
73
- Pipeline(full_name=job.full_name, display_name=job.display_name)
74
- )
51
+ pipelines.append(
52
+ Pipeline(full_name=job.full_name, display_name=job.display_name)
53
+ )
75
54
 
76
55
  return pipelines
77
56
 
@@ -16,9 +16,10 @@ Sources, highest precedence first:
16
16
  5. defaults declared on the Settings class below
17
17
 
18
18
  The config.env is the workstation-friendly option (set once, forget); env vars
19
- remain primary for CI, containers, and one-off overrides. The e2e_tests task
20
- body sources `.env.dev` into the shell before pytest runs; its own e2e tests
21
- read Jenkins coords directly via `os.environ`, bypassing this Settings class.
19
+ remain primary for CI, containers, and one-off overrides. The e2e_tests poetry
20
+ task sources the config file and the secrets file into the shell before pytest
21
+ runs; its own e2e tests read the Jenkins coordinates from `tests/e2e/config.py`,
22
+ not from this Settings class.
22
23
  """
23
24
 
24
25
  from functools import lru_cache
@@ -26,19 +26,20 @@ def _detect_shell() -> str | None:
26
26
 
27
27
 
28
28
  def _shell_name_from_comm(comm: str) -> str | None:
29
- """Map a /proc `comm` string to 'bash'/'zsh', or None if it's neither.
29
+ """Map a /proc `comm` string to a supported shell name, or None.
30
30
 
31
- A login shell's comm carries a leading '-' (e.g. '-zsh'); it's stripped,
32
- along with the trailing newline /proc adds.
31
+ Recognizes bash, zsh, fish, and PowerShell (comm 'pwsh'). A login shell's
32
+ comm carries a leading '-' (e.g. '-zsh'); it's stripped, along with the
33
+ trailing newline /proc adds.
33
34
  """
34
35
  shell_name = comm.strip().removeprefix("-")
35
- if shell_name in ("bash", "zsh"):
36
+ if shell_name in ("bash", "zsh", "fish", "pwsh"):
36
37
  return shell_name
37
38
  return None
38
39
 
39
40
 
40
41
  def _running_shell_from_parent_process() -> str | None:
41
- """The invoking shell from the parent process, or None if it isn't bash/zsh.
42
+ """The invoking shell from the parent process, or None if it isn't supported.
42
43
 
43
44
  $SHELL is the *login* shell, which is wrong when the user is in a different
44
45
  interactive shell (e.g. ran `zsh` from a bash login). The parent process of
@@ -197,6 +198,126 @@ def _build_static_zsh_completion_script() -> str:
197
198
  return "\n".join(lines)
198
199
 
199
200
 
201
+ def _build_static_fish_completion_script() -> str:
202
+ """Render a self-contained fish completion script for `ll-cli`.
203
+
204
+ Fish autoloads this from its completions dir, so — unlike the bash/zsh
205
+ scripts — it's a list of `complete` directives, not a sourced function. The
206
+ command tree is baked in (subcommands gated by `__fish_use_subcommand`,
207
+ per-command options by `__fish_seen_subcommand_from`), generated from the
208
+ live typer app so it stays in sync as long as `ll-cli configure` is re-run
209
+ after CLI changes.
210
+ """
211
+ # local import: ll_cli.main imports this module, so importing it at module
212
+ # load would cycle. By configure-time it's fully loaded.
213
+ import click
214
+ import typer.main
215
+
216
+ from ll_cli import main as main_module
217
+
218
+ click_app = typer.main.get_command(main_module.app)
219
+ assert isinstance(click_app, click.Group)
220
+
221
+ lines = [
222
+ "# Static fish completion for `ll-cli`, generated from the command tree.",
223
+ "# Regenerate with `ll-cli configure` after the CLI's flags change.",
224
+ "",
225
+ "# Subcommands — offered only before a subcommand is typed (-f: no files).",
226
+ ]
227
+ for command_name in click_app.commands:
228
+ lines.append(f"complete -c ll-cli -f -n __fish_use_subcommand -a {command_name}")
229
+ lines.extend([
230
+ "",
231
+ "# Top-level options.",
232
+ "complete -c ll-cli -f -n __fish_use_subcommand -l help",
233
+ "complete -c ll-cli -f -n __fish_use_subcommand -l version",
234
+ "",
235
+ "# Per-subcommand options — offered once the subcommand is on the line.",
236
+ ])
237
+ for command_name, command in click_app.commands.items():
238
+ long_options: list[str] = []
239
+ for param in command.params:
240
+ long_options.extend(opt for opt in param.opts if opt.startswith("--"))
241
+ long_options.append("--help")
242
+ for option in long_options:
243
+ option_name = option.removeprefix("--")
244
+ condition = f"__fish_seen_subcommand_from {command_name}"
245
+ lines.append(f"complete -c ll-cli -n '{condition}' -l {option_name}")
246
+ lines.append("")
247
+ return "\n".join(lines)
248
+
249
+
250
+ def _build_static_powershell_completion_script() -> str:
251
+ """Render a PowerShell `Register-ArgumentCompleter` script for `ll-cli`.
252
+
253
+ NOT exercised by CI — PowerShell isn't in the test environment, so this is
254
+ generated from the command tree and syntax-reviewed but not run; verify it on
255
+ a machine with `pwsh`. The completer mirrors the bash/zsh logic: subcommands
256
+ at the first position, a subcommand's long options when the current word
257
+ starts with '-', and filename completion otherwise.
258
+ """
259
+ # local import: ll_cli.main imports this module, so importing it at module
260
+ # load would cycle. By configure-time it's fully loaded.
261
+ import click
262
+ import typer.main
263
+
264
+ from ll_cli import main as main_module
265
+
266
+ click_app = typer.main.get_command(main_module.app)
267
+ assert isinstance(click_app, click.Group)
268
+ subcommand_list = ", ".join(f"'{name}'" for name in click_app.commands)
269
+
270
+ lines = [
271
+ "# Static PowerShell completion for `ll-cli`, generated from the command tree.",
272
+ "# Regenerate with `ll-cli configure` after the CLI's flags change.",
273
+ "Register-ArgumentCompleter -Native -CommandName ll-cli -ScriptBlock {",
274
+ " param($wordToComplete, $commandAst, $cursorPosition)",
275
+ "",
276
+ " $elements = $commandAst.CommandElements",
277
+ " # The established subcommand is the first non-option token after",
278
+ " # `ll-cli`, ignoring the word currently being typed.",
279
+ " $subcommand = $null",
280
+ " for ($i = 1; $i -lt $elements.Count; $i++) {",
281
+ " $text = $elements[$i].Extent.Text",
282
+ " if ($i -eq $elements.Count - 1 -and $text -eq $wordToComplete) { continue }",
283
+ " if (-not $text.StartsWith('-')) { $subcommand = $text; break }",
284
+ " }",
285
+ "",
286
+ " $candidates = @()",
287
+ " if ($null -eq $subcommand) {",
288
+ " if ($wordToComplete.StartsWith('-')) {",
289
+ " $candidates = @('--help', '--version')",
290
+ " } else {",
291
+ f" $candidates = @({subcommand_list})",
292
+ " }",
293
+ " } elseif ($wordToComplete.StartsWith('-')) {",
294
+ " switch ($subcommand) {",
295
+ ]
296
+ for command_name, command in click_app.commands.items():
297
+ long_options: list[str] = []
298
+ for param in command.params:
299
+ long_options.extend(opt for opt in param.opts if opt.startswith("--"))
300
+ long_options.append("--help")
301
+ options_list = ", ".join(f"'{opt}'" for opt in long_options)
302
+ lines.append(f" '{command_name}' {{ $candidates = @({options_list}) }}")
303
+ lines.extend([
304
+ " }",
305
+ " } else {",
306
+ " # Positional argument — fall back to filename completion.",
307
+ " return [System.Management.Automation.CompletionCompleters]::CompleteFilename($wordToComplete)",
308
+ " }",
309
+ "",
310
+ ' $candidates |',
311
+ ' Where-Object { $_ -like "$wordToComplete*" } |',
312
+ " ForEach-Object {",
313
+ " [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)",
314
+ " }",
315
+ "}",
316
+ "",
317
+ ])
318
+ return "\n".join(lines)
319
+
320
+
200
321
  def _install_static_completion(
201
322
  completion_path: Path, rc_path: Path, completion_script: str
202
323
  ) -> Path:
@@ -237,22 +358,62 @@ def _install_static_zsh_completion() -> Path:
237
358
  return installed_path
238
359
 
239
360
 
361
+ def _install_static_fish_completion() -> Path:
362
+ """Write the fish completion into fish's autoload dir; no rc edit needed.
363
+
364
+ Fish autoloads completions from $XDG_CONFIG_HOME/fish/completions (or
365
+ ~/.config/fish/completions on every platform, macOS included), so — unlike
366
+ bash/zsh — there's no rc file to source it from; dropping the file in place
367
+ is enough. Idempotent: each run just rewrites the same file.
368
+ """
369
+ config_home = os.environ.get("XDG_CONFIG_HOME") or str(Path.home() / ".config")
370
+ completion_path = Path(config_home) / "fish" / "completions" / "ll-cli.fish"
371
+ completion_path.parent.mkdir(parents=True, exist_ok=True)
372
+ completion_path.write_text(_build_static_fish_completion_script())
373
+ return completion_path
374
+
375
+
376
+ def _install_static_powershell_completion() -> Path:
377
+ """Write the PowerShell completer and ensure the profile dot-sources it.
378
+
379
+ On Unix, pwsh's per-user profile is ~/.config/powershell (it does not honor
380
+ $XDG_CONFIG_HOME), so the script and the profile both live there. Idempotent:
381
+ the dot-source line is added only if it isn't already in the profile.
382
+ """
383
+ powershell_dir = Path.home() / ".config" / "powershell"
384
+ completion_path = powershell_dir / "completions" / "ll-cli.ps1"
385
+ profile_path = powershell_dir / "Microsoft.PowerShell_profile.ps1"
386
+ completion_path.parent.mkdir(parents=True, exist_ok=True)
387
+ completion_path.write_text(_build_static_powershell_completion_script())
388
+
389
+ dot_source_line = f". '{completion_path}'"
390
+ profile_content = profile_path.read_text() if profile_path.is_file() else ""
391
+ if dot_source_line not in profile_content:
392
+ profile_content = profile_content.rstrip() + f"\n{dot_source_line}\n"
393
+ profile_path.write_text(profile_content)
394
+ return completion_path
395
+
396
+
240
397
  def maybe_install_shell_completion() -> None:
241
398
  """Offer to install shell completion for the detected shell.
242
399
 
243
- Supports bash and zsh; any other shell gets a short note and is skipped.
244
- Silent when no shell can be identified.
400
+ Supports bash, zsh, fish, and PowerShell; any other shell gets a short note
401
+ and is skipped. Silent when no shell can be identified.
245
402
  """
246
403
  detected_shell = _running_shell()
247
404
  if detected_shell == "bash":
248
405
  install_completion = _install_static_bash_completion
249
406
  elif detected_shell == "zsh":
250
407
  install_completion = _install_static_zsh_completion
408
+ elif detected_shell == "fish":
409
+ install_completion = _install_static_fish_completion
410
+ elif detected_shell == "pwsh":
411
+ install_completion = _install_static_powershell_completion
251
412
  else:
252
413
  if detected_shell:
253
414
  typer.echo(
254
- f" Skipping shell completion: only bash and zsh are supported "
255
- f"(detected: {detected_shell}).",
415
+ f" Skipping shell completion: only bash, zsh, fish, and "
416
+ f"PowerShell are supported (detected: {detected_shell}).",
256
417
  err=True,
257
418
  )
258
419
  return
@@ -267,6 +428,14 @@ def maybe_install_shell_completion() -> None:
267
428
  typer.echo(f" Could not install completion: {err}", err=True)
268
429
  return
269
430
  typer.echo(f" Installed {detected_shell} completion at {installed_path}")
431
+ if detected_shell == "fish":
432
+ # Fish autoloads from its completions dir — nothing to source.
433
+ typer.echo(" Fish will autoload it; open a new shell (or run: exec fish).")
434
+ return
435
+ if detected_shell == "pwsh":
436
+ # The pwsh profile dot-sources it; reload the profile or restart pwsh.
437
+ typer.echo(" Restart PowerShell (or run: . $PROFILE) to enable it.")
438
+ return
270
439
  # A child process can't reload completion in its parent shell, so offer a
271
440
  # one-liner. Source the file directly (not ~/.bashrc) — faster, no side
272
441
  # effects from other rc lines.
@@ -11,7 +11,7 @@ dynamic = ["version", "dependencies", "classifiers", "requires-python"]
11
11
  ll-cli = "ll_cli.main:app"
12
12
 
13
13
  [tool.poetry]
14
- version = "0.7.0"
14
+ version = "0.9.0"
15
15
  packages = [
16
16
  { include = "ll_cli" },
17
17
  { include = "LICENSE" },
@@ -38,7 +38,8 @@ pytest-cov = "^7.0.0"
38
38
  coverage = {extras = ["toml"], version = "^7.11.0"}
39
39
  taskipy = "^1.14.1"
40
40
  mypy = "^1.19.0"
41
- sbomaas-multi = "^0.14.2"
41
+ sbomaas-jenkins = "^1.0.0"
42
+ ll-sbomaas-utils = "^0.2.0"
42
43
 
43
44
  [tool.pytest.ini_options]
44
45
  #log_cli = true
@@ -72,6 +73,7 @@ plugins = ["pydantic.mypy"]
72
73
  module = ["tests.*"]
73
74
  disallow_untyped_defs = false
74
75
  disallow_incomplete_defs = false
76
+ check_untyped_defs = true
75
77
 
76
78
 
77
79
  [[tool.poetry.source]]
@@ -79,13 +81,6 @@ name = "langlauf"
79
81
  url = "https://pypi.langlauf.tech/root/stage/+simple/"
80
82
  priority = "primary"
81
83
 
82
- [tool.taskipy.settings]
83
- use_vars = true
84
-
85
- [tool.taskipy.variables]
86
- MODULE_NAME = "ll_cli"
87
- VERSION = "$(poetry version --short)"
88
-
89
84
  [tool.taskipy.tasks]
90
85
 
91
86
  # Quoting: '''...''' — multi-step script; extra args are NOT forwarded
@@ -104,11 +99,32 @@ localsetup = '''
104
99
  mypy = "poetry install --quiet && python -m mypy --strict --color-output ."
105
100
 
106
101
 
102
+ # -----------------------------------------------------------------------------
103
+ # push_checked_out_ref_and_write_it_to_jenkinsfile_ref_file
104
+ # -----------------------------------------------------------------------------
105
+ # jenkins/jenkinsfile_ref holds the ref the Jenkins job builds. It must be a
106
+ # full ref, never a bare commit hash.
107
+ # Quoting: '''...''' — multi-step script; extra args are NOT forwarded
108
+ push_checked_out_ref_and_write_it_to_jenkinsfile_ref_file = '''
109
+ set -eu
110
+
111
+ branch=$(git branch --show-current)
112
+ if [ -n "$branch" ]; then
113
+ git push
114
+ printf 'refs/heads/%s' "$branch" > jenkins/jenkinsfile_ref
115
+ else
116
+ tag=$(git describe --tags --exact-match)
117
+ git push origin "$tag"
118
+ printf 'refs/tags/%s' "$tag" > jenkins/jenkinsfile_ref
119
+ fi
120
+ '''
121
+
122
+
107
123
  # -----------------------------------------------------------------------------
108
124
  # unit_tests
109
125
  # -----------------------------------------------------------------------------
110
126
  # Quoting: "..." — single command / simple chain; extra args (-x, -k, etc.) are appended
111
- unit_tests = "python -m pytest -v -s --color=yes tests/unit"
127
+ unit_tests ="python -m pytest -v -s --color=yes tests/unit"
112
128
 
113
129
 
114
130
  # -----------------------------------------------------------------------------
@@ -118,12 +134,21 @@ unit_tests = "python -m pytest -v -s --color=yes tests/unit"
118
134
  integration_tests = "echo 'integration_tests: no suite yet, skipping (no-op)' >&2; true"
119
135
 
120
136
 
137
+ # -----------------------------------------------------------------------------
138
+ # cov
139
+ # -----------------------------------------------------------------------------
140
+ # - Runs the unit tests under coverage (no integration suite yet); reports uncovered lines.
141
+ # Quoting: "..." — single command / simple chain; extra args (-x, -k, etc.) are appended
142
+ cov = "python -m pytest -v -s --color=yes tests/unit --cov=ll_cli --cov-report=term-missing"
143
+
144
+
121
145
  # -----------------------------------------------------------------------------
122
146
  # e2e_tests
123
147
  # -----------------------------------------------------------------------------
124
- # Runs the SBOMaaS pipeline (with sbomaas_ingest + sbomaas_export) in a freshly
125
- # built local Jenkins container; pytest runs on the host (outside the container),
126
- # uploads a zipped sample, downloads the SBOM, and checks it.
148
+ # Runs the SBOMaaS pipeline (with sbomaas_ingest + sbomaas_export) in a local
149
+ # Jenkins container from the registry image of the pinned sbomaas-jenkins;
150
+ # pytest runs on the host (outside the container), uploads a zipped sample,
151
+ # downloads the SBOM, and checks it.
127
152
  # Quoting: '''...''' — multi-step script; extra args are appended to last line (no trailing newline before closing quotes)
128
153
  e2e_tests = '''
129
154
  set -eu
@@ -131,18 +156,13 @@ e2e_tests = '''
131
156
  python -m mypy --strict --color-output tests/e2e
132
157
 
133
158
  set -a
134
- . ./.env.dev
159
+ . config/dev/ll_cli.env
160
+ . ~/.sbomaas/secrets/dev/ll_cli.env
135
161
  set +a
136
162
 
137
- # Test the Jenkinsfile on the branch we're actually on: sbomaas-multi clones
138
- # SBOMAAS_JENKINSFILE_REPO_BRANCH from the remote and `git push` below
139
- # publishes the current branch — so pin the clone branch to the current
140
- # checkout, overriding the fixed default from .env.dev.
141
- export SBOMAAS_JENKINSFILE_REPO_BRANCH="$(git branch --show-current)"
142
-
143
- python scripts/update_images_in_jenkinsfile.py --dry-run
163
+ update-images-in-jenkinsfile --dry-run
144
164
 
145
- # sbomaas-multi clones the Jenkinsfile from the bitbucket remote, so any
165
+ # sbomaas-jenkins clones the Jenkinsfile from the bitbucket remote, so any
146
166
  # local edits to $SBOMAAS_JENKINSFILE_PATH_IN_REPO must be pushed first.
147
167
  # We refuse to auto-commit unstaged edits — commit them yourself so the
148
168
  # commit message reflects the actual change.
@@ -150,18 +170,10 @@ e2e_tests = '''
150
170
  echo "Error: $SBOMAAS_JENKINSFILE_PATH_IN_REPO has uncommitted changes. Commit them before running e2e tests so the remote has your changes."
151
171
  exit 1
152
172
  fi
153
- git push
154
-
155
- # Build Jenkins container image and start container.
156
- # sbomaas-multi reads PCR creds from ~/.docker/config.json (populated by a
157
- # one-time `docker login pcr.stage.eu.langlauf.tech:5000`) and runs the
158
- # in-container `docker login` itself — see docker_login_in_jenkins_container
159
- # in main.py. No PCR env vars or pre-existing docker login on the Jenkins
160
- # container required at task time.
161
- poetry run sbomaas-multi \
162
- --no-keep-jenkins-home \
163
- --dot-env-file ../sbomaas_export/.env.dev:sbomaas_export_dot_env \
164
- --dot-env-file ../sbomaas_ingest/.env.dev:sbomaas_ingest_dot_env
173
+
174
+ poetry run task push_checked_out_ref_and_write_it_to_jenkinsfile_ref_file
175
+
176
+ poetry run sbomaas-jenkins up --wipe-jenkins-home
165
177
 
166
178
  # Run pytest locally (uses ll-cli to upload + curl to download from Jenkins container)
167
179
  # ↓ closing quotes must be on this line so taskipy forwards extra args (e.g. -x) to pytest
@@ -171,10 +183,11 @@ e2e_tests = '''
171
183
  # Quoting: '''...''' — multi-step script; extra args (e.g. --dry-run) are appended to last line (no trailing newline before closing quotes)
172
184
  update_jenkinsfile = '''
173
185
  set -a
174
- . ./.env.dev
186
+ . config/dev/ll_cli.env
187
+ . ~/.sbomaas/secrets/dev/ll_cli.env
175
188
  set +a
176
189
 
177
- python scripts/update_images_in_jenkinsfile.py'''
190
+ update-images-in-jenkinsfile'''
178
191
 
179
192
 
180
193
  # -----------------------------------------------------------------------------
File without changes