quality-graph-cli 0.1.8__tar.gz → 0.1.10__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,4 +1,5 @@
1
1
  .venv/
2
+ .env
2
3
  __pycache__/
3
4
  *.py[cod]
4
5
  .pytest_cache/
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quality-graph-cli
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: Provider-driven Quality Graph command-line application
5
- Project-URL: Homepage, https://alchemmist.github.io/quality-graph/
6
- Project-URL: Documentation, https://alchemmist.github.io/quality-graph/
5
+ Project-URL: Homepage, https://quality-graph.xyz/
6
+ Project-URL: Documentation, https://quality-graph.xyz/
7
7
  License-Expression: MIT
8
8
  Requires-Python: >=3.12
9
- Requires-Dist: quality-graph-core==0.1.8
9
+ Requires-Dist: quality-graph-core==0.1.10
10
10
  Description-Content-Type: text/markdown
11
11
 
12
12
  # qg
@@ -15,7 +15,7 @@ Provider-driven command-line application for Quality Graph projects.
15
15
 
16
16
  The CLI discovers providers through the `qg.providers` entry-point group. Install it together
17
17
  with the GitHub provider using
18
- `uv tool install quality-graph-cli==0.1.2 --with quality-graph-github==0.1.2`.
18
+ `uv tool install quality-graph-cli==0.1.8 --with quality-graph-github==0.1.8`.
19
19
 
20
20
  Initialize a repository with its default branch, generate the provider-owned files, and list
21
21
  those paths for repository tooling:
@@ -4,7 +4,7 @@ Provider-driven command-line application for Quality Graph projects.
4
4
 
5
5
  The CLI discovers providers through the `qg.providers` entry-point group. Install it together
6
6
  with the GitHub provider using
7
- `uv tool install quality-graph-cli==0.1.2 --with quality-graph-github==0.1.2`.
7
+ `uv tool install quality-graph-cli==0.1.8 --with quality-graph-github==0.1.8`.
8
8
 
9
9
  Initialize a repository with its default branch, generate the provider-owned files, and list
10
10
  those paths for repository tooling:
@@ -4,16 +4,16 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "quality-graph-cli"
7
- version = "0.1.8"
7
+ version = "0.1.10"
8
8
  description = "Provider-driven Quality Graph command-line application"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
11
11
  license = "MIT"
12
- dependencies = ["quality-graph-core==0.1.8"]
12
+ dependencies = ["quality-graph-core==0.1.10"]
13
13
 
14
14
  [project.urls]
15
- Homepage = "https://alchemmist.github.io/quality-graph/"
16
- Documentation = "https://alchemmist.github.io/quality-graph/"
15
+ Homepage = "https://quality-graph.xyz/"
16
+ Documentation = "https://quality-graph.xyz/"
17
17
 
18
18
  [project.scripts]
19
19
  qg = "qg_cli.cli:main"
@@ -63,6 +63,8 @@ def parser() -> argparse.ArgumentParser:
63
63
  emit.add_argument("--metric", action="append", default=[])
64
64
  emit.add_argument("--repository", required=True)
65
65
  emit.add_argument("--pull-request", type=int)
66
+ emit.add_argument("--flow-id")
67
+ emit.add_argument("--operation-id")
66
68
  emit.add_argument("--head-sha", required=True)
67
69
  emit.add_argument("--workflow-run-id", type=int, required=True)
68
70
  emit.add_argument("--run-attempt", type=int, required=True)
@@ -160,6 +162,8 @@ def _emitted_result(args: argparse.Namespace) -> Result:
160
162
  args.run_attempt,
161
163
  args.graph_digest,
162
164
  args.pull_request,
165
+ args.flow_id,
166
+ args.operation_id,
163
167
  ),
164
168
  failure,
165
169
  args.summary,
@@ -57,7 +57,21 @@ class Project:
57
57
  def generate(self) -> GeneratedProject:
58
58
  """Write every deterministic generated file."""
59
59
  generated = self.render()
60
+ self._validate_output_paths(generated)
60
61
  prettier_ignore = self._prettier_ignore(generated)
62
+ retired = self._retired_paths(generated)
63
+ for path in retired:
64
+ if (path.exists() or path.is_symlink()) and (
65
+ path.is_symlink()
66
+ or not path.read_text().startswith(
67
+ "# Generated by Quality Graph. DO NOT EDIT MANUALLY."
68
+ )
69
+ ):
70
+ message = f"Refusing to remove an unmanaged retired workflow: {path}"
71
+ raise ValueError(message)
72
+ for path in retired:
73
+ if path.exists():
74
+ path.unlink()
61
75
  for item in generated.files:
62
76
  path = self.root / item.path
63
77
  path.parent.mkdir(parents=True, exist_ok=True)
@@ -67,6 +81,34 @@ class Project:
67
81
  ignore_path.write_text(prettier_ignore)
68
82
  return generated
69
83
 
84
+ def _validate_output_paths(self, generated: GeneratedProject) -> None:
85
+ root = self.root.resolve()
86
+ for relative in (*[item.path for item in generated.files], PRETTIER_IGNORE_PATH):
87
+ path = self.root / relative
88
+ if root not in path.resolve().parents:
89
+ message = f"Generated file is outside the project root: {path}"
90
+ raise ValueError(message)
91
+ if path.is_symlink():
92
+ message = f"Refusing to overwrite a generated-file symbolic link: {path}"
93
+ raise ValueError(message)
94
+
95
+ def _retired_paths(self, generated: GeneratedProject) -> tuple[Path, ...]:
96
+ root = self.root.resolve()
97
+ required = tuple(self.root / path for path in generated.retired_files)
98
+ optional = tuple(self.root / path for path in generated.retired_if_generated)
99
+ for path in (*required, *optional):
100
+ if root not in path.resolve().parents:
101
+ message = f"Retired workflow is outside the project root: {path}"
102
+ raise ValueError(message)
103
+ owned = tuple(
104
+ path
105
+ for path in optional
106
+ if not path.is_symlink()
107
+ and path.is_file()
108
+ and path.read_text().startswith("# Generated by Quality Graph. DO NOT EDIT MANUALLY.")
109
+ )
110
+ return (*required, *owned)
111
+
70
112
  def generated_files(self) -> tuple[PurePosixPath, ...]:
71
113
  """Return stable repository-relative compiler-owned paths."""
72
114
  return tuple(item.path for item in self.render().files)
@@ -74,7 +116,14 @@ class Project:
74
116
  def validate(self) -> ValidationReport:
75
117
  """Compare generated output without mutating files."""
76
118
  problems: list[str] = []
77
- for item in self.render().files:
119
+ generated = self.render()
120
+ self._validate_output_paths(generated)
121
+ problems.extend(
122
+ f"retired generated file: {path.relative_to(self.root)}"
123
+ for path in self._retired_paths(generated)
124
+ if path.exists() or path.is_symlink()
125
+ )
126
+ for item in generated.files:
78
127
  path = self.root / item.path
79
128
  if not path.is_file():
80
129
  problems.append(f"missing generated file: {item.path}")