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

Use "staging" as the default when DIMAGIQA_ENV is not set #43

Merged
merged 3 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/python-app.yml
Expand Up @@ -39,8 +39,7 @@ jobs:
DIMAGIQA_LOGIN_USERNAME: ${{ secrets.DIMAGIQA_LOGIN_USERNAME }}
DIMAGIQA_LOGIN_PASSWORD: ${{ secrets.DIMAGIQA_LOGIN_PASSWORD }}
run: |
echo "component: ${{ github.event.client_payload.component }}"
echo "environment: ${{ github.event.client_payload.environment }}"
echo "client_payload: ${{ toJson(github.event.client_payload) }}"
pytest -v
- name: Archive test results
if: failure()
Expand Down
10 changes: 5 additions & 5 deletions HQSmokeTests/TestBase/environmentSetupPage.py
Expand Up @@ -63,9 +63,9 @@ def load_settings():
settings = load_settings_from_environment()
if any(x not in settings for x in ["url", "login_username", "login_password"]):
lines = load_settings_from_environment.__doc__.splitlines()
vars_ = [line.strip() for line in lines if "DIMAGIQA_" in line]
vars_ = "\n ".join(line.strip() for line in lines if "DIMAGIQA_" in line)
raise RuntimeError(
f"Environment variables not set:\n {chr(10).join(vars_)}\n\n"
f"Environment variables not set:\n {vars_}\n\n"
"See https://docs.github.com/en/actions/reference/encrypted-secrets "
"for instructions on how to set them."
)
Expand All @@ -86,8 +86,8 @@ def load_settings_from_environment():
"""Load settings from os.environ

Names of environment variables:
DIMAGIQA_URL - required unless DIMAGIQA_ENV is set
DIMAGIQA_ENV - required if DIMAGIQA_URL is not set
DIMAGIQA_URL - optional
DIMAGIQA_ENV - optional, used if DIMAGIQA_URL is not set. default: staging
DIMAGIQA_LOGIN_USERNAME - required
DIMAGIQA_LOGIN_PASSWORD - required

Expand All @@ -100,7 +100,7 @@ def load_settings_from_environment():
if var in os.environ:
settings[name] = os.environ[var]
if "url" not in settings:
env = os.environ["DIMAGIQA_ENV"]
env = os.environ["DIMAGIQA_ENV"] or "staging"
subdomain = "www" if env == "production" else env
settings["url"] = f"https://{subdomain}.commcarehq.org/"
return settings