Skip to content

Commit 100d997

Browse files
committed
fix(ci): isolate performance candidate trust
1 parent 587c752 commit 100d997

2 files changed

Lines changed: 279 additions & 22 deletions

File tree

‎.github/workflows/openclaw-performance.yml‎

Lines changed: 76 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ jobs:
9393
kova_ref: ${{ steps.resolve.outputs.kova_ref }}
9494
kova_config_contract: ${{ steps.resolve.outputs.kova_config_contract }}
9595
kova_ref_trusted_for_live: ${{ steps.resolve.outputs.kova_ref_trusted_for_live }}
96+
secret_eligible: ${{ steps.candidate_trust.outputs.secret_eligible }}
97+
cache_write_allowed: ${{ steps.candidate_trust.outputs.cache_write_allowed }}
9698
steps:
9799
- name: Checkout target metadata
98100
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
@@ -177,6 +179,34 @@ jobs:
177179
echo "kova_ref_trusted_for_live=false" >> "$GITHUB_OUTPUT"
178180
fi
179181
182+
- name: Classify performance candidate trust
183+
id: candidate_trust
184+
env:
185+
CANDIDATE_SHA: ${{ steps.resolve.outputs.tested_sha }}
186+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
187+
WORKFLOW_SHA: ${{ github.workflow_sha }}
188+
shell: bash
189+
run: |
190+
set -euo pipefail
191+
192+
secret_eligible=false
193+
cache_write_allowed=false
194+
if [[
195+
"$GITHUB_EVENT_NAME" == "schedule" ||
196+
"$GITHUB_EVENT_NAME" == "workflow_dispatch"
197+
]] && [[
198+
"$GITHUB_REF" == "refs/heads/${DEFAULT_BRANCH}" &&
199+
"$CANDIDATE_SHA" == "$WORKFLOW_SHA"
200+
]]; then
201+
secret_eligible=true
202+
cache_write_allowed=true
203+
fi
204+
205+
{
206+
echo "secret_eligible=$secret_eligible"
207+
echo "cache_write_allowed=$cache_write_allowed"
208+
} >> "$GITHUB_OUTPUT"
209+
180210
kova:
181211
name: ${{ matrix.title }}
182212
needs: resolve_target
@@ -234,6 +264,7 @@ jobs:
234264
MATRIX_DEEP_PROFILE: ${{ matrix.deep_profile }}
235265
MATRIX_LIVE: ${{ matrix.live }}
236266
KOVA_REF_TRUSTED_FOR_LIVE: ${{ needs.resolve_target.outputs.kova_ref_trusted_for_live }}
267+
SECRET_ELIGIBLE: ${{ needs.resolve_target.outputs.secret_eligible }}
237268
steps:
238269
- name: Decide lane
239270
id: lane
@@ -250,6 +281,10 @@ jobs:
250281
run_lane=false
251282
reason="live_openai_candidate input is false"
252283
fi
284+
if [[ "$LANE_ID" == "live-openai-candidate" && "$run_lane" == "true" && "$SECRET_ELIGIBLE" != "true" ]]; then
285+
run_lane=false
286+
reason="candidate is not eligible for live credentials"
287+
fi
253288
if [[ "$LANE_ID" == "live-openai-candidate" && "$run_lane" == "true" && "$KOVA_REF_TRUSTED_FOR_LIVE" != "true" ]]; then
254289
echo "::error::The live OpenAI lane only executes a reviewed immutable Kova default. Omit kova_ref or update the pinned workflow defaults after review."
255290
exit 1
@@ -271,7 +306,7 @@ jobs:
271306
if: steps.lane.outputs.run == 'true'
272307
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
273308
with:
274-
ref: ${{ github.sha }}
309+
ref: ${{ github.workflow_sha }}
275310
path: .artifacts/performance-workflow
276311
fetch-depth: 1
277312
persist-credentials: false
@@ -295,11 +330,35 @@ jobs:
295330
echo "Workflow SHA: ${GITHUB_SHA}"
296331
} >> "$GITHUB_STEP_SUMMARY"
297332
333+
- name: Stage trusted setup action graph
334+
if: steps.lane.outputs.run == 'true'
335+
shell: bash
336+
run: &stage_trusted_performance_setup |
337+
set -euo pipefail
338+
github_dir="$GITHUB_WORKSPACE/.github"
339+
actions_dir="$github_dir/actions"
340+
trusted_action="$PERFORMANCE_HELPER_DIR/.github/actions/setup-pnpm-store-cache"
341+
342+
test -f "$trusted_action/action.yml"
343+
test -f "$trusted_action/ensure-node.sh"
344+
if [[ -L "$github_dir" || ( -e "$github_dir" && ! -d "$github_dir" ) ]]; then
345+
rm -rf -- "$github_dir"
346+
fi
347+
mkdir -p "$github_dir"
348+
if [[ -L "$actions_dir" || ( -e "$actions_dir" && ! -d "$actions_dir" ) ]]; then
349+
rm -rf -- "$actions_dir"
350+
fi
351+
mkdir -p "$actions_dir"
352+
rm -rf -- "$actions_dir/setup-pnpm-store-cache"
353+
cp -R -- "$trusted_action" "$actions_dir/setup-pnpm-store-cache"
354+
cmp "$trusted_action/action.yml" "$actions_dir/setup-pnpm-store-cache/action.yml"
355+
cmp "$trusted_action/ensure-node.sh" "$actions_dir/setup-pnpm-store-cache/ensure-node.sh"
356+
298357
- name: Set up Node environment
299358
if: steps.lane.outputs.run == 'true'
300-
uses: ./.github/actions/setup-node-env
359+
uses: ./.artifacts/performance-workflow/.github/actions/setup-node-env
301360
with:
302-
cache-mode: restore
361+
cache-mode: ${{ needs.resolve_target.outputs.cache_write_allowed == 'true' && 'restore' || 'off' }}
303362
install-bun: "false"
304363

305364
- name: Prepare systemd user session
@@ -448,7 +507,7 @@ jobs:
448507
echo "KOVA_LANE_REPEAT=$repeat" >> "$GITHUB_ENV"
449508
450509
- name: Configure live OpenAI auth
451-
if: ${{ steps.lane.outputs.run == 'true' && matrix.live == 'true' }}
510+
if: ${{ steps.lane.outputs.run == 'true' && matrix.live == 'true' && needs.resolve_target.outputs.secret_eligible == 'true' }}
452511
env:
453512
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
454513
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
@@ -466,8 +525,8 @@ jobs:
466525
id: kova
467526
if: steps.lane.outputs.run == 'true'
468527
env:
469-
OPENAI_API_KEY: ${{ matrix.live == 'true' && secrets.OPENAI_API_KEY || '' }}
470-
OPENAI_BASE_URL: ${{ matrix.live == 'true' && secrets.OPENAI_BASE_URL || '' }}
528+
OPENAI_API_KEY: ${{ matrix.live == 'true' && needs.resolve_target.outputs.secret_eligible == 'true' && secrets.OPENAI_API_KEY || '' }}
529+
OPENAI_BASE_URL: ${{ matrix.live == 'true' && needs.resolve_target.outputs.secret_eligible == 'true' && secrets.OPENAI_BASE_URL || '' }}
471530
shell: bash
472531
run: |
473532
set -euo pipefail
@@ -646,7 +705,7 @@ jobs:
646705
- name: Checkout source performance helpers
647706
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
648707
with:
649-
ref: ${{ github.sha }}
708+
ref: ${{ github.workflow_sha }}
650709
path: .artifacts/performance-workflow
651710
fetch-depth: 1
652711
persist-credentials: false
@@ -667,10 +726,14 @@ jobs:
667726
echo "Workflow SHA: ${GITHUB_SHA}"
668727
} >> "$GITHUB_STEP_SUMMARY"
669728
729+
- name: Stage trusted source setup action graph
730+
shell: bash
731+
run: *stage_trusted_performance_setup
732+
670733
- name: Set up source performance environment
671-
uses: ./.github/actions/setup-node-env
734+
uses: ./.artifacts/performance-workflow/.github/actions/setup-node-env
672735
with:
673-
cache-mode: restore
736+
cache-mode: ${{ needs.resolve_target.outputs.cache_write_allowed == 'true' && 'restore' || 'off' }}
674737
install-bun: "false"
675738

676739
- name: Fetch previous source performance baseline
@@ -925,7 +988,7 @@ jobs:
925988
publish:
926989
name: Publish ${{ matrix.title }} report
927990
needs: [resolve_target, kova, source_performance]
928-
if: ${{ always() && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.publish_reports == true)) && needs.resolve_target.result == 'success' && needs.kova.result != 'cancelled' && needs.source_performance.result != 'cancelled' }}
991+
if: ${{ always() && needs.resolve_target.outputs.secret_eligible == 'true' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.publish_reports == true)) && needs.resolve_target.result == 'success' && needs.kova.result != 'cancelled' && needs.source_performance.result != 'cancelled' }}
929992
runs-on: ubuntu-24.04
930993
timeout-minutes: 30
931994
permissions:
@@ -966,7 +1029,7 @@ jobs:
9661029
if: steps.lane.outputs.run == 'true'
9671030
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
9681031
with:
969-
ref: ${{ github.sha }}
1032+
ref: ${{ github.workflow_sha }}
9701033
path: .artifacts/performance-publisher
9711034
sparse-checkout: |
9721035
scripts/lib/kova-report-publish-files.mjs
@@ -1246,7 +1309,7 @@ jobs:
12461309
12471310
- name: Create clawgrit reports app token
12481311
id: clawgrit_app_token
1249-
if: ${{ steps.prepare.outputs.ready == 'true' && steps.prepare.outputs.already_published != 'true' }}
1312+
if: ${{ needs.resolve_target.outputs.secret_eligible == 'true' && steps.prepare.outputs.ready == 'true' && steps.prepare.outputs.already_published != 'true' }}
12501313
continue-on-error: ${{ env.REPORT_PUBLISH_REQUIRED != 'true' }}
12511314
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
12521315
with:
@@ -1257,7 +1320,7 @@ jobs:
12571320
permission-contents: write
12581321

12591322
- name: Publish to clawgrit reports
1260-
if: ${{ steps.prepare.outputs.ready == 'true' && steps.prepare.outputs.already_published != 'true' }}
1323+
if: ${{ needs.resolve_target.outputs.secret_eligible == 'true' && steps.prepare.outputs.ready == 'true' && steps.prepare.outputs.already_published != 'true' }}
12611324
continue-on-error: ${{ env.REPORT_PUBLISH_REQUIRED != 'true' }}
12621325
env:
12631326
CLAWGRIT_REPORTS_APP_TOKEN: ${{ steps.clawgrit_app_token.outputs.token }}

0 commit comments

Comments
 (0)