Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect test output when we are running on the CI #712

Merged
merged 4 commits into from
Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions deployer/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,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