Benchmark: pytest ajetaan Docker-kontissa (kipina-pytest)
Kontti hoitaa uv init + uv add + pytest eristetyssä ympäristössä. Python 3.14, ei VIRTUAL_ENV-ongelmia, täysi toistettavuus. Image: docker build -t kipina-pytest -f tests/Dockerfile.pytest tests/
This commit is contained in:
5
network-poc/tests/Dockerfile.pytest
Normal file
5
network-poc/tests/Dockerfile.pytest
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM python:3.14-slim
|
||||||
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
|
||||||
|
WORKDIR /work
|
||||||
|
ENV PYTHONPATH=/work
|
||||||
|
ENTRYPOINT ["sh", "-c", "uv init --no-readme --python '>=3.14' 2>/dev/null && rm -f hello.py main.py && uv add fastapi 'uvicorn[standard]' sqlalchemy pytest httpx 2>/dev/null && cp /src/*.py . && rm -f app.db test.db && uv run pytest test_main.py -v --tb=short 2>&1"]
|
||||||
@@ -335,20 +335,18 @@ async function runPipeline(model, scenario) {
|
|||||||
result.validationIssues = issues.length;
|
result.validationIssues = issues.length;
|
||||||
result.fixRounds = fixRound;
|
result.fixRounds = fixRound;
|
||||||
|
|
||||||
// 5. Projektin alustus (uv init) + kirjoita tiedostot + pytest
|
// Kirjoita LLM:n generoimat Python-tiedostot
|
||||||
console.log(` [5/5] Pytest...`);
|
|
||||||
try {
|
|
||||||
const uvPath = process.env.HOME + '/.local/bin/uv';
|
|
||||||
const uv = existsSync(uvPath) ? uvPath : 'uv';
|
|
||||||
execSync(`cd "${dir}" && ${uv} init --no-readme --python ">=3.14" 2>/dev/null && rm -f hello.py main.py`, { timeout: 30000, stdio: 'pipe' });
|
|
||||||
execSync(`cd "${dir}" && ${uv} add fastapi "uvicorn[standard]" sqlalchemy pytest httpx 2>/dev/null`, { timeout: 60000, stdio: 'pipe' });
|
|
||||||
|
|
||||||
// Kirjoita LLM:n generoimat Python-tiedostot (uv initin jälkeen)
|
|
||||||
for (const [fn, content] of Object.entries(files)) {
|
for (const [fn, content] of Object.entries(files)) {
|
||||||
if (fn.endsWith('.py')) writeFileSync(`${dir}/${fn}`, content);
|
if (fn.endsWith('.py')) writeFileSync(`${dir}/${fn}`, content);
|
||||||
}
|
}
|
||||||
execSync(`cd "${dir}" && rm -f app.db test.db`, { stdio: 'pipe' });
|
|
||||||
const pytestOut = execSync(`cd "${dir}" && ${uv} run pytest test_main.py -v --tb=short 2>&1`, { timeout: 60000, encoding: 'utf-8' });
|
// 5. Pytest Docker-kontissa (kipina-pytest image)
|
||||||
|
console.log(` [5/5] Pytest (Docker)...`);
|
||||||
|
try {
|
||||||
|
const pytestOut = execSync(
|
||||||
|
`docker run --rm -v "${dir}:/src:ro" kipina-pytest 2>&1`,
|
||||||
|
{ timeout: 120000, encoding: 'utf-8' }
|
||||||
|
);
|
||||||
writeFileSync(`${dir}/_pytest.txt`, pytestOut);
|
writeFileSync(`${dir}/_pytest.txt`, pytestOut);
|
||||||
|
|
||||||
const passedMatch = pytestOut.match(/(\d+) passed/);
|
const passedMatch = pytestOut.match(/(\d+) passed/);
|
||||||
|
|||||||
Reference in New Issue
Block a user