Skip to content

Commit

Permalink
Merge pull request #712 from 2i2c-org/cond_redirect_output
Browse files Browse the repository at this point in the history
Redirect test output when we are running on the CI
  • Loading branch information
damianavila authored Sep 28, 2021
2 parents e96e7bc + 14c4529 commit 2e4ee15
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions deployer/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,22 @@ def deploy(self, auth_provider, secret_key, skip_hub_health_test=False):
# This can contain sensitive info - so we hide stderr
# FIXME: Don't use pytest - just call a function instead
print("Running hub health check...")
with open(os.devnull, 'w') as dn, redirect_stderr(dn), redirect_stdout(dn):
exit_code = pytest.main([
"-q",
"deployer/tests",
"--hub-url", hub_url,
"--api-token", service_api_token,
"--hub-type", self.spec['template']
])
# Show errors locally but redirect on CI
gh_ci = os.environ.get('CI', "false")
pytest_args = [
"-q",
"deployer/tests",
"--hub-url", hub_url,
"--api-token", service_api_token,
"--hub-type", self.spec['template']
]
if gh_ci == "true":
print("Testing on CI, not printing output")
with open(os.devnull, 'w') as dn, redirect_stderr(dn), redirect_stdout(dn):
exit_code = pytest.main(pytest_args)
else:
print("Testing locally, do not redirect output")
exit_code = pytest.main(pytest_args)
if exit_code != 0:
print("Health check failed!", file=sys.stderr)
sys.exit(exit_code)
Expand Down

0 comments on commit 2e4ee15

Please sign in to comment.