Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Docker mapping. #27

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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