mirror of
https://github.com/whyour/qinglong.git
synced 2026-11-30 16:27:21 +08:00
Return committed trigger IDs and add CLI wait and trigger-specific logs while preserving API, CLI, transaction, deduplication and unknown-result semantics. Move scheduling, lifecycle, settlement, queries and legacy adapters into back/cron; remove obsolete internal import paths and circular dependencies. Apply project formatting across the repository, cover CJS/MJS in formatting hooks, add prettier:check and require formatting checks in AGENTS.md. Validation: backend build; 1398 backend/frontend tests passed (17 platform skips); 327 CLI tests passed (6 platform skips); 670 files pass format checks.
111 lines
3.6 KiB
JavaScript
111 lines
3.6 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs/promises');
|
|
const path = require('node:path');
|
|
const os = require('node:os');
|
|
const { createHash } = require('node:crypto');
|
|
const { createContext } = require('../../dist/internal/runtime/context');
|
|
const operator = require('../../dist/internal/maintenance/operator');
|
|
const { stageUpgrade } = require('../../dist/internal/maintenance/upgrade');
|
|
const {
|
|
cancellableOperation,
|
|
} = require('../../dist/internal/runtime/cancellation');
|
|
|
|
test(
|
|
'published master archives pass actual HTTPS download and staging validation',
|
|
{
|
|
skip: process.env.QL_ARCHIVE_INTEGRATION !== '1',
|
|
timeout: 180000,
|
|
},
|
|
async (t) => {
|
|
const mirror = process.env.QL_ARCHIVE_MIRROR || 'github';
|
|
assert.ok(['github', 'gitee'].includes(mirror));
|
|
const root = await fs.mkdtemp(
|
|
path.join(os.tmpdir(), 'ql-published-archive-'),
|
|
);
|
|
t.after(() => fs.rm(root, { recursive: true, force: true }));
|
|
await fs.writeFile(
|
|
path.join(root, 'package.json'),
|
|
'{"name":"isolated-archive-gate"}',
|
|
);
|
|
const context = createContext(
|
|
{ root },
|
|
{ PATH: process.env.PATH, HOME: root, QL_BRANCH: 'master' },
|
|
);
|
|
const installations = [];
|
|
// This gate must not execute code from the downloaded source. Real dependency
|
|
// installation and retained-data upgrade are separate existing Linux gates.
|
|
t.mock.method(
|
|
operator,
|
|
'installPanelDependencies',
|
|
async (ctx, directory) => {
|
|
assert.equal(ctx.root, root);
|
|
assert.equal(
|
|
path.dirname(path.dirname(directory)),
|
|
context.paths.dir_tmp,
|
|
);
|
|
installations.push(directory);
|
|
await fs.mkdir(path.join(directory, 'node_modules'), {
|
|
recursive: true,
|
|
});
|
|
},
|
|
);
|
|
const controller = new AbortController();
|
|
const timer = setTimeout(() => controller.abort('SIGTERM'), 150000);
|
|
t.after(() => clearTimeout(timer));
|
|
const staged = await cancellableOperation(controller.signal, () =>
|
|
stageUpgrade(context, mirror),
|
|
);
|
|
assert.deepEqual(installations, [staged.source]);
|
|
const release = await fs.readFile(
|
|
path.join(staged.source, 'version.yaml'),
|
|
'utf8',
|
|
);
|
|
assert.match(
|
|
release,
|
|
/^version:\s*2\./m,
|
|
'Published branch must still be 2.x',
|
|
);
|
|
await fs.access(path.join(staged.static, 'build/app.js'));
|
|
const workspace = path.dirname(staged.source);
|
|
const pointer = JSON.parse(
|
|
await fs.readFile(
|
|
path.join(context.paths.dir_tmp, 'upgrade-ready-master.json'),
|
|
'utf8',
|
|
),
|
|
);
|
|
assert.equal(pointer.directory, path.basename(workspace));
|
|
const manifest = JSON.parse(
|
|
await fs.readFile(path.join(staged.static, 'build-info.json'), 'utf8'),
|
|
);
|
|
assert.deepEqual(
|
|
JSON.parse(await fs.readFile(path.join(workspace, 'ready.json'), 'utf8')),
|
|
{
|
|
...staged,
|
|
sourceCommit: manifest.sourceCommit,
|
|
dependenciesChanged: true,
|
|
},
|
|
);
|
|
assert.equal(
|
|
await fs.readFile(path.join(root, 'package.json'), 'utf8'),
|
|
'{"name":"isolated-archive-gate"}',
|
|
);
|
|
const archives = {};
|
|
for (const name of ['qinglong', 'qinglong-static']) {
|
|
const content = await fs.readFile(path.join(workspace, `${name}.zip`));
|
|
archives[name] = {
|
|
bytes: content.length,
|
|
sha256: createHash('sha256').update(content).digest('hex'),
|
|
};
|
|
}
|
|
t.diagnostic(
|
|
JSON.stringify({
|
|
mirror,
|
|
release: release.match(/^version:\s*(\S+)/m)?.[1],
|
|
archives,
|
|
downloadedCodeExecuted: false,
|
|
}),
|
|
);
|
|
},
|
|
);
|