Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
435e4b2
ci: host PR evidence outside Git
yiliang114 Aug 25, 2026
3007a15
ci: pin node and ossutil paths in privileged OSS uploads
yiliang114 Aug 25, 2026
08bdacf
ci: make OSS setup best-effort and pair bucket/base-URL defaults
yiliang114 Aug 25, 2026
2b47046
ci: enrich evidence-upload warning with local preconditions
yiliang114 Aug 25, 2026
56f47a8
test: enforce the uploader flag contract and pin the production arm
yiliang114 Aug 25, 2026
e7d683a
test: pin the ossutil credential lifecycle in both publishers
yiliang114 Aug 25, 2026
eee7fc2
docs: align assets-repo guidance with the self-targeting guard
yiliang114 Aug 25, 2026
75fab7f
test: execute the visuals hosting block against a stub uploader
yiliang114 Aug 25, 2026
7214e4e
fix(ci): gate ossutil consumers on verified install
yiliang114 Aug 25, 2026
93f8ff4
fix(ci): grant publisher checkout access
yiliang114 Aug 25, 2026
654f3a3
test(ci): pin OSS publisher failure paths
yiliang114 Aug 25, 2026
447fbd9
test(ci): exercise production OSS dispatch
yiliang114 Aug 26, 2026
d140b0f
Merge branch 'main' into codex/migrate-pr-assets-to-oss
wenshao Aug 26, 2026
cf6994e
Merge remote-tracking branch 'origin/codex/migrate-pr-assets-to-oss' …
yiliang114 Aug 26, 2026
3e62f22
fix(ci): isolate OSS publisher on hosted runner
yiliang114 Aug 26, 2026
f630c7f
fix(ci): sync size baseline and stale runner comments
yiliang114 Aug 26, 2026
e9e4bed
fix(ci): give each visuals publish a fresh OSS prefix
yiliang114 Aug 27, 2026
1f519d1
fix(ci): retry the ossutil download in both PR publishers
yiliang114 Aug 27, 2026
ee198c1
fix(ci): include run attempt in the web-shell OSS asset prefix
yiliang114 Aug 27, 2026
1bf6199
fix(ci): close out PR evidence hosting review findings
yiliang114 Aug 27, 2026
20ea50e
fix(ci): gate visuals-publish Configure step on ossutil install outcome
yiliang114 Aug 27, 2026
c492f11
Merge remote-tracking branch 'origin/main' into codex/migrate-pr-asse…
yiliang114 Aug 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
227 changes: 227 additions & 0 deletions .github/scripts/web-shell-visuals-publish.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
*/

import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import {
existsSync,
mkdirSync,
mkdtempSync,
readdirSync,
readFileSync,
writeFileSync,
} from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import test from 'node:test';

import {
Expand All @@ -22,6 +33,222 @@ import {
const PNG = '89504e470d0a1a0a';
const GIF89 = '474946383961';
const GIF87 = '474946383761';
const workflow = readFileSync(
'.github/workflows/web-shell-visuals-publish.yml',
'utf8',
);

test('workflow hosts visuals on OSS without writing Git refs', () => {
assert.match(workflow, /scripts\/upload-aliyun-oss-assets\.js/);
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
assert.match(
workflow,
/pr-assets\/web-shell-visuals\/\$\{PR\}\/\$\{RUN_HEAD_SHA\}/,
);
assert.match(workflow, /ALIYUN_OSS_PUBLIC_BASE_URL/);
assert.match(workflow, /PATH="\$trusted_bin" "\$node_bin"/);
assert.doesNotMatch(workflow, /PATH="\$RUNNER_TEMP:\$PATH"/);
assert.doesNotMatch(workflow, /git push/);
assert.doesNotMatch(workflow, /checkout -q --orphan/);
});

test('workflow pins the ossutil credential lifecycle (sha256 install, config, always() cleanup)', () => {
// The sha256-verified install and the credential config it feeds are
// best-effort here (a setup failure must not block the no-image path)...
const install =
workflow.split("'Install ossutil'")[1]?.split('- name:')[0] ?? '';
assert.match(install, /continue-on-error: true/);
assert.match(install, /sha256sum -c/);
const configure =
workflow
.split("'Configure Aliyun OSS credentials'")[1]
?.split('- name:')[0] ?? '';
assert.match(configure, /continue-on-error: true/);
assert.match(configure, /-c "\$RUNNER_TEMP\/\.ossutilconfig"/);
// ...but the cleanup must run even on failure, or the OSS key pair
// lingers in $RUNNER_TEMP after the job.
const cleanup = workflow.split("'Cleanup Aliyun OSS credentials'")[1] ?? '';
assert.match(cleanup, /if: '\$\{\{ always\(\) \}\}'/);
assert.match(cleanup, /rm -f "\$RUNNER_TEMP\/\.ossutilconfig"/);
});

// --- Behavioural coverage for the OSS hosting block -----------------------
// The shape regexes above pin the hosting contract as text; this harness
// EXECUTES the extracted hosting block against a stub uploader that mirrors
// scripts/upload-aliyun-oss-assets.js's flag contract (readOptionValue
// rejects a valueless --bucket/--config/--prefix; at least one asset is
// required) and records where the objects land — the same stub-uploader
// pattern as the verify path in scripts/tests/qwen-triage-workflow.test.js.
// A --prefix that drifts away from RAW_BASE (every preview URL 404s) or a
// dropped --config (the real uploader dies before any comment posts) fails
// here, where the shape regexes stay green.

function hostingBlockSource() {
const raw = workflow
.split('# --- Host on Aliyun OSS')[1]
?.split('\n')
.slice(1) // drop the marker line's trailing dashes — not a comment.
.join('\n')
.split('# --- Changed paths')[0]
.replace(/^ {10}/gm, ''); // the step run block's indentation.
assert.ok(raw, 'hosting block markers not found in the publish workflow');
return raw;
}

function runHostingBlock(
hasImages,
{ publicBaseUrl = 'https://assets.example.test', uploadFails = false } = {},
) {
const dir = mkdtempSync(join(tmpdir(), 'visuals-hosting-'));
const runnerTemp = join(dir, 'runner-temp');
const stage = join(dir, 'stage');
const work = join(dir, 'work');
const stubRoot = join(dir, 'oss');
const recordPath = join(dir, 'upload-record.json');
mkdirSync(runnerTemp, { recursive: true });
mkdirSync(stage, { recursive: true });
mkdirSync(join(work, 'scripts'), { recursive: true });
// The block installs its job-private ossutil copy from here; the stub
// uploader never executes it, but the install must succeed.
writeFileSync(join(runnerTemp, 'ossutil'), 'fake ossutil\n');
writeFileSync(join(stage, 'home-light.png'), 'png-bytes');
writeFileSync(join(stage, 'model-switch.gif'), 'gif-bytes');
// Stub uploader: enforces the real flag contract, then copies the objects
// under $OSS_STUB_ROOT/<bucket>/<prefix> and records the flags it saw.
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
writeFileSync(
join(work, 'scripts', 'upload-aliyun-oss-assets.js'),
[
"'use strict';",
"const { copyFileSync, mkdirSync, writeFileSync } = require('node:fs');",
"const { basename, join } = require('node:path');",
"if (process.env.OSS_STUB_FAIL === '1') process.exit(1);",
"const opts = { bucket: '', config: '', prefix: '' };",
'const assets = [];',
'const argv = process.argv.slice(2);',
'for (let i = 0; i < argv.length; i += 1) {',
' const arg = argv[i];',
" if (arg === '--bucket' || arg === '--config' || arg === '--prefix') {",
' opts[arg.slice(2)] = argv[i + 1] ?? "";',
' i += 1;',
' } else {',
' assets.push(arg);',
' }',
'}',
'for (const [name, value] of Object.entries(opts)) {',
' if (!value || value.startsWith("-")) {',
' console.error(`upload-assets stub: --${name} requires a value`);',
' process.exit(1);',
' }',
'}',
'if (assets.length === 0) {',
' console.error("upload-assets stub: at least one ASSET path is required");',
' process.exit(1);',
'}',
'const target = join(process.env.OSS_STUB_ROOT, opts.bucket, opts.prefix);',
'mkdirSync(target, { recursive: true });',
'for (const file of assets) {',
' copyFileSync(file, join(target, basename(file)));',
'}',
'writeFileSync(process.env.OSS_STUB_RECORD, JSON.stringify(opts));',
].join('\n'),
);
const pr = '4242';
const headSha = 'cafe4242cafe4242cafe4242cafe4242cafe4242';
const script = [
'set -euo pipefail',
`HAS_IMAGES=${hasImages ? 1 : 0}`,
`PR=${pr}`,
`RUN_HEAD_SHA=${headSha}`,
`STAGE=${JSON.stringify(stage)}`,
'ALIYUN_OSS_BUCKET=assets-bucket',
`ALIYUN_OSS_PUBLIC_BASE_URL=${JSON.stringify(publicBaseUrl)}`,
`RUNNER_TEMP=${JSON.stringify(runnerTemp)}`,
hostingBlockSource(),
'printf \'RAW_BASE=%s\\n\' "$RAW_BASE"',
].join('\n');
const driverPath = join(dir, 'driver.sh');
writeFileSync(driverPath, script);
const res = spawnSync('bash', [driverPath], {
encoding: 'utf8',
cwd: work,
env: {
...process.env,
OSS_STUB_ROOT: stubRoot,
OSS_STUB_RECORD: recordPath,
OSS_STUB_FAIL: uploadFails ? '1' : '0',
},
});
return { res, recordPath, stubRoot, pr, headSha, runnerTemp };
}

test('hosting block uploads staged images to the exact prefix RAW_BASE promises', () => {
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
const { res, recordPath, stubRoot, pr, headSha, runnerTemp } =
runHostingBlock(true);
assert.equal(res.status, 0, res.stderr);
// Flag wiring: the uploader gets the bucket, the credential file the
// configure step writes, and the prefix the comment URLs are built from.
const record = JSON.parse(readFileSync(recordPath, 'utf8'));
assert.deepEqual(record, {
bucket: 'assets-bucket',
config: `${runnerTemp}/.ossutilconfig`,
prefix: `pr-assets/web-shell-visuals/${pr}/${headSha}`,
});
// Upload-prefix ↔ URL agreement: the objects land exactly where RAW_BASE
// (the comment's image base URL) points.
const hosted = readdirSync(
join(
stubRoot,
'assets-bucket',
'pr-assets',
'web-shell-visuals',
pr,
headSha,
),
).sort();
assert.deepEqual(hosted, ['home-light.png', 'model-switch.gif']);
assert.match(
res.stdout,
new RegExp(
`^RAW_BASE=https://assets\\.example\\.test/pr-assets/web-shell-visuals/${pr}/${headSha}$`,
'm',
),
);
assert.match(
res.stdout,
new RegExp(
`Web-shell visuals hosted at https://assets\\.example\\.test/pr-assets/web-shell-visuals/${pr}/${headSha}\\.`,
),
);
});

test('hosting block skips the uploader entirely on the no-change arm', () => {
const { res, recordPath } = runHostingBlock(false);
assert.equal(res.status, 0, res.stderr);
assert.match(res.stdout, /^RAW_BASE=$/m); // empty -> image-less comment
assert.doesNotMatch(res.stdout, /hosted at/);
assert.equal(existsSync(recordPath), false); // the uploader never ran
});

test('hosting block aborts without publishing a URL when upload fails', () => {
const { res, recordPath } = runHostingBlock(true, { uploadFails: true });
assert.notEqual(res.status, 0);
assert.doesNotMatch(res.stdout, /^RAW_BASE=/m);
assert.equal(existsSync(recordPath), false);
});

test('hosting block strips a trailing slash from the public base URL', () => {
const { res, pr, headSha } = runHostingBlock(true, {
publicBaseUrl: 'https://assets.example.test/',
});
assert.equal(res.status, 0, res.stderr);
assert.match(
res.stdout,
new RegExp(
`^RAW_BASE=https://assets\\.example\\.test/pr-assets/web-shell-visuals/${pr}/${headSha}$`,
'm',
),
);
assert.doesNotMatch(res.stdout, /assets\.example\.test\/\/pr-assets/);
});

test('sanitizeName preserves the extension (regression: a trailing char broke the .png filter)', () => {
assert.equal(
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/.size-baseline
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
20525 qwen-issue-followup-bot.yml
5760 qwen-pr-safety-precheck.yml
27648 qwen-triage-finalize.yml
344548 qwen-triage.yml
348371 qwen-triage.yml
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
9657 release-sdk-java.yml
22037 release-sdk-python.yml
19094 release-sdk.yml
Expand All @@ -57,6 +57,6 @@
10138 sync-release-to-oss.yml
3303 update-ecs-runner-qwen.yml
2307 web-shell-visuals-cleanup.yml
15380 web-shell-visuals-publish.yml
17008 web-shell-visuals-publish.yml
16384 web-shell-visuals.yml
4712 windows-runner-smoke.yml
17 changes: 6 additions & 11 deletions .github/workflows/qwen-code-pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -898,17 +898,12 @@ jobs:
QWEN_CODE_API_TIMEOUT_MS: '600000'
QWEN_STREAM_IDLE_TIMEOUT_MS: '600000'
QWEN_STREAM_MAX_LIFETIME_MS: '1800000'
# Evidence-image destination for `qwen review publish-assets` —
# OPT-IN by design: the command refuses to push images anywhere the
# user did not designate, so with the repository variable unset the
# review simply keeps its evidence as prose and local paths. Set the
# variable (e.g. to this repository) to let reviews embed capture
# PNGs; images land on commit-pinned pr-assets/<pr>-review branches,
# pushed with the same CI_BOT_PAT this step already uses for gh.
# Retention: the visuals cleanup workflow deletes those branches
# only when the variable points at THIS repository — a fork or
# scratch destination manages its own retention.
QWEN_REVIEW_ASSETS_REPO: '${{ vars.QWEN_REVIEW_ASSETS_REPO }}'
# Evidence-image destination for `qwen review publish-assets`.
# It must be a dedicated external host repository: project-local
# image branches are fetched by ordinary clones and permanently
# inflate this repository. Unset or self-targeting configurations
# deliberately degrade to prose and local artifact paths.
QWEN_REVIEW_ASSETS_REPO: "${{ vars.QWEN_REVIEW_ASSETS_REPO != github.repository && vars.QWEN_REVIEW_ASSETS_REPO || '' }}"
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
# Per-run agent home so this review's session/memory cannot leak into
# the next on the reused self-hosted workspace (reset in "Clean stale
# agent state"). Must match the QWEN_HOME computed there.
Expand Down
Loading
Loading