-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (130 loc) · 5.39 KB
/
Copy pathmb3r-report.yml
File metadata and controls
144 lines (130 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: mb3r-report
on:
workflow_call:
inputs:
discovery-artifact-name:
type: string
default: "mb3r-bering-discovery"
gate-artifact-name:
type: string
default: "mb3r-sheaft-gate"
discovery-report-path:
type: string
default: ".mb3r/bering/bering-discovery.json"
gate-report-path:
type: string
default: ".mb3r/sheaft/sheaft-gate.json"
output-dir:
type: string
default: ".mb3r/report"
artifact-name:
type: string
default: "mb3r-report"
upload-artifact:
type: boolean
default: true
outputs:
report-json:
description: Combined report JSON path within the artifact.
value: ${{ jobs.mb3r-report.outputs.report-json }}
report-markdown:
description: Combined report markdown path within the artifact.
value: ${{ jobs.mb3r-report.outputs.report-markdown }}
artifact-name:
description: Uploaded artifact name.
value: ${{ jobs.mb3r-report.outputs.artifact-name }}
overall-decision:
description: Overall stack decision from the merged report.
value: ${{ jobs.mb3r-report.outputs.overall-decision }}
jobs:
mb3r-report:
runs-on: ubuntu-latest
outputs:
report-json: ${{ steps.report.outputs.report-json }}
report-markdown: ${{ steps.report.outputs.report-markdown }}
artifact-name: ${{ steps.report.outputs.artifact-name }}
overall-decision: ${{ steps.report.outputs.overall-decision }}
steps:
- if: ${{ inputs.discovery-artifact-name != '' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.discovery-artifact-name }}
path: .mb3r/input-discovery
- if: ${{ inputs.gate-artifact-name != '' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.gate-artifact-name }}
path: .mb3r/input-gate
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Build combined report
id: report
shell: bash
env:
DISCOVERY_REPORT_PATH: ${{ inputs.discovery-report-path }}
GATE_REPORT_PATH: ${{ inputs.gate-report-path }}
OUTPUT_DIR: ${{ inputs.output-dir }}
ARTIFACT_NAME: ${{ inputs.artifact-name }}
run: |
python - <<'PY'
import json
import os
from datetime import datetime, timezone
from pathlib import Path
ALLOWED_DECISIONS = {"fail", "pass", "report", "review", "warn"}
def normalize_decision(value, source):
if not isinstance(value, str) or value not in ALLOWED_DECISIONS:
allowed = ", ".join(sorted(ALLOWED_DECISIONS))
raise ValueError(f"{source} decision must be one of {allowed}: {value!r}")
return value
output_dir = Path(os.environ["OUTPUT_DIR"])
output_dir.mkdir(parents=True, exist_ok=True)
discovery_report = Path(".mb3r/input-discovery") / Path(os.environ["DISCOVERY_REPORT_PATH"]).name
gate_report = Path(".mb3r/input-gate") / Path(os.environ["GATE_REPORT_PATH"]).name
report_json = output_dir / "mb3r-report.json"
report_md = output_dir / "mb3r-report.md"
discovery = json.loads(discovery_report.read_text(encoding="utf-8"))
gate = json.loads(gate_report.read_text(encoding="utf-8"))
overall_decision = normalize_decision(gate.get("decision", "review"), "gate")
combined = {
"schemaVersion": "v1alpha1",
"kind": "mb3r.stack.report",
"adapter": "github-reusable-workflow",
"generatedAt": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
"overallDecision": overall_decision,
"discovery": {
"status": discovery.get("status"),
"path": discovery_report.as_posix(),
"artifactName": discovery.get("artifactName"),
},
"gate": {
"decision": overall_decision,
"status": gate.get("status"),
"path": gate_report.as_posix(),
"artifactName": gate.get("artifactName"),
},
}
report_json.write_text(json.dumps(combined, indent=2) + "\n", encoding="utf-8")
markdown = "\n".join(
[
"# MB3R Report",
"",
f"- Generated at: {combined['generatedAt']}",
f"- Discovery status: {combined['discovery']['status']}",
f"- Gate status: {combined['gate']['status']}",
f"- Overall decision: {combined['overallDecision']}",
]
)
report_md.write_text(markdown + "\n", encoding="utf-8")
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as handle:
handle.write(f"report-json={report_json.as_posix()}\n")
handle.write(f"report-markdown={report_md.as_posix()}\n")
handle.write(f"artifact-name={os.environ['ARTIFACT_NAME']}\n")
handle.write(f"overall-decision={overall_decision}\n")
PY
- if: ${{ inputs.upload-artifact }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.report.outputs.artifact-name }}
path: ${{ inputs.output-dir }}