testien nopeutus
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 27s
acc-tests Cucumber test report
CI Feature / Cucumber tests (push) Failing after 51s
unit-tests Bats test report
CI Feature / Bats tests (push) Failing after 1m32s
CI Feature / Report Summary (push) Successful in 5s

This commit is contained in:
moilanik
2026-06-20 13:44:36 +03:00
parent a039e6637e
commit cd6ff8830c
4 changed files with 31 additions and 38 deletions
@@ -21,9 +21,15 @@ function bash(cmd) {
}
}
function getFreePort() {
const out = execSync(`python3 -c "import socket; s=socket.socket(); s.bind(('',0)); print(s.getsockname()[1]); s.close()"`, { encoding: 'utf-8' });
return parseInt(out.trim(), 10);
}
function setupMock(seqJson) {
execSync('lsof -ti :18080 2>/dev/null | xargs -r kill -9 2>/dev/null || true', { stdio: 'ignore' });
execSync('sleep 0.4', { stdio: 'ignore' });
const port = getFreePort();
process.env.MOCK_PORT = String(port);
process.env.GITEA_API_URL = `http://localhost:${port}`;
const seqFile = path.join(os.tmpdir(), `cucumber_seq_${Date.now()}.json`);
fs.writeFileSync(seqFile, seqJson);
@@ -34,17 +40,16 @@ function setupMock(seqJson) {
const configFile = path.join(os.tmpdir(), `cucumber_cfg_${Date.now()}.txt`);
fs.writeFileSync(configFile, `SEQUENCE\n${seqJson}\n${idxFile}`);
const proc = spawn('python3', [MOCK_SERVER, '18080', configFile, reqFile], {
const proc = spawn('python3', [MOCK_SERVER, String(port), configFile, reqFile], {
cwd: PROJECT_ROOT,
detached: true,
stdio: 'ignore',
});
proc.unref();
this._mockProc = proc;
for (let i = 0; i < 20; i++) {
try {
execSync('curl -s --max-time 1 http://localhost:18080/', { stdio: 'ignore' });
execSync(`nc -z localhost ${port}`, { stdio: 'ignore' });
fs.writeFileSync(idxFile, '0');
return;
} catch (_) {}
@@ -69,7 +74,8 @@ When('a test workflow is dispatched to a test project', function () {
{ code: 200, body: { workflow_runs: [{ id: 1, status: 'running' }] } },
{ code: 200, body: { id: 1, status: 'completed', conclusion: 'success' } },
]));
const r = runDispatch('"test-owner/test-repo" "test.yml" "main" \'{"version":"1.2.3"}\' "http://localhost:18080" "test-token-abc123"');
const url = process.env.GITEA_API_URL;
const r = runDispatch(`"test-owner/test-repo" "test.yml" "main" '{"version":"1.2.3"}' "${url}" "test-token-abc123"`);
this.dispatchResult = r.status;
});
@@ -87,7 +93,8 @@ When('a test workflow is dispatched and the tests fail', function () {
{ code: 200, body: { workflow_runs: [{ id: 1, status: 'running' }] } },
{ code: 200, body: { id: 1, status: 'completed', conclusion: 'failure' } },
]));
const r = runDispatch('"test-owner/test-repo" "test.yml" "main" \'{"version":"1.2.3"}\' "http://localhost:18080" "test-token-abc123"');
const url = process.env.GITEA_API_URL;
const r = runDispatch(`"test-owner/test-repo" "test.yml" "main" '{"version":"1.2.3"}' "${url}" "test-token-abc123"`);
this.dispatchResult = r.status;
});
@@ -103,7 +110,8 @@ When('a test workflow is dispatched but does not finish within the allowed time'
{ code: 200, body: { id: 1, status: 'running' } },
{ code: 200, body: { id: 1, status: 'running' } },
]));
const r = runDispatch('"test-owner/test-repo" "test.yml" "main" \'{"version":"1.2.3"}\' "http://localhost:18080" "test-token-abc123" "0.001"');
const url = process.env.GITEA_API_URL;
const r = runDispatch(`"test-owner/test-repo" "test.yml" "main" '{"version":"1.2.3"}' "${url}" "test-token-abc123" "0.001"`);
this.dispatchResult = r.status;
});