Skip to content

Commit

Permalink
Merge pull request natcap#1474 from davemfish/bugfix/GHA-1468-autotes…
Browse files Browse the repository at this point in the history
…t-fail

force autotest script to exit with code 1 if any models failed.
  • Loading branch information
dcdenu4 authored Dec 12, 2023
2 parents 8f8db4e + 33a8719 commit b04239a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ jobs:
run: make CONDA="$MAMBA_EXE" binaries

- name: Run invest-autotest with binaries
continue-on-error: true
if : |
github.event_name == 'push' &&
(contains(github.ref, 'release') || github.ref == 'refs/heads/main')
Expand Down
4 changes: 3 additions & 1 deletion scripts/invest-autotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run_model(modelname, binary, workspace, datastack):
binary = binary.replace('/', '\\')
# Using a list here allows subprocess to handle escaping of paths.
command = [binary, 'run', '--workspace', workspace,
'--datastack', datastack, '--headless', modelname]
'--datastack', datastack, modelname]

# Subprocess on linux/mac seems to prefer a list of args, but path escaping
# (by passing the command as a list) seems to work better on Windows.
Expand Down Expand Up @@ -201,6 +201,8 @@ def main(user_args=None):
print(status_messages)
with open(os.path.join(args.workspace, 'model_results.txt'), 'w') as log:
log.write(status_messages)
if failures > 0:
parser.exit(1, 'invest autotest failed')


if __name__ == '__main__':
Expand Down

0 comments on commit b04239a

Please sign in to comment.