quality-graph-github 0.1.4__py3-none-any.whl → 0.1.7__py3-none-any.whl
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.
- qg_github/commands.py +2 -1
- qg_github/compiler.py +180 -25
- qg_github/publication.py +29 -17
- {quality_graph_github-0.1.4.dist-info → quality_graph_github-0.1.7.dist-info}/METADATA +4 -2
- {quality_graph_github-0.1.4.dist-info → quality_graph_github-0.1.7.dist-info}/RECORD +7 -7
- {quality_graph_github-0.1.4.dist-info → quality_graph_github-0.1.7.dist-info}/WHEEL +0 -0
- {quality_graph_github-0.1.4.dist-info → quality_graph_github-0.1.7.dist-info}/entry_points.txt +0 -0
qg_github/commands.py
CHANGED
|
@@ -10,7 +10,7 @@ from enum import StrEnum
|
|
|
10
10
|
|
|
11
11
|
from qg_github.approvals import ApprovalRecord, append_approval_record
|
|
12
12
|
from qg_github.artifacts import ArtifactExpectation, download_results
|
|
13
|
-
from qg_github.compiler import compile_graph
|
|
13
|
+
from qg_github.compiler import compile_graph, project_graph
|
|
14
14
|
from qg_github.controls import control_states, decode_control_marker
|
|
15
15
|
from qg_github.github import GITHUB_PAGE_SIZE, GitHubPort
|
|
16
16
|
from quality_graph_core.graph import Graph
|
|
@@ -187,6 +187,7 @@ def _command_context(port: GitHubPort, number: int) -> CommandContext:
|
|
|
187
187
|
base_sha = _string(base.get("sha"), "pull request base SHA")
|
|
188
188
|
graph = Graph.from_yaml(_repository_file(port, "quality-graph.yml", base_sha))
|
|
189
189
|
compiled = compile_graph(graph)
|
|
190
|
+
graph = project_graph(graph, "pull-request")
|
|
190
191
|
run = _latest_run(port, number)
|
|
191
192
|
run_id = _integer(run.get("id"), "workflow run id")
|
|
192
193
|
attempt = _integer(run.get("run_attempt", 1), "workflow run attempt")
|
qg_github/compiler.py
CHANGED
|
@@ -5,12 +5,13 @@ from __future__ import annotations
|
|
|
5
5
|
import hashlib
|
|
6
6
|
import json
|
|
7
7
|
import re
|
|
8
|
+
from dataclasses import dataclass, replace
|
|
8
9
|
from pathlib import PurePosixPath
|
|
9
10
|
from typing import TYPE_CHECKING, cast, override
|
|
10
11
|
|
|
11
12
|
import yaml
|
|
12
13
|
|
|
13
|
-
from quality_graph_core.graph import Graph, LabelSpec, Node, Profile, Step
|
|
14
|
+
from quality_graph_core.graph import DependencyPolicy, Graph, LabelSpec, Node, Profile, Step
|
|
14
15
|
from quality_graph_core.provider import GeneratedFile, GeneratedProject
|
|
15
16
|
|
|
16
17
|
if TYPE_CHECKING:
|
|
@@ -24,9 +25,10 @@ GENERATED_NOTICE = (
|
|
|
24
25
|
)
|
|
25
26
|
GENERATED_HEADER = f"# {GENERATED_NOTICE}\n---\n"
|
|
26
27
|
EXECUTION_WORKFLOW = PurePosixPath(".github/workflows/quality-graph.yml")
|
|
28
|
+
PUSH_WORKFLOW = PurePosixPath(".github/workflows/quality-graph-push.yml")
|
|
27
29
|
PUBLICATION_WORKFLOW = PurePosixPath(".github/workflows/quality-graph-publish.yml")
|
|
28
30
|
GRAPH_MANIFEST = PurePosixPath(".quality-graph/manifest.json")
|
|
29
|
-
|
|
31
|
+
DEFAULT_UPLOAD_ARTIFACT_ACTION = "actions/upload-artifact@v7"
|
|
30
32
|
ACTION_RE = re.compile(r"^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+(?:/[A-Za-z0-9_.-]+)?@[A-Za-z0-9_.:/-]+$")
|
|
31
33
|
RUNTIME_ACTION_RE = re.compile(r"^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+@[0-9a-f]{40}$")
|
|
32
34
|
PERMISSION_NAMES = {
|
|
@@ -44,6 +46,26 @@ PERMISSION_NAMES = {
|
|
|
44
46
|
"security-events",
|
|
45
47
|
"statuses",
|
|
46
48
|
}
|
|
49
|
+
INVALID_BRANCH_CHARACTER_RE = re.compile(r"[\x00-\x20\x7f ~^:?*\[\\]")
|
|
50
|
+
MAX_BRANCH_NAME_LENGTH = 255
|
|
51
|
+
SUPPORTED_EVENTS = ("pull-request", "push")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass(frozen=True)
|
|
55
|
+
class EventProjection:
|
|
56
|
+
"""Carry one provider-validated event projection into workflow generation."""
|
|
57
|
+
|
|
58
|
+
event: str
|
|
59
|
+
nodes: tuple[Node, ...]
|
|
60
|
+
dependencies: DependencyPolicy
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclass(frozen=True)
|
|
64
|
+
class _GitHubConfiguration:
|
|
65
|
+
runtime_action: str
|
|
66
|
+
publisher_action: str
|
|
67
|
+
upload_artifact_action: str
|
|
68
|
+
default_branch: str
|
|
47
69
|
|
|
48
70
|
|
|
49
71
|
class WorkflowDumper(yaml.SafeDumper):
|
|
@@ -60,11 +82,11 @@ class WorkflowDumper(yaml.SafeDumper):
|
|
|
60
82
|
super().increase_indent(flow, indentless=False)
|
|
61
83
|
|
|
62
84
|
|
|
63
|
-
def _validate_github_graph(graph: Graph) ->
|
|
85
|
+
def _validate_github_graph(graph: Graph) -> _GitHubConfiguration:
|
|
64
86
|
if graph.provider.name != "github":
|
|
65
87
|
message = f"GitHub provider cannot compile provider '{graph.provider.name}'"
|
|
66
88
|
raise ValueError(message)
|
|
67
|
-
unknown = graph.provider.values.keys() - {"runtime"}
|
|
89
|
+
unknown = graph.provider.values.keys() - {"default-branch", "runtime"}
|
|
68
90
|
if unknown:
|
|
69
91
|
message = f"GitHub provider contains unknown configuration: {', '.join(sorted(unknown))}"
|
|
70
92
|
raise ValueError(message)
|
|
@@ -72,11 +94,13 @@ def _validate_github_graph(graph: Graph) -> tuple[str, str]:
|
|
|
72
94
|
if not isinstance(runtime, dict):
|
|
73
95
|
message = "GitHub provider requires a runtime object"
|
|
74
96
|
raise TypeError(message)
|
|
75
|
-
if runtime.keys() - {"action", "publisher-action"}:
|
|
97
|
+
if runtime.keys() - {"action", "publisher-action", "upload-artifact-action"}:
|
|
76
98
|
message = "GitHub runtime contains unknown fields"
|
|
77
99
|
raise ValueError(message)
|
|
78
100
|
action = _runtime_action(runtime.get("action"), "runtime")
|
|
79
101
|
publisher_action = _runtime_action(runtime.get("publisher-action", action), "publisher")
|
|
102
|
+
upload_artifact_action = _upload_artifact_action(runtime)
|
|
103
|
+
default_branch = _default_branch(graph.provider.values.get("default-branch"))
|
|
80
104
|
if publisher_action.partition("@")[0] != action.partition("@")[0]:
|
|
81
105
|
message = "GitHub publisher action must use the runtime action repository"
|
|
82
106
|
raise ValueError(message)
|
|
@@ -90,7 +114,76 @@ def _validate_github_graph(graph: Graph) -> tuple[str, str]:
|
|
|
90
114
|
if len(set(titles)) != len(titles):
|
|
91
115
|
message = "GitHub dashboard requires unique node titles"
|
|
92
116
|
raise ValueError(message)
|
|
93
|
-
|
|
117
|
+
_event_projections(graph)
|
|
118
|
+
return _GitHubConfiguration(action, publisher_action, upload_artifact_action, default_branch)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _event_projections(graph: Graph) -> tuple[EventProjection, ...]:
|
|
122
|
+
supported = set(SUPPORTED_EVENTS)
|
|
123
|
+
unknown = set(graph.execution) - supported
|
|
124
|
+
for node in graph.nodes:
|
|
125
|
+
unknown.update(set(node.events) - supported)
|
|
126
|
+
if unknown:
|
|
127
|
+
names = ", ".join(sorted(unknown))
|
|
128
|
+
message = f"GitHub provider contains unsupported execution events: {names}"
|
|
129
|
+
raise ValueError(message)
|
|
130
|
+
projections: list[EventProjection] = []
|
|
131
|
+
for event in SUPPORTED_EVENTS:
|
|
132
|
+
nodes = tuple(node for node in graph.nodes if not node.events or event in node.events)
|
|
133
|
+
if not nodes:
|
|
134
|
+
message = f"GitHub {event} event projection must contain at least one node"
|
|
135
|
+
raise ValueError(message)
|
|
136
|
+
dependency_policy = graph.execution.get(event, DependencyPolicy.GRAPH)
|
|
137
|
+
if dependency_policy is DependencyPolicy.GRAPH:
|
|
138
|
+
selected = {node.id for node in nodes}
|
|
139
|
+
for node in nodes:
|
|
140
|
+
missing = set(node.needs) - selected
|
|
141
|
+
if missing:
|
|
142
|
+
message = (
|
|
143
|
+
f"GitHub {event} event projection excludes dependencies of {node.id}: "
|
|
144
|
+
f"{', '.join(sorted(missing))}"
|
|
145
|
+
)
|
|
146
|
+
raise ValueError(message)
|
|
147
|
+
else:
|
|
148
|
+
nodes = tuple(replace(node, needs=()) for node in nodes)
|
|
149
|
+
projections.append(EventProjection(event, nodes, dependency_policy))
|
|
150
|
+
return tuple(projections)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def event_projection(graph: Graph, event: str) -> EventProjection:
|
|
154
|
+
"""Return one validated GitHub event projection."""
|
|
155
|
+
for projection in _event_projections(graph):
|
|
156
|
+
if projection.event == event:
|
|
157
|
+
return projection
|
|
158
|
+
message = f"GitHub provider does not support execution event: {event}"
|
|
159
|
+
raise ValueError(message)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def project_graph(graph: Graph, event: str) -> Graph:
|
|
163
|
+
"""Return one dependency-normalized GitHub event graph."""
|
|
164
|
+
return replace(graph, nodes=event_projection(graph, event).nodes)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _default_branch(value: JsonValue) -> str:
|
|
168
|
+
branch = "main" if value is None else value
|
|
169
|
+
if not isinstance(branch, str) or not 1 <= len(branch) <= MAX_BRANCH_NAME_LENGTH:
|
|
170
|
+
message = "GitHub default branch must be a non-empty string of at most 255 characters"
|
|
171
|
+
raise ValueError(message)
|
|
172
|
+
parts = branch.split("/")
|
|
173
|
+
invalid = (
|
|
174
|
+
branch in {"@", "HEAD"}
|
|
175
|
+
or branch.startswith(("-", "!"))
|
|
176
|
+
or branch.endswith(("/", "."))
|
|
177
|
+
or "//" in branch
|
|
178
|
+
or ".." in branch
|
|
179
|
+
or "@{" in branch
|
|
180
|
+
or INVALID_BRANCH_CHARACTER_RE.search(branch) is not None
|
|
181
|
+
or any(not part or part.startswith(".") or part.endswith(".lock") for part in parts)
|
|
182
|
+
)
|
|
183
|
+
if invalid:
|
|
184
|
+
message = f"GitHub default branch is invalid: {branch}"
|
|
185
|
+
raise ValueError(message)
|
|
186
|
+
return branch
|
|
94
187
|
|
|
95
188
|
|
|
96
189
|
def _runtime_action(value: JsonValue, context: str) -> str:
|
|
@@ -100,6 +193,12 @@ def _runtime_action(value: JsonValue, context: str) -> str:
|
|
|
100
193
|
return value
|
|
101
194
|
|
|
102
195
|
|
|
196
|
+
def _upload_artifact_action(runtime: Mapping[str, JsonValue]) -> str:
|
|
197
|
+
if "upload-artifact-action" not in runtime:
|
|
198
|
+
return DEFAULT_UPLOAD_ARTIFACT_ACTION
|
|
199
|
+
return _runtime_action(runtime["upload-artifact-action"], "upload artifact")
|
|
200
|
+
|
|
201
|
+
|
|
103
202
|
def _validate_permissions(profile: Profile) -> None:
|
|
104
203
|
for permission, access in profile.permissions.items():
|
|
105
204
|
if permission not in PERMISSION_NAMES:
|
|
@@ -121,38 +220,81 @@ def _validate_step(step: Step) -> None:
|
|
|
121
220
|
|
|
122
221
|
def compile_graph(graph: Graph) -> GeneratedProject:
|
|
123
222
|
"""Compile one graph through the public declaration seam."""
|
|
124
|
-
|
|
125
|
-
|
|
223
|
+
configuration = _validate_github_graph(graph)
|
|
224
|
+
projections = {item.event: item for item in _event_projections(graph)}
|
|
225
|
+
manifest = _manifest_value(graph, configuration)
|
|
126
226
|
digest = hashlib.sha256(_canonical_json(manifest).encode()).hexdigest()
|
|
127
227
|
manifest["graphDigest"] = digest
|
|
128
228
|
manifest["_generated"] = GENERATED_NOTICE
|
|
129
229
|
files = (
|
|
130
230
|
GeneratedFile(
|
|
131
231
|
EXECUTION_WORKFLOW,
|
|
132
|
-
_yaml_file(
|
|
232
|
+
_yaml_file(
|
|
233
|
+
_execution_workflow(
|
|
234
|
+
graph,
|
|
235
|
+
projections["pull-request"],
|
|
236
|
+
configuration,
|
|
237
|
+
digest,
|
|
238
|
+
)
|
|
239
|
+
),
|
|
240
|
+
),
|
|
241
|
+
GeneratedFile(
|
|
242
|
+
PUSH_WORKFLOW,
|
|
243
|
+
_yaml_file(
|
|
244
|
+
_execution_workflow(
|
|
245
|
+
graph,
|
|
246
|
+
projections["push"],
|
|
247
|
+
configuration,
|
|
248
|
+
digest,
|
|
249
|
+
)
|
|
250
|
+
),
|
|
133
251
|
),
|
|
134
252
|
GeneratedFile(
|
|
135
253
|
PUBLICATION_WORKFLOW,
|
|
136
|
-
_yaml_file(_publication_workflow(publisher_action)),
|
|
254
|
+
_yaml_file(_publication_workflow(configuration.publisher_action)),
|
|
137
255
|
),
|
|
138
256
|
GeneratedFile(GRAPH_MANIFEST, _canonical_json(manifest)),
|
|
139
257
|
)
|
|
140
258
|
return GeneratedProject(digest, files)
|
|
141
259
|
|
|
142
260
|
|
|
143
|
-
def _manifest_value(
|
|
261
|
+
def _manifest_value(
|
|
262
|
+
graph: Graph,
|
|
263
|
+
configuration: _GitHubConfiguration,
|
|
264
|
+
) -> dict[str, JsonValue]:
|
|
144
265
|
profiles = graph.expanded_profiles()
|
|
145
|
-
|
|
266
|
+
value: dict[str, JsonValue] = {
|
|
146
267
|
"manifestVersion": 0,
|
|
147
268
|
"graphVersion": graph.version,
|
|
148
269
|
"provider": graph.provider.name,
|
|
149
270
|
"resultSchemaVersion": 0,
|
|
150
|
-
"runtime": {"action": runtime_action},
|
|
271
|
+
"runtime": {"action": configuration.runtime_action},
|
|
151
272
|
"profiles": {name: _profile_value(profile) for name, profile in profiles.items()},
|
|
152
273
|
"nodes": [_node_value(node, profiles[node.profile]) for node in graph.nodes],
|
|
153
274
|
"labels": _labels_value(graph),
|
|
154
275
|
"administration": {"roles": list(graph.administrator_roles)},
|
|
155
276
|
}
|
|
277
|
+
if "default-branch" in graph.provider.values:
|
|
278
|
+
value["defaultBranch"] = configuration.default_branch
|
|
279
|
+
runtime = cast("dict[str, JsonValue]", graph.provider.values["runtime"])
|
|
280
|
+
if "upload-artifact-action" in runtime:
|
|
281
|
+
cast("dict[str, JsonValue]", value["runtime"])["uploadArtifactAction"] = (
|
|
282
|
+
configuration.upload_artifact_action
|
|
283
|
+
)
|
|
284
|
+
if graph.execution or any(node.events for node in graph.nodes):
|
|
285
|
+
value["execution"] = {
|
|
286
|
+
event: {
|
|
287
|
+
"dependencies": graph.execution.get(event, DependencyPolicy.GRAPH).value,
|
|
288
|
+
}
|
|
289
|
+
for event in SUPPORTED_EVENTS
|
|
290
|
+
}
|
|
291
|
+
effective_events = {node.id: list(node.events or SUPPORTED_EVENTS) for node in graph.nodes}
|
|
292
|
+
for node_value in cast("list[dict[str, JsonValue]]", value["nodes"]):
|
|
293
|
+
node_value["events"] = cast(
|
|
294
|
+
"JsonValue",
|
|
295
|
+
effective_events[cast("str", node_value["id"])],
|
|
296
|
+
)
|
|
297
|
+
return value
|
|
156
298
|
|
|
157
299
|
|
|
158
300
|
def _profile_value(profile: Profile) -> dict[str, JsonValue]:
|
|
@@ -229,21 +371,34 @@ def _label_value(label: LabelSpec) -> dict[str, JsonValue]:
|
|
|
229
371
|
|
|
230
372
|
def _execution_workflow(
|
|
231
373
|
graph: Graph,
|
|
232
|
-
|
|
374
|
+
projection: EventProjection,
|
|
375
|
+
configuration: _GitHubConfiguration,
|
|
233
376
|
digest: str,
|
|
234
377
|
) -> dict[str, JsonValue]:
|
|
235
378
|
profiles = graph.expanded_profiles()
|
|
236
379
|
jobs: dict[str, JsonValue] = {
|
|
237
|
-
node.id: _execution_job(
|
|
238
|
-
|
|
380
|
+
node.id: _execution_job(
|
|
381
|
+
node,
|
|
382
|
+
profiles[node.profile],
|
|
383
|
+
configuration,
|
|
384
|
+
digest,
|
|
385
|
+
)
|
|
386
|
+
for node in projection.nodes
|
|
239
387
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
388
|
+
trigger: dict[str, JsonValue]
|
|
389
|
+
name: str
|
|
390
|
+
if projection.event == "pull-request":
|
|
391
|
+
name = "Quality Graph"
|
|
392
|
+
trigger = {
|
|
393
|
+
"pull_request": {"branches": [configuration.default_branch]},
|
|
245
394
|
"workflow_dispatch": {},
|
|
246
|
-
}
|
|
395
|
+
}
|
|
396
|
+
else:
|
|
397
|
+
name = "Quality Graph (push)"
|
|
398
|
+
trigger = {"push": {"branches": [configuration.default_branch]}}
|
|
399
|
+
return {
|
|
400
|
+
"name": name,
|
|
401
|
+
"on": trigger,
|
|
247
402
|
"permissions": {"contents": "read"},
|
|
248
403
|
"concurrency": {
|
|
249
404
|
"group": "quality-graph-${{ github.workflow }}-${{ github.ref }}",
|
|
@@ -256,7 +411,7 @@ def _execution_workflow(
|
|
|
256
411
|
def _execution_job(
|
|
257
412
|
node: Node,
|
|
258
413
|
profile: Profile,
|
|
259
|
-
|
|
414
|
+
configuration: _GitHubConfiguration,
|
|
260
415
|
graph_digest: str,
|
|
261
416
|
) -> dict[str, JsonValue]:
|
|
262
417
|
runner = cast("str", profile.runner)
|
|
@@ -274,7 +429,7 @@ def _execution_job(
|
|
|
274
429
|
"name": f"Collect {node.title} result",
|
|
275
430
|
"id": "quality-result",
|
|
276
431
|
"if": "always()",
|
|
277
|
-
"uses": runtime_action,
|
|
432
|
+
"uses": configuration.runtime_action,
|
|
278
433
|
"with": {
|
|
279
434
|
"operation": "collect",
|
|
280
435
|
"node-id": node.id,
|
|
@@ -291,7 +446,7 @@ def _execution_job(
|
|
|
291
446
|
upload: dict[str, JsonValue] = {
|
|
292
447
|
"name": f"Upload {node.title} result",
|
|
293
448
|
"if": "always()",
|
|
294
|
-
"uses":
|
|
449
|
+
"uses": configuration.upload_artifact_action,
|
|
295
450
|
"with": {
|
|
296
451
|
"name": f"quality-result-{node.id}-${{{{ github.run_attempt }}}}",
|
|
297
452
|
"path": result_path,
|
qg_github/publication.py
CHANGED
|
@@ -12,7 +12,7 @@ from typing import TYPE_CHECKING, cast
|
|
|
12
12
|
from qg_github.approvals import approval_ledger
|
|
13
13
|
from qg_github.artifacts import ArtifactError, ArtifactExpectation, download_results
|
|
14
14
|
from qg_github.comments import find_managed_comment, upsert_managed_comment
|
|
15
|
-
from qg_github.compiler import compile_graph
|
|
15
|
+
from qg_github.compiler import compile_graph, project_graph
|
|
16
16
|
from qg_github.dashboard import (
|
|
17
17
|
DASHBOARD_MARKER,
|
|
18
18
|
DashboardModel,
|
|
@@ -110,6 +110,7 @@ def publish_workflow_run(
|
|
|
110
110
|
return PublicationOutcome(published=False)
|
|
111
111
|
graph = Graph.from_yaml(_repository_file(port, "quality-graph.yml", pull.base_sha))
|
|
112
112
|
compiled = compile_graph(graph)
|
|
113
|
+
graph = project_graph(graph, "pull-request")
|
|
113
114
|
run = DashboardRun(event.id, event.attempt, pull.head_sha, event.url)
|
|
114
115
|
model, effective_results = _completed_dashboard(
|
|
115
116
|
port,
|
|
@@ -155,6 +156,7 @@ def watch_workflow_run(
|
|
|
155
156
|
if not _is_latest_run(port, event, number):
|
|
156
157
|
return PublicationOutcome(published=False)
|
|
157
158
|
graph = Graph.from_yaml(_repository_file(port, "quality-graph.yml", pull.base_sha))
|
|
159
|
+
graph = project_graph(graph, "pull-request")
|
|
158
160
|
nodes = tuple(DashboardNode(node.id, node.title) for node in graph.nodes)
|
|
159
161
|
run = DashboardRun(event.id, event.attempt, pull.head_sha, event.url)
|
|
160
162
|
_publish_check(port, pending_dashboard(graph, run))
|
|
@@ -176,19 +178,11 @@ def publish_workflow_jobs(
|
|
|
176
178
|
is_current: Callable[[], bool] = lambda: True,
|
|
177
179
|
) -> bool:
|
|
178
180
|
"""Merge authoritative job lifecycle into the single live dashboard."""
|
|
179
|
-
|
|
180
|
-
statuses
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
name = _string(job.get("name"), "workflow job name")
|
|
185
|
-
node_id = by_title.get(name)
|
|
186
|
-
if node_id is None:
|
|
187
|
-
continue
|
|
188
|
-
status = _workflow_job_status(job)
|
|
189
|
-
statuses[node_id] = status
|
|
190
|
-
terminal = terminal and status not in {ResultStatus.WAITING, ResultStatus.IN_PROGRESS}
|
|
191
|
-
terminal = terminal and len(statuses) == len(nodes)
|
|
181
|
+
statuses = _workflow_node_statuses(port, nodes, run.id)
|
|
182
|
+
terminal = len(statuses) == len(nodes) and all(
|
|
183
|
+
status not in {ResultStatus.WAITING, ResultStatus.IN_PROGRESS}
|
|
184
|
+
for status in statuses.values()
|
|
185
|
+
)
|
|
192
186
|
if terminal or not is_current():
|
|
193
187
|
return True
|
|
194
188
|
existing = find_managed_comment(port, number, DASHBOARD_MARKER)
|
|
@@ -217,6 +211,23 @@ def _workflow_jobs(port: GitHubPort, run_id: int) -> tuple[JsonValue, ...]:
|
|
|
217
211
|
page += 1
|
|
218
212
|
|
|
219
213
|
|
|
214
|
+
def _workflow_node_statuses(
|
|
215
|
+
port: GitHubPort,
|
|
216
|
+
nodes: tuple[DashboardNode, ...],
|
|
217
|
+
run_id: int,
|
|
218
|
+
) -> dict[str, ResultStatus]:
|
|
219
|
+
"""Map declared nodes to authoritative GitHub workflow job statuses."""
|
|
220
|
+
by_title = {node.title: node.node_id for node in nodes}
|
|
221
|
+
statuses: dict[str, ResultStatus] = {}
|
|
222
|
+
for value in _workflow_jobs(port, run_id):
|
|
223
|
+
job = _object(value, "workflow job")
|
|
224
|
+
name = _string(job.get("name"), "workflow job name")
|
|
225
|
+
node_id = by_title.get(name)
|
|
226
|
+
if node_id is not None:
|
|
227
|
+
statuses[node_id] = _workflow_job_status(job)
|
|
228
|
+
return statuses
|
|
229
|
+
|
|
230
|
+
|
|
220
231
|
def _workflow_job_status(job: Mapping[str, JsonValue]) -> ResultStatus:
|
|
221
232
|
status = _string(job.get("status"), "workflow job status")
|
|
222
233
|
if status == "queued":
|
|
@@ -254,13 +265,14 @@ def _completed_dashboard(
|
|
|
254
265
|
try:
|
|
255
266
|
results = download_results(port, expectation)
|
|
256
267
|
except ArtifactError as error:
|
|
257
|
-
|
|
268
|
+
nodes = tuple(DashboardNode(node.id, node.title) for node in graph.nodes)
|
|
269
|
+
statuses = _workflow_node_statuses(port, nodes, run.id)
|
|
270
|
+
fallback = live_dashboard(nodes, statuses, run)
|
|
258
271
|
return (
|
|
259
272
|
replace(
|
|
260
|
-
|
|
273
|
+
fallback,
|
|
261
274
|
status=ResultStatus.FAILED,
|
|
262
275
|
message=f"The final dashboard could not be assembled: {error}",
|
|
263
|
-
rows=tuple(replace(row, status=ResultStatus.FAILED) for row in pending.rows),
|
|
264
276
|
),
|
|
265
277
|
None,
|
|
266
278
|
)
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quality-graph-github
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: GitHub provider and Action runtime for Quality Graph
|
|
5
|
+
Project-URL: Homepage, https://alchemmist.github.io/quality-graph/
|
|
6
|
+
Project-URL: Documentation, https://alchemmist.github.io/quality-graph/
|
|
5
7
|
License-Expression: MIT
|
|
6
8
|
Requires-Python: >=3.12
|
|
7
9
|
Requires-Dist: httpx>=0.28.1
|
|
8
10
|
Requires-Dist: jinja2>=3.1.6
|
|
9
11
|
Requires-Dist: pyyaml>=6.0.2
|
|
10
|
-
Requires-Dist: quality-graph-core==0.1.
|
|
12
|
+
Requires-Dist: quality-graph-core==0.1.7
|
|
11
13
|
Description-Content-Type: text/markdown
|
|
12
14
|
|
|
13
15
|
# Quality Graph GitHub Provider
|
|
@@ -2,19 +2,19 @@ qg_github/__init__.py,sha256=ud6DP1C10Vk64U_0T9SZ3f2YpMtJCzsbCGQ5BOtKhG4,106
|
|
|
2
2
|
qg_github/annotations.py,sha256=TwcYcY2g0tT__uVoSmEZuxFTkYrt3llf3mBt0VnG_ss,3217
|
|
3
3
|
qg_github/approvals.py,sha256=v4EDiSXVUgm93bvsH2ka6Olza4cPA8xSa2POf1ktOOM,6052
|
|
4
4
|
qg_github/artifacts.py,sha256=qo3sJ4bPcSU5m5uTPqNZwpodS7Y2BneJ2tsI10bnHUs,7802
|
|
5
|
-
qg_github/commands.py,sha256=
|
|
5
|
+
qg_github/commands.py,sha256=mRcmAMTH7cutFvxk9m5Kz_7-iyapwRaSChJOePCfZyg,12077
|
|
6
6
|
qg_github/comments.py,sha256=8l6acI342hdsT6Cjx-4N406QU73Qv2wMFJsrylt06-8,3417
|
|
7
|
-
qg_github/compiler.py,sha256=
|
|
7
|
+
qg_github/compiler.py,sha256=z0UXfW0Pernee0chxebveYYlXui8aBVsTJYHdEdzmZI,20939
|
|
8
8
|
qg_github/controls.py,sha256=ePTADCzuTNNibNC9k7Q7uw6DNBB7YP7UYdMFPQfIDeM,2554
|
|
9
9
|
qg_github/dashboard.py,sha256=ecAHs7ChHTpqjDJw5oVBnU04DbkHtsYwSFr8fu0iv-M,9881
|
|
10
10
|
qg_github/github.py,sha256=vx7_YhRd_XCCYpC_IvW0hk-tm-nmzGGcZONqQrx4f3A,6979
|
|
11
11
|
qg_github/labels.py,sha256=PT8MnIQZsu896dipMO2880KgUGVcyXH4IJNVQ1oG1zo,4720
|
|
12
12
|
qg_github/provider.py,sha256=9vlC-YrcCYNNaz_CEjFmbQdqfnM8iCYQrcfBBUTn-_Q,578
|
|
13
|
-
qg_github/publication.py,sha256=
|
|
13
|
+
qg_github/publication.py,sha256=JYdGK3lidyesbU6v709x94k1ptt1j-GvSPoUFHRJ7QQ,15103
|
|
14
14
|
qg_github/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
15
15
|
qg_github/reporting.py,sha256=1qo9TPJtf8OCKumRqmzax-nrlLo_2aqsWRaYB7ZuryI,4837
|
|
16
16
|
qg_github/runtime.py,sha256=uO-9m9pSBPKodnrMLLtia8jWVbvubIqm1LoM6A_2AG0,8379
|
|
17
|
-
quality_graph_github-0.1.
|
|
18
|
-
quality_graph_github-0.1.
|
|
19
|
-
quality_graph_github-0.1.
|
|
20
|
-
quality_graph_github-0.1.
|
|
17
|
+
quality_graph_github-0.1.7.dist-info/METADATA,sha256=3JKhGbpgt2iqDE9gzw1Tg1pLews98WP-KkkzxVuIEDc,857
|
|
18
|
+
quality_graph_github-0.1.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
19
|
+
quality_graph_github-0.1.7.dist-info/entry_points.txt,sha256=cSP-mOVXpvGL9nCA7EEfxdrIafFMHwKJEq-wc7DOEyo,43
|
|
20
|
+
quality_graph_github-0.1.7.dist-info/RECORD,,
|
|
File without changes
|
{quality_graph_github-0.1.4.dist-info → quality_graph_github-0.1.7.dist-info}/entry_points.txt
RENAMED
|
File without changes
|