From 90811878067876f3aa414e25e7a195723f5f6443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Aleksi=C4=87?= Date: Tue, 1 Aug 2023 10:28:11 +0200 Subject: [PATCH] CI/CD problem analysis (#1919) --- .github/workflows/pr.workflow.yml | 8 ++++---- dev-requirements.in | 2 +- dev-requirements.txt | 20 +++++++++++++------ .../core/tests/helpers/data_source_fixture.py | 7 ++++++- .../tests/postgres_data_source_fixture.py | 5 ++--- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr.workflow.yml b/.github/workflows/pr.workflow.yml index 0db5c787f..9a0e950fc 100644 --- a/.github/workflows/pr.workflow.yml +++ b/.github/workflows/pr.workflow.yml @@ -84,8 +84,8 @@ jobs: - name: Test with tox run: | - tox -- soda -k soda/core - tox -- soda -k soda/${{ matrix.data-source }} + tox --exit-and-dump-after 3600 -- soda -k soda/core + tox --exit-and-dump-after 3600 -- soda -k soda/${{ matrix.data-source }} env: test_data_source: ${{ matrix.data-source }} @@ -116,7 +116,7 @@ jobs: - name: Test with tox run: | - tox -- soda -k soda/core + tox --exit-and-dump-after 3600 -- soda -k soda/core env: test_data_source: postgres WESTMALLE: BETTER_THAN_LA_TRAPPE @@ -148,4 +148,4 @@ jobs: - name: Test with tox run: | - tox -- soda -k soda/scientific + tox --exit-and-dump-after 3600 -- soda -k soda/scientific diff --git a/dev-requirements.in b/dev-requirements.in index faf693193..b46d5c651 100644 --- a/dev-requirements.in +++ b/dev-requirements.in @@ -1,7 +1,7 @@ pip-tools~=6.5 pytest~=7.0 python-dotenv~=1.0 -tox~=3.24 +tox~=4.6 tox-docker~=4.1 pytest-html~=3.1 pytest-cov~=3.0 diff --git a/dev-requirements.txt b/dev-requirements.txt index 9ae65d466..6556fe7fd 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -10,10 +10,14 @@ bleach==6.0.0 # via readme-renderer build==0.10.0 # via pip-tools +cachetools==5.3.1 + # via tox certifi==2023.5.7 # via # -r dev-requirements.in # requests +chardet==5.1.0 + # via tox charset-normalizer==3.2.0 # via requests cli-ui==0.17.2 @@ -23,7 +27,9 @@ click==8.1.5 # black # pip-tools colorama==0.4.6 - # via cli-ui + # via + # cli-ui + # tox contextlib2==21.6.0 # via schema coverage[toml]==7.2.7 @@ -53,6 +59,7 @@ mypy-extensions==1.0.0 packaging==23.1 # via # build + # pyproject-api # pytest # tox # tox-docker @@ -63,19 +70,20 @@ pip-tools==6.14.0 platformdirs==3.8.1 # via # black + # tox # virtualenv pluggy==1.2.0 # via # pytest # tox py==1.11.0 - # via - # pytest-html - # tox + # via pytest-html pygments==2.15.1 # via # -r dev-requirements.in # readme-renderer +pyproject-api==1.5.3 + # via tox pyproject-hooks==1.0.0 # via build pytest==7.4.0 @@ -104,7 +112,6 @@ six==1.16.0 # via # bleach # python-dateutil - # tox tabulate==0.8.10 # via cli-ui tbump==6.10.0 @@ -115,12 +122,13 @@ tomli==2.0.1 # build # coverage # pip-tools + # pyproject-api # pyproject-hooks # pytest # tox tomlkit==0.11.8 # via tbump -tox==3.28.0 +tox==4.6.4 # via # -r dev-requirements.in # tox-docker diff --git a/soda/core/tests/helpers/data_source_fixture.py b/soda/core/tests/helpers/data_source_fixture.py index 92f99c9c4..08170f5c4 100644 --- a/soda/core/tests/helpers/data_source_fixture.py +++ b/soda/core/tests/helpers/data_source_fixture.py @@ -210,7 +210,8 @@ def create_test_scan(self) -> TestScan: def _test_session_ends(self): self.data_source.connection.close() - self._drop_schema_if_exists() + if not is_cicd(): + self._drop_schema_if_exists() self.schema_data_source.connection.close() def _drop_schema_if_exists(self): @@ -253,3 +254,7 @@ def _update(self, sql: str, connection=None) -> object: return updates finally: cursor.close() + + +def is_cicd(): + return os.getenv("GITHUB_ACTIONS") is not None diff --git a/soda/postgres/tests/postgres_data_source_fixture.py b/soda/postgres/tests/postgres_data_source_fixture.py index dcff68645..18bb6a2a9 100644 --- a/soda/postgres/tests/postgres_data_source_fixture.py +++ b/soda/postgres/tests/postgres_data_source_fixture.py @@ -3,7 +3,7 @@ import logging import os -from helpers.data_source_fixture import DataSourceFixture +from helpers.data_source_fixture import DataSourceFixture, is_cicd logger = logging.getLogger(__name__) @@ -11,9 +11,8 @@ class PostgresDataSourceFixture(DataSourceFixture): def __init__(self, test_data_source: str): super().__init__(test_data_source=test_data_source) - is_local_dev = os.getenv("GITHUB_ACTIONS") is None is_schema_reuse_disabled = os.getenv("POSTGRES_REUSE_SCHEMA", "").lower() == "disabled" - self.local_dev_schema_reused = is_local_dev and not is_schema_reuse_disabled + self.local_dev_schema_reused = (not is_cicd()) and not is_schema_reuse_disabled def _build_configuration_dict(self, schema_name: str | None = None) -> dict: return {