2525 allow_failures :
2626 description : Allow rendering from valid incomplete QA evidence
2727 required : false
28- default : false
28+ default : true
2929 type : boolean
3030 workflow_call :
3131 inputs :
9696 workflow_repository : ${{ steps.workflow.outputs.workflow_repository }}
9797 workflow_sha : ${{ steps.workflow.outputs.workflow_sha }}
9898 steps :
99+ # Protect both direct dispatches and reusable calls before the workflow reaches the
100+ # secret-bearing QA evidence workflow.
101+ - name : Require authorized workflow actor
102+ uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
103+ env :
104+ CALLER_WORKFLOW_REF : ${{ github.workflow_ref }}
105+ JOB_CONTEXT : ${{ toJSON(job) }}
106+ with :
107+ script : |
108+ const job = JSON.parse(process.env.JOB_CONTEXT ?? "{}");
109+ const callerWorkflowRef = process.env.CALLER_WORKFLOW_REF ?? "";
110+ const calledWorkflowRef =
111+ "openclaw/openclaw/.github/workflows/maturity-scorecard.yml@refs/heads/main";
112+ const trustedMainCaller =
113+ callerWorkflowRef !== calledWorkflowRef &&
114+ /^openclaw\/openclaw\/.github\/workflows\/[A-Za-z0-9_.-]+\.yml@refs\/heads\/main$/u.test(
115+ callerWorkflowRef,
116+ ) &&
117+ job.workflow_repository === "openclaw/openclaw" &&
118+ job.workflow_ref === calledWorkflowRef;
119+ if (context.actor === "github-actions[bot]") {
120+ if (!trustedMainCaller) {
121+ throw new Error("Bot invocation is not bound to a trusted main-branch caller.");
122+ }
123+ return;
124+ }
125+ const allowed = new Set(["admin", "maintain", "write"]);
126+ const { owner, repo } = context.repo;
127+ const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
128+ owner,
129+ repo,
130+ username: context.actor,
131+ });
132+ if (!allowed.has(data.permission)) {
133+ throw new Error(
134+ `Workflow requires write/maintain/admin access; actor ${context.actor} has ${data.permission}.`,
135+ );
136+ }
137+
99138 # actionlint 1.7.11 lacks GitHub's current job.workflow_* fields. Serialize the non-secret
100139 # job context, validate those identity facts, and pass only checked outputs forward.
101140 - name : Resolve job workflow identity
@@ -405,21 +444,24 @@ jobs:
405444 QA_EVIDENCE_RUN_ID : ${{ inputs.qa_evidence_run_id }}
406445 run : |
407446 set -euo pipefail
408- mapfile -t evidence_paths < <(find .artifacts/maturity-evidence -type f -name qa-evidence.json | sort)
409- if [[ "${#evidence_paths[@]}" -eq 0 ]]; then
410- echo "Expected a qa-evidence.json file in the downloaded QA evidence artifact." >&2
447+ mapfile -t manifest_paths < <(
448+ find .artifacts/maturity-evidence -type f -name qa-profile-evidence-manifest.json | sort
449+ )
450+ if [[ "${#manifest_paths[@]}" -ne 1 ]]; then
451+ echo "Expected exactly one aggregate QA evidence manifest, found ${#manifest_paths[@]}:" >&2
452+ printf '%s\n' "${manifest_paths[@]}" >&2
411453 exit 1
412454 fi
413- if [[ "${#evidence_paths[@ ]}" -gt 1 ]]; then
414- echo "Expected exactly one qa-evidence.json file, found ${#evidence_paths[@]}:" >&2
415- printf '%s\n' "${evidence_paths[@]} " >&2
455+ evidence_path="$(dirname "${manifest_paths[0 ]}")/qa-evidence.json"
456+ if [[ ! -f "$evidence_path" || -L "$evidence_path" ]]; then
457+ echo "Aggregate QA evidence is missing next to ${manifest_paths[0]}. " >&2
416458 exit 1
417459 fi
418- echo "qa_evidence_path=${evidence_paths[0] }" >> "$GITHUB_OUTPUT"
460+ echo "qa_evidence_path=${evidence_path }" >> "$GITHUB_OUTPUT"
419461 {
420462 echo "### QA evidence"
421463 echo
422- echo "- Evidence path: \`${evidence_paths[0] }\`"
464+ echo "- Evidence path: \`${evidence_path }\`"
423465 echo "- Evidence source run: \`${QA_EVIDENCE_RUN_ID:-$GITHUB_RUN_ID}\`"
424466 } >> "$GITHUB_STEP_SUMMARY"
425467
@@ -548,6 +590,16 @@ jobs:
548590 exit 1
549591 fi
550592
593+ - name : Prepare aggregate QA evidence for rendering
594+ env :
595+ QA_EVIDENCE_PATH : ${{ steps.evidence.outputs.qa_evidence_path }}
596+ run : |
597+ set -euo pipefail
598+ render_evidence_dir=".artifacts/maturity-render-evidence"
599+ rm -rf "$render_evidence_dir"
600+ mkdir -p "$render_evidence_dir"
601+ install -m 0644 "$QA_EVIDENCE_PATH" "$render_evidence_dir/qa-evidence.json"
602+
551603 - name : Validate maturity score sources
552604 run : |
553605 node --import tsx --input-type=module <<'NODE'
@@ -575,7 +627,7 @@ jobs:
575627 --output-dir .artifacts/maturity-docs \
576628 --static-assets-dir .artifacts/maturity-docs/assets/maturity \
577629 --scores qa/maturity-scores.yaml \
578- --evidence-dir .artifacts/maturity-evidence \
630+ --evidence-dir .artifacts/maturity-render- evidence \
579631 --strict-inputs \
580632 "${allow_failures_args[@]}"
581633 {
@@ -600,7 +652,7 @@ jobs:
600652 pnpm maturity:render -- \
601653 --output-dir docs \
602654 --scores qa/maturity-scores.yaml \
603- --evidence-dir .artifacts/maturity-evidence \
655+ --evidence-dir .artifacts/maturity-render- evidence \
604656 --strict-inputs \
605657 "${allow_failures_args[@]}"
606658
0 commit comments