Merge pull request #457 from Brikaa/dont-run-if-compile-error
Piston-Nix: Don't start run stage if compile stage errored
This commit is contained in:
commit
46ab4a4ba4
|
@ -264,7 +264,11 @@ router.post('/execute', async (req, res) => {
|
|||
|
||||
await job.prime();
|
||||
|
||||
const result = await job.execute();
|
||||
let result = await job.execute();
|
||||
// Backward compatibility when the run stage is not started
|
||||
if (result.run === undefined) {
|
||||
result.run = result.compile;
|
||||
}
|
||||
|
||||
await job.cleanup();
|
||||
|
||||
|
|
|
@ -234,6 +234,7 @@ class Job {
|
|||
this.logger.debug('Compiling');
|
||||
|
||||
let compile;
|
||||
let compile_errored = false;
|
||||
|
||||
if (this.runtime.compiled) {
|
||||
compile = await this.safe_call(
|
||||
|
@ -242,16 +243,20 @@ class Job {
|
|||
this.timeouts.compile,
|
||||
this.memory_limits.compile
|
||||
);
|
||||
compile_errored = compile.code !== 0;
|
||||
}
|
||||
|
||||
let run;
|
||||
if (!compile_errored) {
|
||||
this.logger.debug('Running');
|
||||
|
||||
const run = await this.safe_call(
|
||||
run = await this.safe_call(
|
||||
this.runtime.run,
|
||||
[code_files[0].name, ...this.args],
|
||||
this.timeouts.run,
|
||||
this.memory_limits.run
|
||||
);
|
||||
}
|
||||
|
||||
this.state = job_states.EXECUTED;
|
||||
|
||||
|
@ -277,6 +282,7 @@ class Job {
|
|||
|
||||
const code_files = this.files.filter(file => file.encoding == 'utf8');
|
||||
|
||||
let compile_errored = false;
|
||||
if (this.runtime.compiled) {
|
||||
eventBus.emit('stage', 'compile');
|
||||
const { error, code, signal } = await this.safe_call(
|
||||
|
@ -288,8 +294,10 @@ class Job {
|
|||
);
|
||||
|
||||
eventBus.emit('exit', 'compile', { error, code, signal });
|
||||
compile_errored = code !== 0;
|
||||
}
|
||||
|
||||
if (!compile_errored) {
|
||||
this.logger.debug('Running');
|
||||
eventBus.emit('stage', 'run');
|
||||
const { error, code, signal } = await this.safe_call(
|
||||
|
@ -301,6 +309,7 @@ class Job {
|
|||
);
|
||||
|
||||
eventBus.emit('exit', 'run', { error, code, signal });
|
||||
}
|
||||
|
||||
this.state = job_states.EXECUTED;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue