Counts
Passed, failed, blocked, needs-review and not-run checks. Blocked, needs-review and not-run never count as passed.
Guide · GitHub Actions, GitLab, Bitbucket, CircleCI
Save a reviewed Sybqa plan once. A GitHub Actions, GitLab CI, Bitbucket Pipelines or CircleCI job can submit it to Sybqa on each pull request or preview deployment, wait for a real-browser run, and publish the verdict and evidence report link. The four pipeline templates below use the same runner, and the shell script mirrors its rules.
First published · Last updated
.sybqa/plan.json.SYBQA_API_TOKEN..github/workflows/sybqa.yml:name: Sybqa QA
on: pull_request
permissions:
contents: read
jobs:
sybqa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- id: sybqa
name: Run Sybqa website QA
env:
SYBQA_URL: https://app.sybqa.com
SYBQA_API_TOKEN: ${{ secrets.SYBQA_API_TOKEN }}
SYBQA_PLAN: .sybqa/plan.json
SYBQA_TARGET_URL: https://staging.example.com
SYBQA_FAIL_ON: fail
run: |
node --input-type=module <<'NODE'
async function sybqaRunner() {
const { appendFile, mkdir, readFile, writeFile } = await import('node:fs/promises');
const { dirname } = await import('node:path');
const env = process.env;
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
// Site text is untrusted: escape Markdown so a check summary cannot add links, images or emphasis to the job summary.
const clean = value => String(value ?? '').replace(/\s+/g, ' ').trim().slice(0, 200).replace(/[&<>]/g, char => ({ '&': '&', '<': '<', '>': '>' })[char]).replace(/[\\[\]()!*_~#|]/g, '\\$&').replace(/^[-+]/, '\\$&').replace(/@/g, '@\u200b').replace(/`/g, "'");
const xml = value => String(value ?? '').replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, '').replace(/[<>&"']/g, char => ({ '<': '<', '>': '>', '&': '&', '"': '"', "'": ''' })[char]);
// The server's rule (check-policy.ts): only explicitly advisory, non-required checks are outside the verdict.
const isAdvisory = check => check?.advisory === true && check?.required === false;
const ciName = env.GITHUB_ACTIONS ? 'github-actions' : env.GITLAB_CI ? 'gitlab-ci' : env.BITBUCKET_BUILD_NUMBER ? 'bitbucket-pipelines' : env.CIRCLECI ? 'circleci' : 'ci';
const revision = env.GITHUB_SHA || env.CI_COMMIT_SHA || env.BITBUCKET_COMMIT || env.CIRCLE_SHA1 || '';
const branch = env.GITHUB_REF_NAME || env.CI_COMMIT_REF_NAME || env.BITBUCKET_BRANCH || env.CIRCLE_BRANCH || '';
try {
const raw = env.SYBQA_URL || 'https://app.sybqa.com';
const base = new URL(raw);
// A user name or password hides the real host (http://localhost:@evil.test goes to evil.test); the shell script refuses it too.
if (base.username || base.password || /^[^/]*\/\/[^/]*@/.test(raw)) throw new Error('SYBQA_URL must not contain a user name or password.');
const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(base.hostname);
if (base.protocol !== 'https:' && !(base.protocol === 'http:' && loopback)) throw new Error('SYBQA_URL must use HTTPS except on loopback.');
base.pathname = base.pathname.replace(/\/+$/, '');
const token = env.SYBQA_API_TOKEN;
if (!/^sybqa_[A-Za-z0-9_-]{43}$/.test(token ?? '')) throw new Error('SYBQA_API_TOKEN is missing or invalid. GitHub withholds repository secrets from fork pull requests and Dependabot; other CIs hide protected variables from unprotected branches.');
const failOn = env.SYBQA_FAIL_ON || 'fail';
if (!['fail', 'review', 'never'].includes(failOn)) throw new Error('SYBQA_FAIL_ON must be fail, review or never.');
const document = JSON.parse(await readFile(env.SYBQA_PLAN || '.sybqa/plan.json', 'utf8'));
const plan = document.plan && typeof document.plan === 'object' ? document.plan : document;
const profile = plan.profile && typeof plan.profile === 'object' ? plan.profile : plan;
if (typeof profile.target !== 'string') throw new Error('The plan has no target. Download plan JSON from the Sybqa Plan page.');
if (env.SYBQA_TARGET_URL) { profile.target = env.SYBQA_TARGET_URL; if (plan !== profile) plan.target = env.SYBQA_TARGET_URL; }
const context = { ...(profile.runContext && typeof profile.runContext === 'object' ? profile.runContext : {}) };
if (!context.revision && revision) context.revision = revision.slice(0, 80);
if (!context.environment) context.environment = `${ciName}${branch ? ` ${branch}` : ''}`.slice(0, 80);
profile.runContext = context;
const body = JSON.stringify(plan === profile ? { profile } : { plan });
const headers = { authorization: `Bearer ${token}`, accept: 'application/json', 'content-type': 'application/json' };
const deadline = Date.now() + 30 * 60_000;
const read = async response => ({ response, payload: await response.json().catch(() => ({})) });
let started;
while (!started) {
const { response, payload } = await read(await fetch(new URL('/api/runs', base), { method: 'POST', headers, body }));
if (response.status === 429 && payload.code !== 'token_rate_limited' && Date.now() + 30_000 < deadline) { console.log('Sybqa run queue is full; retrying in 30 seconds.'); await sleep(30_000); continue; }
if (!response.ok) throw new Error(`Sybqa refused to start the run (${response.status}): ${payload.error ?? 'no details'}`);
started = payload;
}
const runId = started.id;
if (typeof runId !== 'string' || !/^run-[a-z0-9-]+$/.test(runId)) throw new Error('Sybqa did not return a run id.');
const terminal = new Set(['completed', 'blocked', 'failed', 'cancelled']);
let state = started, timedOut = false, misses = 0;
while (!terminal.has(state.status)) {
if (Date.now() >= deadline) { timedOut = true; break; }
await sleep(Math.min(10_000, deadline - Date.now()));
try {
const { response, payload } = await read(await fetch(new URL(`/api/runs/${encodeURIComponent(runId)}`, base), { headers }));
if (response.ok) { state = payload; misses = 0; continue; }
if ([401, 404].includes(response.status)) throw new Error(`Sybqa stopped returning run ${runId} (${response.status}).`);
if (++misses > 5) throw new Error(`Could not read run ${runId} after repeated API errors (${response.status}).`);
} catch (error) { if (error.message.startsWith('Sybqa stopped') || error.message.startsWith('Could not read')) throw error; if (++misses > 5) throw new Error('Could not read the Sybqa run after repeated network errors.'); }
}
const all = Array.isArray(state.checks) ? state.checks.filter(check => check && typeof check === 'object') : [];
// The counts, top failures and JUnit list the checks the evidence report shows (certificate.ts shownChecks):
// run notes (note: true) are bookkeeping about the run, and a failed journey's replay and learning records
// sit on that journey's card. Advisory checks are counted, as on the report, but never decide the verdict.
const failedIds = new Set(all.filter(check => check.status === 'FAIL').map(check => check.id));
const companion = check => failedIds.has(/^((?:bot:[^:]+:)?journey:.+):(?:reproduction|learning)$/.exec(String(check.id ?? ''))?.[1]);
const shown = all.filter(check => check.note !== true && !companion(check));
const notes = all.filter(check => check.note === true).length;
const advisory = shown.filter(isAdvisory).length;
const counts = { PASS: 0, FAIL: 0, BLOCKED: 0, NEEDS_REVIEW: 0, NOT_RUN: 0 };
for (const check of shown) if (Object.hasOwn(counts, check.status)) counts[check.status]++;
const listed = shown.filter(check => !isAdvisory(check));
const failures = new Map();
for (const check of listed) if (check.status === 'FAIL') failures.set(check.summary, (failures.get(check.summary) ?? 0) + 1);
// The server's verdict (run-store.ts): its result when the run has one. Otherwise it is acceptance over every
// check that is not advisory (check-policy.ts): any failure fails, and only a required check that did not pass
// keeps the run open; a non-required check never does.
const acceptance = all.filter(check => !isAdvisory(check));
const failed = acceptance.some(check => check.status === 'FAIL');
const open = !acceptance.length || acceptance.some(check => check.required !== false && check.status !== 'PASS');
const verdict = timedOut ? 'timeout' : ['failed', 'cancelled'].includes(state.status) ? 'error' : failed || state.result === 'issues' ? 'fail' : state.result === 'pass' ? 'pass' : state.result === 'incomplete' || state.status === 'blocked' || open ? 'review' : 'pass';
const reportUrl = state.reportPath ? new URL(state.reportPath, base).toString() : new URL(`/app?run=${encodeURIComponent(runId)}`, base).toString();
const top = [...failures.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5);
const summary = [`### Sybqa QA · ${verdict}`, '', `Target: ${clean(profile.target)} · run \`${clean(runId)}\` · status ${clean(timedOut ? `${state.status} (timed out)` : state.status)}`, '', '| PASS | FAIL | BLOCKED | NEEDS_REVIEW | NOT_RUN |', '| ---: | ---: | ---: | ---: | ---: |', `| ${counts.PASS} | ${counts.FAIL} | ${counts.BLOCKED} | ${counts.NEEDS_REVIEW} | ${counts.NOT_RUN} |`, ''];
const aside = [advisory ? `${advisory} advisory check${advisory === 1 ? ' is' : 's are'} counted but ${advisory === 1 ? 'does' : 'do'} not decide the verdict.` : '', notes ? `${notes} run note${notes === 1 ? ' is' : 's are'} listed apart, as on the report.` : ''].filter(Boolean);
if (aside.length) summary.push(aside.join(' '), '');
if (top.length) summary.push('**Top failures**', '', ...top.map(([message, times]) => `- [${clean(message)}](${reportUrl})${times > 1 ? ` · seen ${times} times` : ''}`), '');
summary.push(`[Open the evidence report](${reportUrl})`, '');
if (env.GITHUB_STEP_SUMMARY) await appendFile(env.GITHUB_STEP_SUMMARY, summary.join('\n'));
if (env.GITHUB_OUTPUT) await appendFile(env.GITHUB_OUTPUT, `run-id=${runId}\nreport-url=${reportUrl}\nverdict=${verdict}\n`);
if (env.SYBQA_JUNIT) {
// The CI test view lists the checks that decide the verdict: advisory checks stay in the summary only.
const cases = listed.map(check => {
const name = `<testcase classname="sybqa" name="${xml(check.id)}"`;
if (check.status === 'PASS') return ` ${name}/>`;
if (check.status === 'FAIL') return ` ${name}><failure message="${xml(String(check.summary ?? '').slice(0, 500))}">${xml(reportUrl)}</failure></testcase>`;
return ` ${name}><skipped message="${xml(`${check.status}: ${String(check.summary ?? '').slice(0, 480)}`)}"/></testcase>`;
});
const skipped = listed.filter(check => !['PASS', 'FAIL'].includes(check.status)).length;
await mkdir(dirname(env.SYBQA_JUNIT), { recursive: true });
await writeFile(env.SYBQA_JUNIT, [`<?xml version="1.0" encoding="UTF-8"?>`, `<testsuite name="Sybqa QA" tests="${listed.length}" failures="${listed.filter(check => check.status === 'FAIL').length}" skipped="${skipped}">`, ...cases, '</testsuite>', ''].join('\n'));
}
console.log(summary.filter(line => !line.startsWith('|')).join('\n').replace(/\n{2,}/g, '\n'));
console.log(`Sybqa verdict: ${verdict} · PASS ${counts.PASS} · FAIL ${counts.FAIL} · BLOCKED ${counts.BLOCKED} · NEEDS_REVIEW ${counts.NEEDS_REVIEW} · NOT_RUN ${counts.NOT_RUN}`);
if (failOn !== 'never' && ['fail', 'error', 'timeout'].includes(verdict) || failOn === 'review' && verdict === 'review') process.exitCode = 1;
} catch (error) { console.error(`${env.GITHUB_ACTIONS ? '::error::' : 'Sybqa error: '}${String(error?.message ?? error).replace(/[\r\n]+/g, ' ')}`); process.exitCode = 1; }
}
await sybqaRunner();
NODE
Open a pull request. The job waits up to 30 minutes and puts the verdict and report link in its summary. With SYBQA_FAIL_ON: fail it fails on failed checks, errors and timeouts; set SYBQA_FAIL_ON: review to also fail on blocked, unrun or needs-review checks, or never to report without blocking merges. GitHub withholds Actions secrets from pull requests opened from forks and Dependabot, so this example reports a clear error there instead of running without a token.
Hosts such as Vercel and Netlify report a preview URL through GitHub deployment events. To test the deployed build, copy the same job above, change its trigger to on: deployment_status, add if: github.event.deployment_status.state == 'success' to the job, and set SYBQA_TARGET_URL: ${{ github.event.deployment_status.environment_url }}. The API request then tests that preview URL instead of the fixed staging site. Each preview URL is a new address, so New failures since the last run alerts and fix checks do not compare preview runs; use Run failed alerts.
Sybqa does not send Vercel’s protection bypass header or a preview password, so a protected preview returns its login page and the checks are blocked, not passed. Point SYBQA_TARGET_URL at a preview you have chosen to leave open, or at a staging domain. The authenticated preview guide explains what each access layer proves.
Passed, failed, blocked, needs-review and not-run checks. Blocked, needs-review and not-run never count as passed.
The five most frequent failures, listed first.
The full evidence report with screenshots and steps to reproduce. Opening it requires signing in to Sybqa.
verdict, run-id and report-url are available to later steps in the job.
SYBQA_FAIL_ON controls the job result: fail (the value in these templates, and the default when it is unset) fails on failed checks, errors and timeouts and lets review results pass; review also fails when a required check is blocked, not run or needs review, and on unfinished runs; never only reports. The verdict is the run’s own result from the Sybqa server, so a run the report calls passed is pass here too. Checks that are not required, and advisory notes that sit outside the plan’s acceptance, such as a link that leaves the site, are counted but never change the verdict.
Add SYBQA_API_TOKEN as a masked CI/CD variable, commit the plan, and add this job to .gitlab-ci.yml. It writes a JUnit file and declares it under artifacts:reports:junit, which GitLab uses for its test report view (GitLab unit test reports, read 2026-11-04). The verdict and the evidence report link print in the job log, and each failed check appears in the test report with the same link.
.gitlab-ci.ymlsybqa:
image: node:24
stage: test
variables:
SYBQA_URL: https://app.sybqa.com
SYBQA_PLAN: .sybqa/plan.json
SYBQA_TARGET_URL: https://staging.example.com
SYBQA_FAIL_ON: fail
SYBQA_JUNIT: sybqa-junit.xml
script:
- |
node --input-type=module <<'NODE'
async function sybqaRunner() {
const { appendFile, mkdir, readFile, writeFile } = await import('node:fs/promises');
const { dirname } = await import('node:path');
const env = process.env;
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
// Site text is untrusted: escape Markdown so a check summary cannot add links, images or emphasis to the job summary.
const clean = value => String(value ?? '').replace(/\s+/g, ' ').trim().slice(0, 200).replace(/[&<>]/g, char => ({ '&': '&', '<': '<', '>': '>' })[char]).replace(/[\\[\]()!*_~#|]/g, '\\$&').replace(/^[-+]/, '\\$&').replace(/@/g, '@\u200b').replace(/`/g, "'");
const xml = value => String(value ?? '').replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, '').replace(/[<>&"']/g, char => ({ '<': '<', '>': '>', '&': '&', '"': '"', "'": ''' })[char]);
// The server's rule (check-policy.ts): only explicitly advisory, non-required checks are outside the verdict.
const isAdvisory = check => check?.advisory === true && check?.required === false;
const ciName = env.GITHUB_ACTIONS ? 'github-actions' : env.GITLAB_CI ? 'gitlab-ci' : env.BITBUCKET_BUILD_NUMBER ? 'bitbucket-pipelines' : env.CIRCLECI ? 'circleci' : 'ci';
const revision = env.GITHUB_SHA || env.CI_COMMIT_SHA || env.BITBUCKET_COMMIT || env.CIRCLE_SHA1 || '';
const branch = env.GITHUB_REF_NAME || env.CI_COMMIT_REF_NAME || env.BITBUCKET_BRANCH || env.CIRCLE_BRANCH || '';
try {
const raw = env.SYBQA_URL || 'https://app.sybqa.com';
const base = new URL(raw);
// A user name or password hides the real host (http://localhost:@evil.test goes to evil.test); the shell script refuses it too.
if (base.username || base.password || /^[^/]*\/\/[^/]*@/.test(raw)) throw new Error('SYBQA_URL must not contain a user name or password.');
const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(base.hostname);
if (base.protocol !== 'https:' && !(base.protocol === 'http:' && loopback)) throw new Error('SYBQA_URL must use HTTPS except on loopback.');
base.pathname = base.pathname.replace(/\/+$/, '');
const token = env.SYBQA_API_TOKEN;
if (!/^sybqa_[A-Za-z0-9_-]{43}$/.test(token ?? '')) throw new Error('SYBQA_API_TOKEN is missing or invalid. GitHub withholds repository secrets from fork pull requests and Dependabot; other CIs hide protected variables from unprotected branches.');
const failOn = env.SYBQA_FAIL_ON || 'fail';
if (!['fail', 'review', 'never'].includes(failOn)) throw new Error('SYBQA_FAIL_ON must be fail, review or never.');
const document = JSON.parse(await readFile(env.SYBQA_PLAN || '.sybqa/plan.json', 'utf8'));
const plan = document.plan && typeof document.plan === 'object' ? document.plan : document;
const profile = plan.profile && typeof plan.profile === 'object' ? plan.profile : plan;
if (typeof profile.target !== 'string') throw new Error('The plan has no target. Download plan JSON from the Sybqa Plan page.');
if (env.SYBQA_TARGET_URL) { profile.target = env.SYBQA_TARGET_URL; if (plan !== profile) plan.target = env.SYBQA_TARGET_URL; }
const context = { ...(profile.runContext && typeof profile.runContext === 'object' ? profile.runContext : {}) };
if (!context.revision && revision) context.revision = revision.slice(0, 80);
if (!context.environment) context.environment = `${ciName}${branch ? ` ${branch}` : ''}`.slice(0, 80);
profile.runContext = context;
const body = JSON.stringify(plan === profile ? { profile } : { plan });
const headers = { authorization: `Bearer ${token}`, accept: 'application/json', 'content-type': 'application/json' };
const deadline = Date.now() + 30 * 60_000;
const read = async response => ({ response, payload: await response.json().catch(() => ({})) });
let started;
while (!started) {
const { response, payload } = await read(await fetch(new URL('/api/runs', base), { method: 'POST', headers, body }));
if (response.status === 429 && payload.code !== 'token_rate_limited' && Date.now() + 30_000 < deadline) { console.log('Sybqa run queue is full; retrying in 30 seconds.'); await sleep(30_000); continue; }
if (!response.ok) throw new Error(`Sybqa refused to start the run (${response.status}): ${payload.error ?? 'no details'}`);
started = payload;
}
const runId = started.id;
if (typeof runId !== 'string' || !/^run-[a-z0-9-]+$/.test(runId)) throw new Error('Sybqa did not return a run id.');
const terminal = new Set(['completed', 'blocked', 'failed', 'cancelled']);
let state = started, timedOut = false, misses = 0;
while (!terminal.has(state.status)) {
if (Date.now() >= deadline) { timedOut = true; break; }
await sleep(Math.min(10_000, deadline - Date.now()));
try {
const { response, payload } = await read(await fetch(new URL(`/api/runs/${encodeURIComponent(runId)}`, base), { headers }));
if (response.ok) { state = payload; misses = 0; continue; }
if ([401, 404].includes(response.status)) throw new Error(`Sybqa stopped returning run ${runId} (${response.status}).`);
if (++misses > 5) throw new Error(`Could not read run ${runId} after repeated API errors (${response.status}).`);
} catch (error) { if (error.message.startsWith('Sybqa stopped') || error.message.startsWith('Could not read')) throw error; if (++misses > 5) throw new Error('Could not read the Sybqa run after repeated network errors.'); }
}
const all = Array.isArray(state.checks) ? state.checks.filter(check => check && typeof check === 'object') : [];
// The counts, top failures and JUnit list the checks the evidence report shows (certificate.ts shownChecks):
// run notes (note: true) are bookkeeping about the run, and a failed journey's replay and learning records
// sit on that journey's card. Advisory checks are counted, as on the report, but never decide the verdict.
const failedIds = new Set(all.filter(check => check.status === 'FAIL').map(check => check.id));
const companion = check => failedIds.has(/^((?:bot:[^:]+:)?journey:.+):(?:reproduction|learning)$/.exec(String(check.id ?? ''))?.[1]);
const shown = all.filter(check => check.note !== true && !companion(check));
const notes = all.filter(check => check.note === true).length;
const advisory = shown.filter(isAdvisory).length;
const counts = { PASS: 0, FAIL: 0, BLOCKED: 0, NEEDS_REVIEW: 0, NOT_RUN: 0 };
for (const check of shown) if (Object.hasOwn(counts, check.status)) counts[check.status]++;
const listed = shown.filter(check => !isAdvisory(check));
const failures = new Map();
for (const check of listed) if (check.status === 'FAIL') failures.set(check.summary, (failures.get(check.summary) ?? 0) + 1);
// The server's verdict (run-store.ts): its result when the run has one. Otherwise it is acceptance over every
// check that is not advisory (check-policy.ts): any failure fails, and only a required check that did not pass
// keeps the run open; a non-required check never does.
const acceptance = all.filter(check => !isAdvisory(check));
const failed = acceptance.some(check => check.status === 'FAIL');
const open = !acceptance.length || acceptance.some(check => check.required !== false && check.status !== 'PASS');
const verdict = timedOut ? 'timeout' : ['failed', 'cancelled'].includes(state.status) ? 'error' : failed || state.result === 'issues' ? 'fail' : state.result === 'pass' ? 'pass' : state.result === 'incomplete' || state.status === 'blocked' || open ? 'review' : 'pass';
const reportUrl = state.reportPath ? new URL(state.reportPath, base).toString() : new URL(`/app?run=${encodeURIComponent(runId)}`, base).toString();
const top = [...failures.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5);
const summary = [`### Sybqa QA · ${verdict}`, '', `Target: ${clean(profile.target)} · run \`${clean(runId)}\` · status ${clean(timedOut ? `${state.status} (timed out)` : state.status)}`, '', '| PASS | FAIL | BLOCKED | NEEDS_REVIEW | NOT_RUN |', '| ---: | ---: | ---: | ---: | ---: |', `| ${counts.PASS} | ${counts.FAIL} | ${counts.BLOCKED} | ${counts.NEEDS_REVIEW} | ${counts.NOT_RUN} |`, ''];
const aside = [advisory ? `${advisory} advisory check${advisory === 1 ? ' is' : 's are'} counted but ${advisory === 1 ? 'does' : 'do'} not decide the verdict.` : '', notes ? `${notes} run note${notes === 1 ? ' is' : 's are'} listed apart, as on the report.` : ''].filter(Boolean);
if (aside.length) summary.push(aside.join(' '), '');
if (top.length) summary.push('**Top failures**', '', ...top.map(([message, times]) => `- [${clean(message)}](${reportUrl})${times > 1 ? ` · seen ${times} times` : ''}`), '');
summary.push(`[Open the evidence report](${reportUrl})`, '');
if (env.GITHUB_STEP_SUMMARY) await appendFile(env.GITHUB_STEP_SUMMARY, summary.join('\n'));
if (env.GITHUB_OUTPUT) await appendFile(env.GITHUB_OUTPUT, `run-id=${runId}\nreport-url=${reportUrl}\nverdict=${verdict}\n`);
if (env.SYBQA_JUNIT) {
// The CI test view lists the checks that decide the verdict: advisory checks stay in the summary only.
const cases = listed.map(check => {
const name = `<testcase classname="sybqa" name="${xml(check.id)}"`;
if (check.status === 'PASS') return ` ${name}/>`;
if (check.status === 'FAIL') return ` ${name}><failure message="${xml(String(check.summary ?? '').slice(0, 500))}">${xml(reportUrl)}</failure></testcase>`;
return ` ${name}><skipped message="${xml(`${check.status}: ${String(check.summary ?? '').slice(0, 480)}`)}"/></testcase>`;
});
const skipped = listed.filter(check => !['PASS', 'FAIL'].includes(check.status)).length;
await mkdir(dirname(env.SYBQA_JUNIT), { recursive: true });
await writeFile(env.SYBQA_JUNIT, [`<?xml version="1.0" encoding="UTF-8"?>`, `<testsuite name="Sybqa QA" tests="${listed.length}" failures="${listed.filter(check => check.status === 'FAIL').length}" skipped="${skipped}">`, ...cases, '</testsuite>', ''].join('\n'));
}
console.log(summary.filter(line => !line.startsWith('|')).join('\n').replace(/\n{2,}/g, '\n'));
console.log(`Sybqa verdict: ${verdict} · PASS ${counts.PASS} · FAIL ${counts.FAIL} · BLOCKED ${counts.BLOCKED} · NEEDS_REVIEW ${counts.NEEDS_REVIEW} · NOT_RUN ${counts.NOT_RUN}`);
if (failOn !== 'never' && ['fail', 'error', 'timeout'].includes(verdict) || failOn === 'review' && verdict === 'review') process.exitCode = 1;
} catch (error) { console.error(`${env.GITHUB_ACTIONS ? '::error::' : 'Sybqa error: '}${String(error?.message ?? error).replace(/[\r\n]+/g, ' ')}`); process.exitCode = 1; }
}
await sybqaRunner();
NODE
artifacts:
when: always
reports:
junit: sybqa-junit.xml
Add SYBQA_API_TOKEN as a secured repository variable and save this as bitbucket-pipelines.yml. The JUnit file goes to test-results/, one of the directories Bitbucket scans for test reports, up to three levels deep (Bitbucket test reporting, read 2026-11-04). The verdict and the evidence report link print in the job log, and each failed check appears in the test report with the same link.
bitbucket-pipelines.ymlimage: node:24
pipelines:
default:
- step:
name: Sybqa QA
script:
- export SYBQA_URL=https://app.sybqa.com SYBQA_PLAN=.sybqa/plan.json SYBQA_TARGET_URL=https://staging.example.com SYBQA_FAIL_ON=fail SYBQA_JUNIT=test-results/sybqa-junit.xml
- |
node --input-type=module <<'NODE'
async function sybqaRunner() {
const { appendFile, mkdir, readFile, writeFile } = await import('node:fs/promises');
const { dirname } = await import('node:path');
const env = process.env;
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
// Site text is untrusted: escape Markdown so a check summary cannot add links, images or emphasis to the job summary.
const clean = value => String(value ?? '').replace(/\s+/g, ' ').trim().slice(0, 200).replace(/[&<>]/g, char => ({ '&': '&', '<': '<', '>': '>' })[char]).replace(/[\\[\]()!*_~#|]/g, '\\$&').replace(/^[-+]/, '\\$&').replace(/@/g, '@\u200b').replace(/`/g, "'");
const xml = value => String(value ?? '').replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, '').replace(/[<>&"']/g, char => ({ '<': '<', '>': '>', '&': '&', '"': '"', "'": ''' })[char]);
// The server's rule (check-policy.ts): only explicitly advisory, non-required checks are outside the verdict.
const isAdvisory = check => check?.advisory === true && check?.required === false;
const ciName = env.GITHUB_ACTIONS ? 'github-actions' : env.GITLAB_CI ? 'gitlab-ci' : env.BITBUCKET_BUILD_NUMBER ? 'bitbucket-pipelines' : env.CIRCLECI ? 'circleci' : 'ci';
const revision = env.GITHUB_SHA || env.CI_COMMIT_SHA || env.BITBUCKET_COMMIT || env.CIRCLE_SHA1 || '';
const branch = env.GITHUB_REF_NAME || env.CI_COMMIT_REF_NAME || env.BITBUCKET_BRANCH || env.CIRCLE_BRANCH || '';
try {
const raw = env.SYBQA_URL || 'https://app.sybqa.com';
const base = new URL(raw);
// A user name or password hides the real host (http://localhost:@evil.test goes to evil.test); the shell script refuses it too.
if (base.username || base.password || /^[^/]*\/\/[^/]*@/.test(raw)) throw new Error('SYBQA_URL must not contain a user name or password.');
const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(base.hostname);
if (base.protocol !== 'https:' && !(base.protocol === 'http:' && loopback)) throw new Error('SYBQA_URL must use HTTPS except on loopback.');
base.pathname = base.pathname.replace(/\/+$/, '');
const token = env.SYBQA_API_TOKEN;
if (!/^sybqa_[A-Za-z0-9_-]{43}$/.test(token ?? '')) throw new Error('SYBQA_API_TOKEN is missing or invalid. GitHub withholds repository secrets from fork pull requests and Dependabot; other CIs hide protected variables from unprotected branches.');
const failOn = env.SYBQA_FAIL_ON || 'fail';
if (!['fail', 'review', 'never'].includes(failOn)) throw new Error('SYBQA_FAIL_ON must be fail, review or never.');
const document = JSON.parse(await readFile(env.SYBQA_PLAN || '.sybqa/plan.json', 'utf8'));
const plan = document.plan && typeof document.plan === 'object' ? document.plan : document;
const profile = plan.profile && typeof plan.profile === 'object' ? plan.profile : plan;
if (typeof profile.target !== 'string') throw new Error('The plan has no target. Download plan JSON from the Sybqa Plan page.');
if (env.SYBQA_TARGET_URL) { profile.target = env.SYBQA_TARGET_URL; if (plan !== profile) plan.target = env.SYBQA_TARGET_URL; }
const context = { ...(profile.runContext && typeof profile.runContext === 'object' ? profile.runContext : {}) };
if (!context.revision && revision) context.revision = revision.slice(0, 80);
if (!context.environment) context.environment = `${ciName}${branch ? ` ${branch}` : ''}`.slice(0, 80);
profile.runContext = context;
const body = JSON.stringify(plan === profile ? { profile } : { plan });
const headers = { authorization: `Bearer ${token}`, accept: 'application/json', 'content-type': 'application/json' };
const deadline = Date.now() + 30 * 60_000;
const read = async response => ({ response, payload: await response.json().catch(() => ({})) });
let started;
while (!started) {
const { response, payload } = await read(await fetch(new URL('/api/runs', base), { method: 'POST', headers, body }));
if (response.status === 429 && payload.code !== 'token_rate_limited' && Date.now() + 30_000 < deadline) { console.log('Sybqa run queue is full; retrying in 30 seconds.'); await sleep(30_000); continue; }
if (!response.ok) throw new Error(`Sybqa refused to start the run (${response.status}): ${payload.error ?? 'no details'}`);
started = payload;
}
const runId = started.id;
if (typeof runId !== 'string' || !/^run-[a-z0-9-]+$/.test(runId)) throw new Error('Sybqa did not return a run id.');
const terminal = new Set(['completed', 'blocked', 'failed', 'cancelled']);
let state = started, timedOut = false, misses = 0;
while (!terminal.has(state.status)) {
if (Date.now() >= deadline) { timedOut = true; break; }
await sleep(Math.min(10_000, deadline - Date.now()));
try {
const { response, payload } = await read(await fetch(new URL(`/api/runs/${encodeURIComponent(runId)}`, base), { headers }));
if (response.ok) { state = payload; misses = 0; continue; }
if ([401, 404].includes(response.status)) throw new Error(`Sybqa stopped returning run ${runId} (${response.status}).`);
if (++misses > 5) throw new Error(`Could not read run ${runId} after repeated API errors (${response.status}).`);
} catch (error) { if (error.message.startsWith('Sybqa stopped') || error.message.startsWith('Could not read')) throw error; if (++misses > 5) throw new Error('Could not read the Sybqa run after repeated network errors.'); }
}
const all = Array.isArray(state.checks) ? state.checks.filter(check => check && typeof check === 'object') : [];
// The counts, top failures and JUnit list the checks the evidence report shows (certificate.ts shownChecks):
// run notes (note: true) are bookkeeping about the run, and a failed journey's replay and learning records
// sit on that journey's card. Advisory checks are counted, as on the report, but never decide the verdict.
const failedIds = new Set(all.filter(check => check.status === 'FAIL').map(check => check.id));
const companion = check => failedIds.has(/^((?:bot:[^:]+:)?journey:.+):(?:reproduction|learning)$/.exec(String(check.id ?? ''))?.[1]);
const shown = all.filter(check => check.note !== true && !companion(check));
const notes = all.filter(check => check.note === true).length;
const advisory = shown.filter(isAdvisory).length;
const counts = { PASS: 0, FAIL: 0, BLOCKED: 0, NEEDS_REVIEW: 0, NOT_RUN: 0 };
for (const check of shown) if (Object.hasOwn(counts, check.status)) counts[check.status]++;
const listed = shown.filter(check => !isAdvisory(check));
const failures = new Map();
for (const check of listed) if (check.status === 'FAIL') failures.set(check.summary, (failures.get(check.summary) ?? 0) + 1);
// The server's verdict (run-store.ts): its result when the run has one. Otherwise it is acceptance over every
// check that is not advisory (check-policy.ts): any failure fails, and only a required check that did not pass
// keeps the run open; a non-required check never does.
const acceptance = all.filter(check => !isAdvisory(check));
const failed = acceptance.some(check => check.status === 'FAIL');
const open = !acceptance.length || acceptance.some(check => check.required !== false && check.status !== 'PASS');
const verdict = timedOut ? 'timeout' : ['failed', 'cancelled'].includes(state.status) ? 'error' : failed || state.result === 'issues' ? 'fail' : state.result === 'pass' ? 'pass' : state.result === 'incomplete' || state.status === 'blocked' || open ? 'review' : 'pass';
const reportUrl = state.reportPath ? new URL(state.reportPath, base).toString() : new URL(`/app?run=${encodeURIComponent(runId)}`, base).toString();
const top = [...failures.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5);
const summary = [`### Sybqa QA · ${verdict}`, '', `Target: ${clean(profile.target)} · run \`${clean(runId)}\` · status ${clean(timedOut ? `${state.status} (timed out)` : state.status)}`, '', '| PASS | FAIL | BLOCKED | NEEDS_REVIEW | NOT_RUN |', '| ---: | ---: | ---: | ---: | ---: |', `| ${counts.PASS} | ${counts.FAIL} | ${counts.BLOCKED} | ${counts.NEEDS_REVIEW} | ${counts.NOT_RUN} |`, ''];
const aside = [advisory ? `${advisory} advisory check${advisory === 1 ? ' is' : 's are'} counted but ${advisory === 1 ? 'does' : 'do'} not decide the verdict.` : '', notes ? `${notes} run note${notes === 1 ? ' is' : 's are'} listed apart, as on the report.` : ''].filter(Boolean);
if (aside.length) summary.push(aside.join(' '), '');
if (top.length) summary.push('**Top failures**', '', ...top.map(([message, times]) => `- [${clean(message)}](${reportUrl})${times > 1 ? ` · seen ${times} times` : ''}`), '');
summary.push(`[Open the evidence report](${reportUrl})`, '');
if (env.GITHUB_STEP_SUMMARY) await appendFile(env.GITHUB_STEP_SUMMARY, summary.join('\n'));
if (env.GITHUB_OUTPUT) await appendFile(env.GITHUB_OUTPUT, `run-id=${runId}\nreport-url=${reportUrl}\nverdict=${verdict}\n`);
if (env.SYBQA_JUNIT) {
// The CI test view lists the checks that decide the verdict: advisory checks stay in the summary only.
const cases = listed.map(check => {
const name = `<testcase classname="sybqa" name="${xml(check.id)}"`;
if (check.status === 'PASS') return ` ${name}/>`;
if (check.status === 'FAIL') return ` ${name}><failure message="${xml(String(check.summary ?? '').slice(0, 500))}">${xml(reportUrl)}</failure></testcase>`;
return ` ${name}><skipped message="${xml(`${check.status}: ${String(check.summary ?? '').slice(0, 480)}`)}"/></testcase>`;
});
const skipped = listed.filter(check => !['PASS', 'FAIL'].includes(check.status)).length;
await mkdir(dirname(env.SYBQA_JUNIT), { recursive: true });
await writeFile(env.SYBQA_JUNIT, [`<?xml version="1.0" encoding="UTF-8"?>`, `<testsuite name="Sybqa QA" tests="${listed.length}" failures="${listed.filter(check => check.status === 'FAIL').length}" skipped="${skipped}">`, ...cases, '</testsuite>', ''].join('\n'));
}
console.log(summary.filter(line => !line.startsWith('|')).join('\n').replace(/\n{2,}/g, '\n'));
console.log(`Sybqa verdict: ${verdict} · PASS ${counts.PASS} · FAIL ${counts.FAIL} · BLOCKED ${counts.BLOCKED} · NEEDS_REVIEW ${counts.NEEDS_REVIEW} · NOT_RUN ${counts.NOT_RUN}`);
if (failOn !== 'never' && ['fail', 'error', 'timeout'].includes(verdict) || failOn === 'review' && verdict === 'review') process.exitCode = 1;
} catch (error) { console.error(`${env.GITHUB_ACTIONS ? '::error::' : 'Sybqa error: '}${String(error?.message ?? error).replace(/[\r\n]+/g, ' ')}`); process.exitCode = 1; }
}
await sybqaRunner();
NODE
Add SYBQA_API_TOKEN as a project environment variable and save this as .circleci/config.yml. The store_test_results step reads the JUnit XML the runner writes (CircleCI test data, read 2026-11-04). The verdict and the evidence report link print in the job log, and each failed check appears in the test report with the same link.
.circleci/config.ymlversion: 2.1
jobs:
sybqa:
docker:
- image: node:24
environment:
SYBQA_URL: https://app.sybqa.com
SYBQA_PLAN: .sybqa/plan.json
SYBQA_TARGET_URL: https://staging.example.com
SYBQA_FAIL_ON: fail
SYBQA_JUNIT: test-results/sybqa/junit.xml
steps:
- checkout
- run:
name: Run Sybqa website QA
command: |
node --input-type=module <<'NODE'
async function sybqaRunner() {
const { appendFile, mkdir, readFile, writeFile } = await import('node:fs/promises');
const { dirname } = await import('node:path');
const env = process.env;
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
// Site text is untrusted: escape Markdown so a check summary cannot add links, images or emphasis to the job summary.
const clean = value => String(value ?? '').replace(/\s+/g, ' ').trim().slice(0, 200).replace(/[&<>]/g, char => ({ '&': '&', '<': '<', '>': '>' })[char]).replace(/[\\[\]()!*_~#|]/g, '\\$&').replace(/^[-+]/, '\\$&').replace(/@/g, '@\u200b').replace(/`/g, "'");
const xml = value => String(value ?? '').replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, '').replace(/[<>&"']/g, char => ({ '<': '<', '>': '>', '&': '&', '"': '"', "'": ''' })[char]);
// The server's rule (check-policy.ts): only explicitly advisory, non-required checks are outside the verdict.
const isAdvisory = check => check?.advisory === true && check?.required === false;
const ciName = env.GITHUB_ACTIONS ? 'github-actions' : env.GITLAB_CI ? 'gitlab-ci' : env.BITBUCKET_BUILD_NUMBER ? 'bitbucket-pipelines' : env.CIRCLECI ? 'circleci' : 'ci';
const revision = env.GITHUB_SHA || env.CI_COMMIT_SHA || env.BITBUCKET_COMMIT || env.CIRCLE_SHA1 || '';
const branch = env.GITHUB_REF_NAME || env.CI_COMMIT_REF_NAME || env.BITBUCKET_BRANCH || env.CIRCLE_BRANCH || '';
try {
const raw = env.SYBQA_URL || 'https://app.sybqa.com';
const base = new URL(raw);
// A user name or password hides the real host (http://localhost:@evil.test goes to evil.test); the shell script refuses it too.
if (base.username || base.password || /^[^/]*\/\/[^/]*@/.test(raw)) throw new Error('SYBQA_URL must not contain a user name or password.');
const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(base.hostname);
if (base.protocol !== 'https:' && !(base.protocol === 'http:' && loopback)) throw new Error('SYBQA_URL must use HTTPS except on loopback.');
base.pathname = base.pathname.replace(/\/+$/, '');
const token = env.SYBQA_API_TOKEN;
if (!/^sybqa_[A-Za-z0-9_-]{43}$/.test(token ?? '')) throw new Error('SYBQA_API_TOKEN is missing or invalid. GitHub withholds repository secrets from fork pull requests and Dependabot; other CIs hide protected variables from unprotected branches.');
const failOn = env.SYBQA_FAIL_ON || 'fail';
if (!['fail', 'review', 'never'].includes(failOn)) throw new Error('SYBQA_FAIL_ON must be fail, review or never.');
const document = JSON.parse(await readFile(env.SYBQA_PLAN || '.sybqa/plan.json', 'utf8'));
const plan = document.plan && typeof document.plan === 'object' ? document.plan : document;
const profile = plan.profile && typeof plan.profile === 'object' ? plan.profile : plan;
if (typeof profile.target !== 'string') throw new Error('The plan has no target. Download plan JSON from the Sybqa Plan page.');
if (env.SYBQA_TARGET_URL) { profile.target = env.SYBQA_TARGET_URL; if (plan !== profile) plan.target = env.SYBQA_TARGET_URL; }
const context = { ...(profile.runContext && typeof profile.runContext === 'object' ? profile.runContext : {}) };
if (!context.revision && revision) context.revision = revision.slice(0, 80);
if (!context.environment) context.environment = `${ciName}${branch ? ` ${branch}` : ''}`.slice(0, 80);
profile.runContext = context;
const body = JSON.stringify(plan === profile ? { profile } : { plan });
const headers = { authorization: `Bearer ${token}`, accept: 'application/json', 'content-type': 'application/json' };
const deadline = Date.now() + 30 * 60_000;
const read = async response => ({ response, payload: await response.json().catch(() => ({})) });
let started;
while (!started) {
const { response, payload } = await read(await fetch(new URL('/api/runs', base), { method: 'POST', headers, body }));
if (response.status === 429 && payload.code !== 'token_rate_limited' && Date.now() + 30_000 < deadline) { console.log('Sybqa run queue is full; retrying in 30 seconds.'); await sleep(30_000); continue; }
if (!response.ok) throw new Error(`Sybqa refused to start the run (${response.status}): ${payload.error ?? 'no details'}`);
started = payload;
}
const runId = started.id;
if (typeof runId !== 'string' || !/^run-[a-z0-9-]+$/.test(runId)) throw new Error('Sybqa did not return a run id.');
const terminal = new Set(['completed', 'blocked', 'failed', 'cancelled']);
let state = started, timedOut = false, misses = 0;
while (!terminal.has(state.status)) {
if (Date.now() >= deadline) { timedOut = true; break; }
await sleep(Math.min(10_000, deadline - Date.now()));
try {
const { response, payload } = await read(await fetch(new URL(`/api/runs/${encodeURIComponent(runId)}`, base), { headers }));
if (response.ok) { state = payload; misses = 0; continue; }
if ([401, 404].includes(response.status)) throw new Error(`Sybqa stopped returning run ${runId} (${response.status}).`);
if (++misses > 5) throw new Error(`Could not read run ${runId} after repeated API errors (${response.status}).`);
} catch (error) { if (error.message.startsWith('Sybqa stopped') || error.message.startsWith('Could not read')) throw error; if (++misses > 5) throw new Error('Could not read the Sybqa run after repeated network errors.'); }
}
const all = Array.isArray(state.checks) ? state.checks.filter(check => check && typeof check === 'object') : [];
// The counts, top failures and JUnit list the checks the evidence report shows (certificate.ts shownChecks):
// run notes (note: true) are bookkeeping about the run, and a failed journey's replay and learning records
// sit on that journey's card. Advisory checks are counted, as on the report, but never decide the verdict.
const failedIds = new Set(all.filter(check => check.status === 'FAIL').map(check => check.id));
const companion = check => failedIds.has(/^((?:bot:[^:]+:)?journey:.+):(?:reproduction|learning)$/.exec(String(check.id ?? ''))?.[1]);
const shown = all.filter(check => check.note !== true && !companion(check));
const notes = all.filter(check => check.note === true).length;
const advisory = shown.filter(isAdvisory).length;
const counts = { PASS: 0, FAIL: 0, BLOCKED: 0, NEEDS_REVIEW: 0, NOT_RUN: 0 };
for (const check of shown) if (Object.hasOwn(counts, check.status)) counts[check.status]++;
const listed = shown.filter(check => !isAdvisory(check));
const failures = new Map();
for (const check of listed) if (check.status === 'FAIL') failures.set(check.summary, (failures.get(check.summary) ?? 0) + 1);
// The server's verdict (run-store.ts): its result when the run has one. Otherwise it is acceptance over every
// check that is not advisory (check-policy.ts): any failure fails, and only a required check that did not pass
// keeps the run open; a non-required check never does.
const acceptance = all.filter(check => !isAdvisory(check));
const failed = acceptance.some(check => check.status === 'FAIL');
const open = !acceptance.length || acceptance.some(check => check.required !== false && check.status !== 'PASS');
const verdict = timedOut ? 'timeout' : ['failed', 'cancelled'].includes(state.status) ? 'error' : failed || state.result === 'issues' ? 'fail' : state.result === 'pass' ? 'pass' : state.result === 'incomplete' || state.status === 'blocked' || open ? 'review' : 'pass';
const reportUrl = state.reportPath ? new URL(state.reportPath, base).toString() : new URL(`/app?run=${encodeURIComponent(runId)}`, base).toString();
const top = [...failures.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5);
const summary = [`### Sybqa QA · ${verdict}`, '', `Target: ${clean(profile.target)} · run \`${clean(runId)}\` · status ${clean(timedOut ? `${state.status} (timed out)` : state.status)}`, '', '| PASS | FAIL | BLOCKED | NEEDS_REVIEW | NOT_RUN |', '| ---: | ---: | ---: | ---: | ---: |', `| ${counts.PASS} | ${counts.FAIL} | ${counts.BLOCKED} | ${counts.NEEDS_REVIEW} | ${counts.NOT_RUN} |`, ''];
const aside = [advisory ? `${advisory} advisory check${advisory === 1 ? ' is' : 's are'} counted but ${advisory === 1 ? 'does' : 'do'} not decide the verdict.` : '', notes ? `${notes} run note${notes === 1 ? ' is' : 's are'} listed apart, as on the report.` : ''].filter(Boolean);
if (aside.length) summary.push(aside.join(' '), '');
if (top.length) summary.push('**Top failures**', '', ...top.map(([message, times]) => `- [${clean(message)}](${reportUrl})${times > 1 ? ` · seen ${times} times` : ''}`), '');
summary.push(`[Open the evidence report](${reportUrl})`, '');
if (env.GITHUB_STEP_SUMMARY) await appendFile(env.GITHUB_STEP_SUMMARY, summary.join('\n'));
if (env.GITHUB_OUTPUT) await appendFile(env.GITHUB_OUTPUT, `run-id=${runId}\nreport-url=${reportUrl}\nverdict=${verdict}\n`);
if (env.SYBQA_JUNIT) {
// The CI test view lists the checks that decide the verdict: advisory checks stay in the summary only.
const cases = listed.map(check => {
const name = `<testcase classname="sybqa" name="${xml(check.id)}"`;
if (check.status === 'PASS') return ` ${name}/>`;
if (check.status === 'FAIL') return ` ${name}><failure message="${xml(String(check.summary ?? '').slice(0, 500))}">${xml(reportUrl)}</failure></testcase>`;
return ` ${name}><skipped message="${xml(`${check.status}: ${String(check.summary ?? '').slice(0, 480)}`)}"/></testcase>`;
});
const skipped = listed.filter(check => !['PASS', 'FAIL'].includes(check.status)).length;
await mkdir(dirname(env.SYBQA_JUNIT), { recursive: true });
await writeFile(env.SYBQA_JUNIT, [`<?xml version="1.0" encoding="UTF-8"?>`, `<testsuite name="Sybqa QA" tests="${listed.length}" failures="${listed.filter(check => check.status === 'FAIL').length}" skipped="${skipped}">`, ...cases, '</testsuite>', ''].join('\n'));
}
console.log(summary.filter(line => !line.startsWith('|')).join('\n').replace(/\n{2,}/g, '\n'));
console.log(`Sybqa verdict: ${verdict} · PASS ${counts.PASS} · FAIL ${counts.FAIL} · BLOCKED ${counts.BLOCKED} · NEEDS_REVIEW ${counts.NEEDS_REVIEW} · NOT_RUN ${counts.NOT_RUN}`);
if (failOn !== 'never' && ['fail', 'error', 'timeout'].includes(verdict) || failOn === 'review' && verdict === 'review') process.exitCode = 1;
} catch (error) { console.error(`${env.GITHUB_ACTIONS ? '::error::' : 'Sybqa error: '}${String(error?.message ?? error).replace(/[\r\n]+/g, ' ')}`); process.exitCode = 1; }
}
await sybqaRunner();
NODE
- store_test_results:
path: test-results
workflows:
sybqa:
jobs:
- sybqa
Any CI can call the same API with the same token. Start a run with POST /api/runs and the exported plan, then poll GET /api/runs/<id> until the status is completed, blocked, failed or cancelled. The result field is pass, issues or incomplete. This POSIX shell script does that with curl and jq.
sybqa.sh#!/bin/sh
# Sybqa website QA from any CI or terminal. Needs curl and jq. Set SYBQA_API_TOKEN as a secret.
set -eu
SYBQA_URL="${SYBQA_URL:-https://app.sybqa.com}"
# As in the Node runner, trailing slashes go: https://host/ would send //api/runs, which no server route answers.
while :; do case "$SYBQA_URL" in */) SYBQA_URL=${SYBQA_URL%/} ;; *) break ;; esac; done
SYBQA_PLAN="${SYBQA_PLAN:-.sybqa/plan.json}"
SYBQA_FAIL_ON="${SYBQA_FAIL_ON:-fail}"
SYBQA_TARGET_URL="${SYBQA_TARGET_URL:-}"
# As in the Node runner: no user name or password, and the token travels only over HTTPS or over plain HTTP to
# this machine. The host is everything before the first slash, so http://localhost:@evil.test is refused.
sybqa_authority=${SYBQA_URL#*://}; sybqa_authority=${sybqa_authority%%/*}
case "$sybqa_authority" in *@*) echo "SYBQA_URL must not contain a user name or password." >&2; exit 1 ;; esac
sybqa_host=${sybqa_authority%%[?#]*}
case "$sybqa_host" in *:[0-9]|*:[0-9][0-9]|*:[0-9][0-9][0-9]|*:[0-9][0-9][0-9][0-9]|*:[0-9][0-9][0-9][0-9][0-9]) sybqa_host=${sybqa_host%:*} ;; esac
case "$SYBQA_URL" in https://*) ;; http://*) case "$sybqa_host" in localhost|127.0.0.1|\[::1\]) ;; *) echo "SYBQA_URL must use HTTPS except on loopback." >&2; exit 1 ;; esac ;; *) echo "SYBQA_URL must use HTTPS except on loopback." >&2; exit 1 ;; esac
case "$SYBQA_FAIL_ON" in fail|review|never) ;; *) echo "SYBQA_FAIL_ON must be fail, review or never." >&2; exit 1 ;; esac
case "${SYBQA_API_TOKEN:-}" in sybqa_*) ;; *) echo "SYBQA_API_TOKEN is missing or invalid." >&2; exit 1 ;; esac
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
printf 'authorization: Bearer %s\n' "$SYBQA_API_TOKEN" > "$work/auth"
jq -c --arg target "$SYBQA_TARGET_URL" '
(if (.plan | type) == "object" then .plan else . end) as $plan
| if ($plan.profile | type) == "object"
then {plan: ($plan | if $target != "" then .target = $target | .profile.target = $target else . end)}
else {profile: ($plan | if $target != "" then .target = $target else . end)} end' "$SYBQA_PLAN" > "$work/body"
deadline=$(( $(date +%s) + 1800 ))
while :; do
status=$(curl -sS -o "$work/run" -w '%{http_code}' -X POST -H @"$work/auth" -H 'content-type: application/json' -H 'accept: application/json' --data-binary @"$work/body" "$SYBQA_URL/api/runs")
if [ "$status" = 429 ] && [ "$(jq -r '.code // ""' "$work/run")" != token_rate_limited ] && [ $(( $(date +%s) + 30 )) -lt "$deadline" ]; then echo "Sybqa run queue is full; retrying in 30 seconds."; sleep 30; continue; fi
[ "$status" -ge 200 ] && [ "$status" -lt 300 ] || { echo "Sybqa refused to start the run ($status): $(jq -r '.error // "no details"' "$work/run")" >&2; exit 1; }
break
done
run_id=$(jq -r '.id // ""' "$work/run")
case "$run_id" in run-*) ;; *) echo "Sybqa did not return a run id." >&2; exit 1 ;; esac
verdict=""
while :; do
case "$(jq -r '.status' "$work/run")" in completed|blocked|failed|cancelled) break ;; esac
if [ "$(date +%s)" -ge "$deadline" ]; then verdict=timeout; break; fi
sleep 10
status=$(curl -sS -o "$work/next" -w '%{http_code}' -H @"$work/auth" -H 'accept: application/json' "$SYBQA_URL/api/runs/$run_id" || echo 000)
if [ "$status" = 200 ]; then mv "$work/next" "$work/run"; elif [ "$status" = 401 ] || [ "$status" = 404 ]; then echo "Sybqa stopped returning run $run_id ($status)." >&2; exit 1; fi
done
# The server's verdict, as in the Node runner: its result when the run has one. Advisory checks are outside
# it, and only a required check that did not pass keeps the run open.
if [ -z "$verdict" ]; then verdict=$(jq -r '
[.checks[]? | select((.advisory == true and .required == false) | not)] as $c
| if (.status == "failed" or .status == "cancelled") then "error"
elif ([$c[] | select(.status == "FAIL")] | length) > 0 or .result == "issues" then "fail"
elif .result == "pass" then "pass"
elif .result == "incomplete" or .status == "blocked" or ($c | length) == 0 or ([$c[] | select(.required != false and .status != "PASS")] | length) > 0 then "review"
else "pass" end' "$work/run"); fi
report=$(jq -r --arg base "$SYBQA_URL" '.reportPath // "" | if . == "" then "" else $base + . end' "$work/run")
echo "Sybqa verdict: $verdict · run $run_id"
[ -n "$report" ] && echo "Evidence report: $report"
case "$verdict" in fail|error|timeout) [ "$SYBQA_FAIL_ON" = never ] || exit 1 ;; review) [ "$SYBQA_FAIL_ON" = review ] && exit 1 ;; esac
exit 0
CI runs use the same plan as runs started in the console. The free plan includes monthly runs without AI review, and every run counts, including reruns. AI review is part of the paid Starter plan. See pricing for what counts as a run and the current numbers.
You need a plan before the workflow has anything to run. Create a free account, point Sybqa at your site, and download the plan.
Commit the plan, save the token as a secret, then add the workflow. GitLab CI, Bitbucket Pipelines, CircleCI and a shell script follow below.
New: every template has a Copy button. The code also stays on the page, so you can select it by hand.
SYBQA_FAIL_ON decides whether review results block a merge. The templates fail only on failed checks, errors and timeouts.