Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
sentrivana committed Jun 20, 2023
1 parent 260776e commit da019c0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test-integration-django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
SENTRY_PYTHON_TEST_POSTGRES_USER: postgres
SENTRY_PYTHON_TEST_POSTGRES_PASSWORD: sentry
SENTRY_PYTHON_TEST_POSTGRES_NAME: ci_test
SENTRY_PYTHON_TEST_POSTGRES_HOST: localhost

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -110,6 +111,7 @@ jobs:
SENTRY_PYTHON_TEST_POSTGRES_USER: postgres
SENTRY_PYTHON_TEST_POSTGRES_PASSWORD: sentry
SENTRY_PYTHON_TEST_POSTGRES_NAME: ci_test
SENTRY_PYTHON_TEST_POSTGRES_HOST: postgres

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions scripts/split-tox-gh-actions/ci-yaml-services.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
SENTRY_PYTHON_TEST_POSTGRES_USER: postgres
SENTRY_PYTHON_TEST_POSTGRES_PASSWORD: sentry
SENTRY_PYTHON_TEST_POSTGRES_NAME: ci_test
SENTRY_PYTHON_TEST_POSTGRES_HOST: {{ postgres_host }}
21 changes: 18 additions & 3 deletions scripts/split-tox-gh-actions/split-tox-gh-actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,25 @@ def write_yaml_file(
py27_supported = "2.7" in py_versions

test_loc = template.index("{{ test }}\n")
test_snippet = open(TEMPLATE_SNIPPET_TEST, "r").readlines()
f = open(TEMPLATE_SNIPPET_TEST, "r")
test_snippet = f.readlines()
template = template[:test_loc] + test_snippet + template[test_loc + 1 :]
f.close()

test_py27_loc = template.index("{{ test_py27 }}\n")
if py27_supported:
test_py27_snippet = open(TEMPLATE_SNIPPET_TEST_PY27, "r").readlines()
f = open(TEMPLATE_SNIPPET_TEST_PY27, "r")
test_py27_snippet = f.readlines()
template = (
template[:test_py27_loc] + test_py27_snippet + template[test_py27_loc + 1 :]
)
f.close()

py_versions.remove("2.7")
else:
template.pop(test_py27_loc)

py27_test_part = False
for template_line in template:
if template_line.strip() == "{{ strategy_matrix }}":
m = MATRIX_DEFINITION
Expand All @@ -97,7 +102,14 @@ def write_yaml_file(
elif template_line.strip() == "{{ services }}":
if current_framework in FRAMEWORKS_NEEDING_POSTGRES:
f = open(TEMPLATE_FILE_SERVICES, "r")
out += "".join(f.readlines())
lines = [
line.replace(
"{{ postgres_host }}",
"postgres" if py27_test_part else "localhost",
)
for line in f.readlines()
]
out += "".join(lines)
f.close()

elif template_line.strip() == "{{ check_needs }}":
Expand All @@ -111,6 +123,9 @@ def write_yaml_file(
out += CHECK_PY27

else:
if template_line.strip() == "test-py27:":
py27_test_part = True

out += template_line.replace("{{ framework }}", current_framework)

# write rendered template
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/django/myapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def middleware(request):
"NAME": os.environ["SENTRY_PYTHON_TEST_POSTGRES_NAME"],
"USER": os.environ["SENTRY_PYTHON_TEST_POSTGRES_USER"],
"PASSWORD": os.environ["SENTRY_PYTHON_TEST_POSTGRES_PASSWORD"],
"HOST": "postgres",
"HOST": os.environ.get("SENTRY_PYTHON_TEST_POSTGRES_HOST", "localhost"),
"PORT": 5432,
}
except (ImportError, KeyError):
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ passenv =
SENTRY_PYTHON_TEST_POSTGRES_USER
SENTRY_PYTHON_TEST_POSTGRES_PASSWORD
SENTRY_PYTHON_TEST_POSTGRES_NAME
SENTRY_PYTHON_TEST_POSTGRES_HOST
usedevelop = True
extras =
bottle: bottle
Expand Down

0 comments on commit da019c0

Please sign in to comment.