mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
fix(ci/triage): remove OpenAI proxy and Rust/Code caches; call API directly in safety screen\n\n- Drop local proxy step and OPENAI_BASE_URL override\n- Strip unused Rust toolchain/cache and Code binary cache\n- Keep Node setup only; triage doesn’t build or run Rust\n- Keeps safety screen using Responses API (gpt-5→gpt-4o-mini fallback)
This commit is contained in:
@@ -118,39 +118,7 @@ jobs:
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Cache npm (npx) downloads
|
||||
timeout-minutes: 5
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.npm
|
||||
key: npm-cache-${{ runner.os }}-node20-${{ hashFiles('**/package-lock.json', '**/pnpm-lock.yaml', '**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
npm-cache-${{ runner.os }}-node20-
|
||||
|
||||
- name: Cache Code binary bootstrap (~/.cache/just-every/code)
|
||||
timeout-minutes: 5
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/just-every/code
|
||||
key: code-bin-cache-${{ runner.os }}-v1
|
||||
restore-keys: |
|
||||
code-bin-cache-${{ runner.os }}-
|
||||
|
||||
- name: Setup Rust toolchain (match repo)
|
||||
timeout-minutes: 5
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: 1.89.0
|
||||
|
||||
- name: Cache Rust build (cargo + target)
|
||||
timeout-minutes: 5
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: |
|
||||
codex-rs -> target
|
||||
save-if: true
|
||||
# No Rust or heavy npm usage in triage; skip related caches and toolchains.
|
||||
|
||||
- name: Configure Git author
|
||||
timeout-minutes: 5
|
||||
@@ -314,7 +282,6 @@ jobs:
|
||||
uses: actions/github-script@v7
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
OPENAI_BASE_URL: http://127.0.0.1:5054/v1
|
||||
with:
|
||||
script: |
|
||||
const apiKey = process.env.OPENAI_API_KEY;
|
||||
@@ -323,7 +290,7 @@ jobs:
|
||||
core.setOutput('reason', 'Missing OPENAI_API_KEY for safety screening.');
|
||||
core.notice('Safety: block (no OPENAI_API_KEY)');
|
||||
} else {
|
||||
const base = (process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1').replace(/\/$/,'');
|
||||
const base = 'https://api.openai.com/v1';
|
||||
async function callResponses(model) {
|
||||
const input = [
|
||||
{
|
||||
@@ -383,7 +350,7 @@ jobs:
|
||||
}
|
||||
}
|
||||
};
|
||||
return fetch(base + '/responses', {
|
||||
return fetch(base + '/responses', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${apiKey}`, 'OpenAI-Beta': 'responses=experimental' },
|
||||
body: JSON.stringify(payload)
|
||||
@@ -428,50 +395,6 @@ jobs:
|
||||
}
|
||||
}
|
||||
|
||||
- name: Start local OpenAI proxy for triage (hardened)
|
||||
if: env.OPENAI_API_KEY != ''
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p .github/auto
|
||||
cat > .github/auto/openai-proxy.js <<'JS'
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const crypto = require('crypto');
|
||||
const { URL } = require('url');
|
||||
const PORT = process.env.PORT || 5054;
|
||||
const API_KEY = process.env.OPENAI_API_KEY || '';
|
||||
const UPSTREAM = new URL(process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1');
|
||||
const ALLOWED = ['/v1/chat/completions','/v1/responses'];
|
||||
if (!API_KEY) { process.exit(0); }
|
||||
function log(ev){ try{ console.log(JSON.stringify({ ts:new Date().toISOString(), ...ev })); }catch{} }
|
||||
const server = http.createServer((req, res) => {
|
||||
const rid = crypto.randomUUID();
|
||||
if (!ALLOWED.some(p => req.url.startsWith(p))) { res.writeHead(403,{'content-type':'application/json'}); res.end(JSON.stringify({error:'blocked', path:req.url})); return; }
|
||||
const chunks=[]; req.on('data', c=>{ chunks.push(c); if (Buffer.concat(chunks).length>2*1024*1024) req.destroy(); });
|
||||
req.on('end', ()=>{
|
||||
const body = Buffer.concat(chunks);
|
||||
const up = new URL(req.url, UPSTREAM);
|
||||
const headers = { ...req.headers };
|
||||
if (!headers['content-type']) headers['content-type']='application/json';
|
||||
headers['authorization'] = `Bearer ${API_KEY}`;
|
||||
if (up.pathname.startsWith('/v1/responses') && !headers['openai-beta']) headers['openai-beta']='responses=experimental';
|
||||
delete headers['host']; headers['host']=up.host;
|
||||
if (headers['content-length']) headers['content-length']=String(body.length);
|
||||
const opts = { protocol: up.protocol, hostname: up.hostname, port: up.port || (up.protocol==='https:'?443:80), path: up.pathname+up.search, method: req.method, headers,
|
||||
servername: up.hostname, agent:(up.protocol==='https:'? new https.Agent({keepAlive:true, maxSockets:64, servername: up.hostname}) : new http.Agent({keepAlive:true, maxSockets:64})) };
|
||||
const fw = (up.protocol==='https:'?https:http).request(opts, r=>{ res.writeHead(r.statusCode||500, r.headers); r.pipe(res); });
|
||||
fw.on('error', e=>{ log({ level:'error', rid, phase:'upstream_error', err:String(e) }); res.writeHead(502,{'content-type':'application/json'}); res.end(JSON.stringify({ error:'upstream', message: String(e.message||e) })); });
|
||||
fw.end(body);
|
||||
});
|
||||
});
|
||||
server.headersTimeout=650000; server.keepAliveTimeout=650000;
|
||||
server.listen(PORT,'127.0.0.1',()=>{ log({ level:'info', msg:'proxy listening', addr:'127.0.0.1', port: PORT }); });
|
||||
JS
|
||||
node .github/auto/openai-proxy.js > .github/auto/openai-proxy.log 2>&1 &
|
||||
for i in {1..30}; do if nc -z 127.0.0.1 5054; then break; else sleep 0.2; fi; done || true
|
||||
|
||||
- name: Gate decision (proceed vs. comment-only)
|
||||
timeout-minutes: 5
|
||||
id: gate
|
||||
|
||||
Reference in New Issue
Block a user