Skip to content

Commit

Permalink
test with timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Jan 23, 2024
1 parent 92398b0 commit 9e7124d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci_run_pubsub_electron_cfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"data": "is_ci"
}
],
"node_cmd": "npm start"
"node_cmd": "npm start",
"timeout": 300
}
15 changes: 9 additions & 6 deletions utils/run_in_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ def launch_runnable():
exit_code = 0

print("Launching runnable...")
runable_timeout = None
if ('timeout' in config_json):
runable_timeout = config_json['timeout']

try:
# Java
Expand Down Expand Up @@ -282,15 +285,15 @@ def launch_runnable():
# C++
elif (config_json['language'] == "CPP"):
runnable_return = subprocess.run(
args=config_json_arguments_list, executable=config_json['runnable_file'])
args=config_json_arguments_list, executable=config_json['runnable_file'], timeout=runable_timeout)
exit_code = runnable_return.returncode

elif (config_json['language'] == "Python"):
config_json_arguments_list.append("--is_ci")
config_json_arguments_list.append("True")

runnable_return = subprocess.run(
args=[sys.executable, config_json['runnable_file']] + config_json_arguments_list)
args=[sys.executable, config_json['runnable_file']] + config_json_arguments_list, timeout=runable_timeout)
exit_code = runnable_return.returncode

elif (config_json['language'] == "Javascript"):
Expand All @@ -301,9 +304,9 @@ def launch_runnable():

runnable_return_one = None
if sys.platform == "win32" or sys.platform == "cygwin":
runnable_return_one = subprocess.run(args=["npm", "install"], shell=True)
runnable_return_one = subprocess.run(args=["npm", "install"], shell=True, timeout=runable_timeout)
else:
runnable_return_one = subprocess.run(args=["npm", "install"])
runnable_return_one = subprocess.run(args=["npm", "install"], timeout=runable_timeout)

if (runnable_return_one == None or runnable_return_one.returncode != 0):
exit_code = runnable_return_one.returncode
Expand All @@ -317,10 +320,10 @@ def launch_runnable():

if sys.platform == "win32" or sys.platform == "cygwin":
runnable_return_two = subprocess.run(
args=arguments + config_json_arguments_list, shell=True, check=True)
args=arguments + config_json_arguments_list, shell=True, check=True, timeout=runable_timeout)
else:
runnable_return_two = subprocess.run(
args=arguments + config_json_arguments_list)
args=arguments + config_json_arguments_list, timeout=runable_timeout)

if (runnable_return_two != None):
exit_code = runnable_return_two.returncode
Expand Down

0 comments on commit 9e7124d

Please sign in to comment.