diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..479bb809 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,45 @@ +name: Pull Request Checks + +on: + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install pytest build psycopg2-binary + + - name: Build + run: | + python -m build + + - name: Install build artifact (wheel) + run: | + pip install $(ls dist/*.whl) + - name: Run tests + run: | + pytest tests/test_import_from_sqlalchemy.py + + - name: Install build artifact (tgz) + run: | + pip uninstall -y sqlalchemy-redshift + pip install $(ls dist/*.tar.gz) + - name: Run tests + run: | + pytest tests/test_import_from_sqlalchemy.py diff --git a/sqlalchemy_redshift/dialect/commands.py b/sqlalchemy_redshift/commands.py similarity index 100% rename from sqlalchemy_redshift/dialect/commands.py rename to sqlalchemy_redshift/commands.py diff --git a/sqlalchemy_redshift/dialect/ddl.py b/sqlalchemy_redshift/ddl.py similarity index 100% rename from sqlalchemy_redshift/dialect/ddl.py rename to sqlalchemy_redshift/ddl.py diff --git a/sqlalchemy_redshift/dialect/__init__.py b/sqlalchemy_redshift/dialect.py similarity index 99% rename from sqlalchemy_redshift/dialect/__init__.py rename to sqlalchemy_redshift/dialect.py index dd92fae5..0ed5e2d4 100644 --- a/sqlalchemy_redshift/dialect/__init__.py +++ b/sqlalchemy_redshift/dialect.py @@ -3,7 +3,6 @@ import re from collections import defaultdict, namedtuple from logging import getLogger - from importlib.resources import files import sqlalchemy as sa from packaging.version import Version @@ -1212,7 +1211,7 @@ def create_connect_args(self, *args, **kwargs): """ default_args = { 'sslmode': 'verify-full', - 'sslrootcert': str(files(__name__).joinpath('redshift-ca-bundle.crt')), + 'sslrootcert': str(files("sqlalchemy_redshift").joinpath("redshift-ca-bundle.crt")) } cargs, cparams = ( super(Psycopg2RedshiftDialectMixin, self).create_connect_args( diff --git a/tests/test_import_from_sqlalchemy.py b/tests/test_import_from_sqlalchemy.py new file mode 100644 index 00000000..dd10d55f --- /dev/null +++ b/tests/test_import_from_sqlalchemy.py @@ -0,0 +1,11 @@ +from sqlalchemy import create_engine + + +def test_sqla_create_engine(): + """ + Historically SQLalchemy's integration with this package has differed in behavior between Python versions. + This test should be run with each Python version that GX supports. + """ + create_engine( + "redshift+psycopg2://username:password@my-redshift-cluster.abcdef123456.us-west-2.redshift.amazonaws.com:5439/mydatabase" + )