Skip to content

Commit

Permalink
Simplify Docker mapping.
Browse files Browse the repository at this point in the history
This fixes how script files are mapped.
  • Loading branch information
soulgalore committed Jun 20, 2024
1 parent 88c6963 commit e4c790f
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions testrunner/src/testrunners/docker-testrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ export default async function runJob(job) {
);

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 @@ -56,8 +51,7 @@ export default async function runJob(job) {
job,
dockerContainer,
dockerExtraParameters,
baseWorkingDirectory,
insideDockerDirectory,
workingDirectory,
configFileName,
resultFileName
);
Expand Down Expand Up @@ -123,7 +117,11 @@ export default async function runJob(job) {
logger.error('Failed to execute job: %s', error.message, job.data.url);
job.log('Job failed:' + error.message);
if (workingDirectory) {
await cleanupWorkingDirectory(workingDirectory, logger);
try {
await cleanupWorkingDirectory(workingDirectory, logger);
} catch {
/* no worries */
}
}
throw error;
}
Expand All @@ -138,32 +136,31 @@ async function handleScriptingFile(job, workingDirectory) {
: `export default async function (context, commands) {${job.data.scripting}}`;
const filename = join(
workingDirectory,
(job.data.scriptingName || job.id) + scriptExtension
job.data.scriptingName || job.id + scriptExtension
);
await writeFile(filename, scriptContent);
return filename;
return job.data.scriptingName || job.id + scriptExtension;
}

function setupDockerParameters(
job,
dockerContainer,
dockerExtraParameters,
baseWorkingDirectory,
insideDockerDirectory,
workingDirectory,
configFileName,
resultFileName
) {
const baseParameters = [
'run',
'--rm',
'--volume',
`${baseWorkingDirectory}:/sitespeed.io`,
`${workingDirectory}:/sitespeed.io`,
...dockerExtraParameters,
dockerContainer,
'--config',
join(insideDockerDirectory, configFileName),
join('/sitespeed.io', configFileName),
'--storeResult',
join(insideDockerDirectory, resultFileName),
join('/sitespeed.io', resultFileName),
'--disableAPI',
true
];
Expand Down

0 comments on commit e4c790f

Please sign in to comment.