Skip to content

Commit 69a2397

Browse files
committed
Merge branch 'ci/fixes'
2 parents 2239882 + cd9afbb commit 69a2397

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

.github/scripts/generate_missing_junits.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99
import yaml
1010

1111

12-
def read_workflow_info(path: Path) -> dict:
13-
try:
14-
return json.loads(path.read_text(encoding="utf-8"))
15-
except Exception as e:
16-
print(f"WARN: Failed to read workflow info at {path}: {e}", file=sys.stderr)
17-
return {}
18-
19-
2012
def parse_array(value) -> list[str]:
2113
if isinstance(value, list):
2214
return [str(x) for x in value]
@@ -197,28 +189,30 @@ def write_missing_xml(out_root: Path, platform: str, target: str, test_type: str
197189

198190

199191
def main():
200-
# Args: <build_artifacts_dir> <output_junit_dir>
201-
if len(sys.argv) != 3:
202-
print(f"Usage: {sys.argv[0]} <build_artifacts_dir> <output_junit_dir>", file=sys.stderr)
192+
# Args: <build_artifacts_dir> <test_results_dir> <output_junit_dir>
193+
if len(sys.argv) != 4:
194+
print(f"Usage: {sys.argv[0]} <build_artifacts_dir> <test_results_dir> <output_junit_dir>", file=sys.stderr)
203195
return 2
204196

205197
build_root = Path(sys.argv[1]).resolve()
206-
artifacts_root = Path(sys.argv[2]).resolve()
207-
wf_info = artifacts_root / "parent-artifacts" / "workflow_info.json"
208-
209-
info = read_workflow_info(wf_info)
210-
hw_enabled = str(info.get("hw_tests_enabled", "false")).lower() == "true"
211-
wokwi_enabled = str(info.get("wokwi_tests_enabled", "false")).lower() == "true"
212-
qemu_enabled = str(info.get("qemu_tests_enabled", "false")).lower() == "true"
213-
hw_targets = parse_array(info.get("hw_targets"))
214-
wokwi_targets = parse_array(info.get("wokwi_targets"))
215-
qemu_targets = parse_array(info.get("qemu_targets"))
216-
hw_types = parse_array(info.get("hw_types"))
217-
wokwi_types = parse_array(info.get("wokwi_types"))
218-
qemu_types = parse_array(info.get("qemu_types"))
198+
results_root = Path(sys.argv[2]).resolve()
199+
out_root = Path(sys.argv[3]).resolve()
200+
201+
# Read matrices from environment variables injected by workflow
202+
hw_enabled = (os.environ.get("HW_TESTS_ENABLED", "false").lower() == "true")
203+
wokwi_enabled = (os.environ.get("WOKWI_TESTS_ENABLED", "false").lower() == "true")
204+
qemu_enabled = (os.environ.get("QEMU_TESTS_ENABLED", "false").lower() == "true")
205+
206+
hw_targets = parse_array(os.environ.get("HW_TARGETS", "[]"))
207+
wokwi_targets = parse_array(os.environ.get("WOKWI_TARGETS", "[]"))
208+
qemu_targets = parse_array(os.environ.get("QEMU_TARGETS", "[]"))
209+
210+
hw_types = parse_array(os.environ.get("HW_TYPES", "[]"))
211+
wokwi_types = parse_array(os.environ.get("WOKWI_TYPES", "[]"))
212+
qemu_types = parse_array(os.environ.get("QEMU_TYPES", "[]"))
219213

220214
expected = expected_from_artifacts(build_root) # (platform, target, type, sketch) -> expected_count
221-
executed = scan_executed_xml(artifacts_root) # (platform, target, type, sketch) -> count
215+
executed = scan_executed_xml(results_root) # (platform, target, type, sketch) -> count
222216

223217
# Filter expected by enabled platforms and target/type matrices
224218
enabled_plats = set()
@@ -240,7 +234,7 @@ def main():
240234
continue
241235
got = executed.get((plat, target, test_type, sketch), 0)
242236
if got < exp_count:
243-
write_missing_xml(artifacts_root, plat, target, test_type, sketch, exp_count - got)
237+
write_missing_xml(out_root, plat, target, test_type, sketch, exp_count - got)
244238
missing_total += (exp_count - got)
245239

246240
print(f"Generated {missing_total} placeholder JUnit files for missing runs.", file=sys.stderr)

.github/workflows/tests_results.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,24 @@ jobs:
124124
run_id: ${{ github.event.workflow_run.id }}
125125
path: ./artifacts
126126

127-
- name: Generate placeholders for missing runs
127+
- name: Generate JUnit files for missing runs
128128
env:
129129
GH_TOKEN: ${{ github.token }}
130+
HW_TESTS_ENABLED: ${{ needs.get-artifacts.outputs.hw_tests_enabled }}
131+
HW_TARGETS: ${{ needs.get-artifacts.outputs.hw_targets }}
132+
HW_TYPES: ${{ needs.get-artifacts.outputs.hw_types }}
133+
WOKWI_TESTS_ENABLED: ${{ needs.get-artifacts.outputs.wokwi_tests_enabled }}
134+
WOKWI_TARGETS: ${{ needs.get-artifacts.outputs.wokwi_targets }}
135+
WOKWI_TYPES: ${{ needs.get-artifacts.outputs.wokwi_types }}
136+
QEMU_TESTS_ENABLED: ${{ needs.get-artifacts.outputs.qemu_tests_enabled }}
137+
QEMU_TARGETS: ${{ needs.get-artifacts.outputs.qemu_targets }}
138+
QEMU_TYPES: ${{ needs.get-artifacts.outputs.qemu_types }}
130139
run: |
131140
pip3 install pyyaml
132141
mkdir -p build_artifacts test_errors
133142
gh run download ${{ needs.get-artifacts.outputs.original_run_id }} --name "test-bin-*" --dir ./build_artifacts || true
134143
wget https://raw.githubusercontent.com/${{ github.repository }}/master/.github/scripts/generate_missing_junits.py -O ./generate_missing_junits.py
135-
python3 ./generate_missing_junits.py ./build_artifacts ./test_errors
144+
python3 ./generate_missing_junits.py ./build_artifacts ./artifacts ./test_errors
136145
137146
- name: Publish Unit Test Results
138147
uses: EnricoMi/publish-unit-test-result-action@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0

0 commit comments

Comments
 (0)