release-check.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. const fs = require('fs');
  3. const os = require('os');
  4. const path = require('path');
  5. const { spawnSync } = require('child_process');
  6. const ROOT = path.resolve(__dirname, '..');
  7. const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'qiwei-release-check-'));
  8. const outputsDir = path.join(tempRoot, 'outputs');
  9. const npmCli = process.env.npm_execpath || path.join(path.dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js');
  10. const checks = [
  11. 'check',
  12. 'smoke',
  13. 'agent:smoke',
  14. 'library:smoke',
  15. 'excel:smoke',
  16. 'outputs:validate',
  17. 'install:check',
  18. 'package:smoke',
  19. 'audit:prod',
  20. ];
  21. try {
  22. for (const check of checks) {
  23. const result = spawnSync(process.execPath, [npmCli, 'run', check], {
  24. cwd: ROOT,
  25. env: {
  26. ...process.env,
  27. QIWEI_OUTPUTS_DIR: outputsDir,
  28. QIWEI_AGENT_DB_PATH: path.join(outputsDir, 'messages', 'agent-workbench.db'),
  29. },
  30. stdio: 'inherit',
  31. windowsHide: true,
  32. });
  33. if (result.error) throw result.error;
  34. if (result.status !== 0) process.exit(result.status || 1);
  35. }
  36. process.stdout.write(`\n发布检查通过:${checks.length} 组检查均已完成,测试输出已隔离。\n`);
  37. } finally {
  38. fs.rmSync(tempRoot, { recursive: true, force: true });
  39. }