Skip to content

Commit

Permalink
A better docketr file structure (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored May 25, 2024
1 parent 43eb02a commit 6735b77
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions testrunner/src/testrunners/docker-testrunner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { writeFile, readFile, mkdir, rm } from 'node:fs/promises';
import path from 'node:path';
// import os from 'node:os';
import os from 'node:os';

import { execa } from 'execa';
import log from 'intel';
Expand All @@ -18,11 +18,15 @@ export default async function runJob(job) {
let workingDirectory;
try {
logger.info('Start with job');
const baseWorkingDirectory = './'; // nconf.get('workingDirectory') || os.tmpdir();
const baseWorkingDirectory = os.tmpdir();
const dockerContainer = nconf.get('docker:container');

workingDirectory = join(baseWorkingDirectory, job.queue.name, job.id);

const insideDockerDirectory = join(
'/sitespeed.io/',
job.queue.name,
job.id
);
await mkdir(workingDirectory, { recursive: true });
const configFileName = `${job.queue.name}-${job.id}-config.json`;
const resultFileName = `${job.queue.name}-${job.id}-result.json`;
Expand All @@ -41,7 +45,8 @@ export default async function runJob(job) {
const parameters = setupDockerParameters(
job,
dockerContainer,
workingDirectory,
baseWorkingDirectory,
insideDockerDirectory,
configFileName,
resultFileName
);
Expand Down Expand Up @@ -131,20 +136,21 @@ async function handleScriptingFile(job, workingDirectory) {
function setupDockerParameters(
job,
dockerContainer,
workingDirectory,
baseWorkingDirectory,
insideDockerDirectory,
configFileName,
resultFileName
) {
const baseParameters = [
'run',
'--rm',
'--volume',
`${process.cwd()}:/sitespeed.io`,
`${baseWorkingDirectory}:/sitespeed.io`,
dockerContainer,
'--config',
join(workingDirectory, configFileName),
join(insideDockerDirectory, configFileName),
'--storeResult',
join(workingDirectory, resultFileName)
join(insideDockerDirectory, resultFileName)
];

if (job.data.config.webpagereplay) {
Expand Down

0 comments on commit 6735b77

Please sign in to comment.