release: validate 1.2.0 packages and real model Git delivery on the live host
This commit is contained in:
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { randomUUID, createHash } from 'node:crypto';
|
||||
import { spawn } from 'node:child_process';
|
||||
import net from 'node:net';
|
||||
|
||||
const release = JSON.parse(fs.readFileSync('releases/latest.json', 'utf8'));
|
||||
const appRoot = release.portableRoot;
|
||||
@@ -16,14 +17,18 @@ for (const file of manifest.files) {
|
||||
}
|
||||
const data = path.resolve('.qa', 'release-' + randomUUID());
|
||||
fs.mkdirSync(data, { recursive: true });
|
||||
const env = { ...process.env, AGENT_WORKBENCH_DATA_DIR: data, AGENT_WORKBENCH_PORT: '4320' };
|
||||
const portProbe = net.createServer();
|
||||
await new Promise((resolve, reject) => { portProbe.once('error', reject); portProbe.listen(0, '127.0.0.1', resolve); });
|
||||
const port = portProbe.address().port;
|
||||
await new Promise(resolve => portProbe.close(resolve));
|
||||
const env = { ...process.env, AGENT_WORKBENCH_DATA_DIR: data, AGENT_WORKBENCH_PORT: String(port) };
|
||||
delete env.AGENT_WORKBENCH_API_KEY;
|
||||
for (const name of Object.keys(env)) if (name.toLowerCase() === 'path') delete env[name];
|
||||
const windowsRoot = process.env.SystemRoot || 'C:\\Windows';
|
||||
env.PATH = [windowsRoot, path.join(windowsRoot, 'System32'), path.join(windowsRoot, 'System32', 'WindowsPowerShell', 'v1.0')].join(path.delimiter);
|
||||
function runPowerShell(script, extra = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', path.join(appRoot, 'scripts', script), '-Port', '4320', ...extra], { windowsHide: true, env, stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
const child = spawn('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', path.join(appRoot, 'scripts', script), '-Port', String(port), ...extra], { windowsHide: true, env, stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
let output = '', errors = '';
|
||||
child.stdout.on('data', bytes => { output += bytes.toString('utf8'); });
|
||||
child.stderr.on('data', bytes => { errors += bytes.toString('utf8'); });
|
||||
@@ -39,7 +44,7 @@ function runPowerShell(script, extra = []) {
|
||||
}
|
||||
const launch = () => runPowerShell('Start-Workbench.ps1', ['-NoBrowser']);
|
||||
const stop = () => runPowerShell('Stop-Workbench.ps1');
|
||||
const url = 'http://127.0.0.1:4320';
|
||||
const url = 'http://127.0.0.1:' + port;
|
||||
const until = async predicate => {
|
||||
const deadline = Date.now() + 10000;
|
||||
while (!(await predicate())) {
|
||||
@@ -49,7 +54,12 @@ const until = async predicate => {
|
||||
};
|
||||
let started = false;
|
||||
try {
|
||||
console.log((await launch()).trim()); started = true;
|
||||
console.log((await launch()).trim());
|
||||
const firstInfo = JSON.parse(fs.readFileSync(path.join(data, 'service-info.json'), 'utf8'));
|
||||
assert.equal(path.resolve(firstInfo.appRoot), path.resolve(appRoot));
|
||||
const health = await (await fetch(url + '/api/health')).json();
|
||||
assert.equal(health.pid, firstInfo.pid, 'The test must own the launched service.');
|
||||
started = true;
|
||||
const bootstrap = await (await fetch(url + '/api/bootstrap')).json();
|
||||
const api = async (route, input) => {
|
||||
const response = await fetch(url + '/api' + route, { method: input === undefined ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token },
|
||||
@@ -57,7 +67,6 @@ try {
|
||||
const result = await response.json(); assert.ok(response.ok, result.error); return result;
|
||||
};
|
||||
assert.equal(bootstrap.version, manifest.version); assert.equal(bootstrap.config.mode, 'demo');
|
||||
const firstInfo = JSON.parse(fs.readFileSync(path.join(data, 'service-info.json'), 'utf8'));
|
||||
console.log((await launch()).trim());
|
||||
assert.equal(JSON.parse(fs.readFileSync(path.join(data, 'service-info.json'), 'utf8')).pid, firstInfo.pid);
|
||||
const example = bootstrap.projects.find(project => project.id === bootstrap.exampleProjectId);
|
||||
|
||||
Reference in New Issue
Block a user