Don't start run stage if compile stage errored

This commit is contained in:
Omar Brikaa 2022-03-06 17:24:28 +02:00
parent 16e4f08dfa
commit 2262618c52
1 changed files with 26 additions and 17 deletions

View File

@ -230,6 +230,7 @@ class Job {
this.logger.debug('Compiling'); this.logger.debug('Compiling');
let compile; let compile;
let compile_errored = false;
if (this.runtime.compiled) { if (this.runtime.compiled) {
compile = await this.safe_call( compile = await this.safe_call(
@ -238,16 +239,20 @@ class Job {
this.timeouts.compile, this.timeouts.compile,
this.memory_limits.compile this.memory_limits.compile
); );
compile_errored = compile.code !== 0;
} }
this.logger.debug('Running'); let run;
if (!compile_errored) {
this.logger.debug('Running');
const run = await this.safe_call( run = await this.safe_call(
this.runtime.run, this.runtime.run,
[code_files[0].name, ...this.args], [code_files[0].name, ...this.args],
this.timeouts.run, this.timeouts.run,
this.memory_limits.run this.memory_limits.run
); );
}
this.state = job_states.EXECUTED; this.state = job_states.EXECUTED;
@ -273,6 +278,7 @@ class Job {
const code_files = this.files.filter(file => file.encoding == 'utf8'); const code_files = this.files.filter(file => file.encoding == 'utf8');
let compile_errored = false;
if (this.runtime.compiled) { if (this.runtime.compiled) {
eventBus.emit('stage', 'compile'); eventBus.emit('stage', 'compile');
const { error, code, signal } = await this.safe_call( const { error, code, signal } = await this.safe_call(
@ -284,19 +290,22 @@ class Job {
); );
eventBus.emit('exit', 'compile', { error, code, signal }); eventBus.emit('exit', 'compile', { error, code, signal });
compile_errored = code !== 0;
} }
this.logger.debug('Running'); if (!compile_errored) {
eventBus.emit('stage', 'run'); this.logger.debug('Running');
const { error, code, signal } = await this.safe_call( eventBus.emit('stage', 'run');
this.runtime.run, const { error, code, signal } = await this.safe_call(
[code_files[0].name, ...this.args], this.runtime.run,
this.timeouts.run, [code_files[0].name, ...this.args],
this.memory_limits.run, this.timeouts.run,
eventBus this.memory_limits.run,
); eventBus
);
eventBus.emit('exit', 'run', { error, code, signal }); eventBus.emit('exit', 'run', { error, code, signal });
}
this.state = job_states.EXECUTED; this.state = job_states.EXECUTED;
} }