-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
422 lines (413 loc) · 15.7 KB
/
Copy pathaction.yml
File metadata and controls
422 lines (413 loc) · 15.7 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
name: Open Verification Kernel
description: Solver-agnostic verification evidence for AI-agent pull requests
author: Open Verification Kernel Contributors
inputs:
mode:
description: advisory or strict
required: false
default: advisory
metadata:
description: Optional path to self-protection metadata JSON in the consumer repository
required: false
default: ""
changed-files:
description: Optional path to changed-files JSON, newline text, or a unified diff; PR diff is collected automatically when empty
required: false
default: ""
check-metadata:
description: Optional path to required-check metadata JSON
required: false
default: ""
backend-strategy:
description: Backend strategy, one of deterministic, opa, or both
required: false
default: deterministic
evidence-output:
description: Path for the generated evidence bundle
required: false
default: ovk-evidence.json
markdown-output:
description: Path for the generated Markdown summary
required: false
default: ovk-pr-comment.md
attestation-output:
description: Path for the generated attestation statement
required: false
default: ovk-attestation.json
manifest-output:
description: Path for the generated artifact manifest
required: false
default: ovk-artifact-manifest.json
quality-output:
description: Path for the generated evidence quality report
required: false
default: ovk-evidence-quality.json
post-comment:
description: Post the Markdown report as a pull-request comment when possible
required: false
default: "false"
verification-manifest:
description: Optional multi-lane verification manifest JSON; when set, runs ovk verify instead of ovk check
required: false
default: ""
use-check:
description: When true and verification-manifest is empty, run ovk check instead of ovk ci
required: false
default: "true"
emit-check:
description: Emit a GitHub check run from the OVK evidence bundle when token permissions allow
required: false
default: "true"
bundle-output-dir:
description: Output directory for multi-lane release bundles when verification-manifest is set
required: false
default: ovk-release-bundle
outputs:
recommendation:
description: Merge recommendation from the evidence bundle (allow, block, require_human_review, etc.)
value: ${{ steps.set-outputs.outputs.recommendation }}
exit_code:
description: Process exit code implied by the recommendation (0 allow, 1 block, 2 require_human_review)
value: ${{ steps.set-outputs.outputs.exit_code }}
check_emitted:
description: Whether a GitHub check run was successfully emitted
value: ${{ steps.set-outputs.outputs.check_emitted }}
runs:
using: composite
steps:
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ovk-pip-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
ovk-pip-${{ runner.os }}-
- name: Install OVK package
shell: bash
working-directory: ${{ github.action_path }}
run: |
set -euo pipefail
python -m pip install --upgrade pip
install_from_checkout() {
# package_data/ is generated and gitignored; sync before non-editable install
# so schemas/templates/adapters ship into site-packages.
python scripts/sync_package_data.py
pip install .
}
if [ -n "${OVK_PACKAGE_VERSION:-}" ]; then
pip install "open-verification-kernel==${OVK_PACKAGE_VERSION}" || install_from_checkout
else
install_from_checkout
fi
- name: Initialize verification directory if needed
shell: bash
working-directory: ${{ github.workspace }}
run: ovk init
- name: Collect branch metadata
shell: bash
working-directory: ${{ github.workspace }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
python "${{ github.action_path }}/scripts/collect_branch_metadata.py" \
--event "${{ github.event_path }}" \
--output ovk-branch-metadata.json || true
- name: Prepare change input
if: ${{ inputs.verification-manifest == '' }}
shell: bash
working-directory: ${{ github.workspace }}
env:
OVK_CHANGED_FILES: ${{ inputs.changed-files }}
OVK_EVENT_BASE_SHA: ${{ github.event.pull_request.base.sha }}
OVK_EVENT_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
OVK_GITHUB_SHA: ${{ github.sha }}
run: |
set -euo pipefail
if [ -n "$OVK_CHANGED_FILES" ]; then
if [ ! -f "$OVK_CHANGED_FILES" ]; then
echo "OVK changed-files input does not exist: $OVK_CHANGED_FILES" >&2
exit 1
fi
printf '%s\n' "$OVK_CHANGED_FILES" > .ovk-effective-input-path
exit 0
fi
HEAD_SHA="${OVK_EVENT_HEAD_SHA:-$OVK_GITHUB_SHA}"
BASE_SHA="${OVK_EVENT_BASE_SHA:-}"
if [ -n "$BASE_SHA" ] && ! git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null; then
git fetch --no-tags --depth=1 origin "$BASE_SHA" || true
fi
if [ -n "$HEAD_SHA" ] && ! git cat-file -e "${HEAD_SHA}^{commit}" 2>/dev/null; then
git fetch --no-tags --depth=1 origin "$HEAD_SHA" || true
fi
if [ -n "$BASE_SHA" ] && git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null \
&& [ -n "$HEAD_SHA" ] && git cat-file -e "${HEAD_SHA}^{commit}" 2>/dev/null; then
git diff --no-ext-diff --binary "$BASE_SHA" "$HEAD_SHA" > .ovk-pr.diff
elif [ -n "$BASE_SHA" ] && git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null; then
git diff --no-ext-diff --binary "$BASE_SHA" HEAD > .ovk-pr.diff
elif git rev-parse HEAD^ >/dev/null 2>&1; then
git diff --no-ext-diff --binary HEAD^ HEAD > .ovk-pr.diff
else
git show --format= --no-ext-diff --binary HEAD > .ovk-pr.diff
fi
printf '%s\n' ".ovk-pr.diff" > .ovk-effective-input-path
- name: Run OVK multi-lane verification
id: verify
if: ${{ inputs.verification-manifest != '' }}
shell: bash
working-directory: ${{ github.workspace }}
env:
OVK_MODE: ${{ inputs.mode }}
OVK_VERIFICATION_MANIFEST: ${{ inputs.verification-manifest }}
OVK_BUNDLE_OUTPUT_DIR: ${{ inputs.bundle-output-dir }}
OVK_REPO: ${{ github.repository }}
OVK_HEAD_SHA: ${{ github.sha }}
run: |
args=(
--manifest "$OVK_VERIFICATION_MANIFEST"
--output-dir "$OVK_BUNDLE_OUTPUT_DIR"
--repo "$OVK_REPO"
--head-sha "$OVK_HEAD_SHA"
)
if [ "$OVK_MODE" = "advisory" ]; then
args+=(--advisory)
fi
set +e
ovk verify "${args[@]}"
ACTION_RC=$?
ovk evidence-quality "$OVK_BUNDLE_OUTPUT_DIR/ovk-evidence.json" \
--output "$OVK_BUNDLE_OUTPUT_DIR/ovk-evidence-quality.json"
QUALITY_RC=$?
if [ "$ACTION_RC" -eq 0 ] && [ "$QUALITY_RC" -ne 0 ]; then
ACTION_RC=$QUALITY_RC
fi
set -e
echo "$ACTION_RC" > .ovk-action-exit-code
- name: Run OVK check path
id: check
if: ${{ inputs.verification-manifest == '' && inputs.use-check == 'true' }}
shell: bash
working-directory: ${{ github.workspace }}
env:
OVK_MODE: ${{ inputs.mode }}
OVK_CHECK_METADATA: ${{ inputs.check-metadata }}
OVK_GITHUB_EVENT: ${{ github.event_path }}
OVK_REPO: ${{ github.repository }}
OVK_HEAD_SHA: ${{ github.sha }}
run: |
OVK_DIFF_PATH="$(cat .ovk-effective-input-path)"
args=(
--diff "$OVK_DIFF_PATH"
--github-event "$OVK_GITHUB_EVENT"
--repo "$OVK_REPO"
--head-sha "$OVK_HEAD_SHA"
--output-dir .
)
if [ -n "$OVK_CHECK_METADATA" ]; then
args+=(--check-metadata "$OVK_CHECK_METADATA")
elif [ -f ovk-branch-metadata.json ]; then
args+=(--check-metadata ovk-branch-metadata.json)
fi
if [ "$OVK_MODE" = "advisory" ]; then
args+=(--advisory)
elif [ "$OVK_MODE" = "strict" ]; then
args+=(--strict)
fi
set +e
ovk check "${args[@]}"
ACTION_RC=$?
ovk evidence-quality ovk-evidence.json --output ovk-evidence-quality.json
QUALITY_RC=$?
if [ "$ACTION_RC" -eq 0 ] && [ "$QUALITY_RC" -ne 0 ]; then
ACTION_RC=$QUALITY_RC
fi
set -e
echo "$ACTION_RC" > .ovk-action-exit-code
- name: Emit OVK GitHub check (check path)
id: emit-check-run
if: ${{ inputs.emit-check == 'true' && inputs.verification-manifest == '' && inputs.use-check == 'true' }}
shell: bash
working-directory: ${{ github.workspace }}
env:
GITHUB_TOKEN: ${{ github.token }}
OVK_REPO: ${{ github.repository }}
OVK_HEAD_SHA: ${{ github.sha }}
run: |
set +e
python "${{ github.action_path }}/scripts/emit_github_check.py" \
--evidence ovk-evidence.json \
--markdown ovk-pr-comment.md \
--repo "$OVK_REPO" \
--head-sha "$OVK_HEAD_SHA"
EMIT_RC=$?
set -e
if [ "$EMIT_RC" -eq 0 ]; then
echo "true" > .ovk-check-emitted
else
echo "$EMIT_RC" > .ovk-emit-exit-code
fi
- name: Emit OVK GitHub check (verify path)
id: emit-check-verify
if: ${{ inputs.emit-check == 'true' && inputs.verification-manifest != '' }}
shell: bash
working-directory: ${{ github.workspace }}
env:
GITHUB_TOKEN: ${{ github.token }}
OVK_BUNDLE_OUTPUT_DIR: ${{ inputs.bundle-output-dir }}
OVK_REPO: ${{ github.repository }}
OVK_HEAD_SHA: ${{ github.sha }}
run: |
EVIDENCE="$OVK_BUNDLE_OUTPUT_DIR/ovk-evidence.json"
MARKDOWN="$OVK_BUNDLE_OUTPUT_DIR/ovk-pr-comment.md"
set +e
python "${{ github.action_path }}/scripts/emit_github_check.py" \
--evidence "$EVIDENCE" \
--markdown "$MARKDOWN" \
--repo "$OVK_REPO" \
--head-sha "$OVK_HEAD_SHA"
EMIT_RC=$?
set -e
if [ "$EMIT_RC" -eq 0 ]; then
echo "true" > .ovk-check-emitted
else
echo "$EMIT_RC" > .ovk-emit-exit-code
fi
- name: Run OVK self-protection CI path
id: ci
if: ${{ inputs.verification-manifest == '' && inputs.use-check != 'true' }}
shell: bash
working-directory: ${{ github.workspace }}
env:
OVK_MODE: ${{ inputs.mode }}
OVK_CHECK_METADATA: ${{ inputs.check-metadata }}
OVK_GITHUB_EVENT: ${{ github.event_path }}
OVK_METADATA: ${{ inputs.metadata }}
OVK_BACKEND_STRATEGY: ${{ inputs.backend-strategy }}
OVK_EVIDENCE_OUTPUT: ${{ inputs.evidence-output }}
OVK_MARKDOWN_OUTPUT: ${{ inputs.markdown-output }}
OVK_ATTESTATION_OUTPUT: ${{ inputs.attestation-output }}
OVK_MANIFEST_OUTPUT: ${{ inputs.manifest-output }}
OVK_QUALITY_OUTPUT: ${{ inputs.quality-output }}
OVK_REPO: ${{ github.repository }}
OVK_HEAD_SHA: ${{ github.sha }}
run: |
OVK_DIFF_PATH="$(cat .ovk-effective-input-path)"
args=(
--github-event "$OVK_GITHUB_EVENT"
--changed-files "$OVK_DIFF_PATH"
--backend-strategy "$OVK_BACKEND_STRATEGY"
--evidence-output "$OVK_EVIDENCE_OUTPUT"
--markdown-output "$OVK_MARKDOWN_OUTPUT"
--attestation-output "$OVK_ATTESTATION_OUTPUT"
--manifest-output "$OVK_MANIFEST_OUTPUT"
--quality-output "$OVK_QUALITY_OUTPUT"
--repo "$OVK_REPO"
--head-sha "$OVK_HEAD_SHA"
)
if [ -n "$OVK_METADATA" ]; then
args+=(--metadata "$OVK_METADATA")
fi
if [ -n "$OVK_CHECK_METADATA" ]; then
args+=(--check-metadata "$OVK_CHECK_METADATA")
elif [ -f ovk-branch-metadata.json ]; then
args+=(--check-metadata ovk-branch-metadata.json)
fi
if [ "$OVK_MODE" = "advisory" ]; then
args+=(--advisory)
fi
set +e
ovk ci "${args[@]}"
ACTION_RC=$?
set -e
echo "$ACTION_RC" > .ovk-action-exit-code
- name: Post OVK pull-request comment
if: ${{ inputs.post-comment == 'true' }}
shell: bash
working-directory: ${{ github.workspace }}
env:
GITHUB_TOKEN: ${{ github.token }}
OVK_MARKDOWN_OUTPUT: ${{ inputs.markdown-output }}
OVK_GITHUB_EVENT: ${{ github.event_path }}
OVK_VERIFICATION_MANIFEST: ${{ inputs.verification-manifest }}
OVK_BUNDLE_OUTPUT_DIR: ${{ inputs.bundle-output-dir }}
run: |
MARKDOWN="$OVK_MARKDOWN_OUTPUT"
if [ -n "$OVK_VERIFICATION_MANIFEST" ]; then
MARKDOWN="$OVK_BUNDLE_OUTPUT_DIR/ovk-pr-comment.md"
fi
python "${{ github.action_path }}/scripts/post_pr_comment.py" \
--markdown "$MARKDOWN" \
--event "$OVK_GITHUB_EVENT"
- name: Set action outputs
id: set-outputs
if: always()
shell: bash
working-directory: ${{ github.workspace }}
env:
OVK_VERIFICATION_MANIFEST: ${{ inputs.verification-manifest }}
OVK_BUNDLE_OUTPUT_DIR: ${{ inputs.bundle-output-dir }}
OVK_EVIDENCE_OUTPUT: ${{ inputs.evidence-output }}
run: |
python - <<'PY'
import json
import os
from pathlib import Path
if os.environ.get("OVK_VERIFICATION_MANIFEST"):
evidence_path = Path(os.environ["OVK_BUNDLE_OUTPUT_DIR"]) / "ovk-evidence.json"
else:
configured = Path(os.environ.get("OVK_EVIDENCE_OUTPUT", "ovk-evidence.json"))
evidence_path = configured if configured.exists() else Path("ovk-evidence.json")
recommendation = ""
exit_code = "2"
if evidence_path.exists():
bundle = json.loads(evidence_path.read_text(encoding="utf-8"))
recommendation = str(bundle.get("decision", {}).get("merge_recommendation", ""))
exit_codes = {
"allow": 0,
"allow_with_warning": 0,
"block": 1,
"require_human_review": 2,
"require_stronger_check": 2,
}
exit_code = str(exit_codes.get(recommendation, 2))
check_emitted = "true" if Path(".ovk-check-emitted").exists() else "false"
github_output = os.environ["GITHUB_OUTPUT"]
with open(github_output, "a", encoding="utf-8") as handle:
handle.write(f"recommendation={recommendation}\n")
handle.write(f"exit_code={exit_code}\n")
handle.write(f"check_emitted={check_emitted}\n")
PY
- name: Enforce strict exit
if: always()
shell: bash
working-directory: ${{ github.workspace }}
env:
OVK_MODE: ${{ inputs.mode }}
OVK_EMIT_CHECK: ${{ inputs.emit-check }}
run: |
if [ "$OVK_MODE" != "strict" ]; then
exit 0
fi
if [ -f .ovk-emit-exit-code ] && [ "$OVK_EMIT_CHECK" = "true" ]; then
exit "$(cat .ovk-emit-exit-code)"
fi
if [ -f .ovk-action-exit-code ]; then
exit "$(cat .ovk-action-exit-code)"
fi
exit 2
- name: Upload OVK artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: ovk-evidence-artifacts-${{ github.job }}
path: |
ovk-evidence.json
ovk-pr-comment.md
ovk-attestation.json
ovk-artifact-manifest.json
ovk-evidence-quality.json
ovk-provenance.json
ovk-attestation-envelope.json
${{ inputs.bundle-output-dir }}/**
ovk-branch-metadata.json
.ovk-pr.diff
.ovk-check-emitted