From 5257e0f2c8fc914360f922a332e2260b4a9f434b Mon Sep 17 00:00:00 2001 From: rhatgadkar-goog Date: Mon, 6 Jan 2025 18:39:05 +0000 Subject: [PATCH 1/5] feat: Add psycopg 2.9.10 into requirements-test.txt --- requirements-test.txt | 1 + .../samples => tests/system}/test_psycopg2_direct_connection.py | 0 2 files changed, 1 insertion(+) rename {docs/samples => tests/system}/test_psycopg2_direct_connection.py (100%) diff --git a/requirements-test.txt b/requirements-test.txt index d0c14928..12b94c08 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,6 +1,7 @@ asyncpg==0.30.0 mock==5.1.0 pg8000==1.31.2 +psycopg2-binary==2.9.10 pytest==8.3.4 pytest-asyncio==0.24.0 pytest-cov==6.0.0 diff --git a/docs/samples/test_psycopg2_direct_connection.py b/tests/system/test_psycopg2_direct_connection.py similarity index 100% rename from docs/samples/test_psycopg2_direct_connection.py rename to tests/system/test_psycopg2_direct_connection.py From 9ca0ff8fe434e5192d3f671cccf862291ebf94be Mon Sep 17 00:00:00 2001 From: rhatgadkar-goog Date: Mon, 6 Jan 2025 19:26:26 +0000 Subject: [PATCH 2/5] Change to use macos-12 in tests.yml --- .github/workflows/tests.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8c487349..41d62552 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -37,7 +37,11 @@ jobs: pull-requests: write strategy: matrix: - os: [macos-latest, windows-latest, ubuntu-latest] + # psycopg 2.9.10 isn't supported on Python 3.9 for macos-14. See + # https://github.com/psycopg/psycopg2/issues/1737. So we are using + # macos-12 for now. When Python 3.9 reaches end-of-life, we should + # change this back to macos-latest. + os: [macos-12, windows-latest, ubuntu-latest] python-version: ["3.9", "3.13"] fail-fast: false steps: From 8aca793fba4abdc27c5f2159fb70abfb04a88dbc Mon Sep 17 00:00:00 2001 From: rhatgadkar-goog Date: Mon, 6 Jan 2025 19:31:20 +0000 Subject: [PATCH 3/5] Fix lint error related to enums From latest mypy, enum members can't be annotated anymore: https://mypy.readthedocs.io/en/stable/changelog.html#change-to-enum-membership-semantics --- google/cloud/alloydb/connector/enums.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/google/cloud/alloydb/connector/enums.py b/google/cloud/alloydb/connector/enums.py index eab5a63a..b1b2086b 100644 --- a/google/cloud/alloydb/connector/enums.py +++ b/google/cloud/alloydb/connector/enums.py @@ -22,9 +22,9 @@ class IPTypes(Enum): Enum for specifying IP type to connect to AlloyDB with. """ - PUBLIC: str = "PUBLIC" - PRIVATE: str = "PRIVATE" - PSC: str = "PSC" + PUBLIC = "PUBLIC" + PRIVATE = "PRIVATE" + PSC = "PSC" @classmethod def _missing_(cls, value: object) -> None: @@ -39,8 +39,8 @@ class RefreshStrategy(Enum): Enum for specifying refresh strategy to connect to AlloyDB with. """ - LAZY: str = "LAZY" - BACKGROUND: str = "BACKGROUND" + LAZY = "LAZY" + BACKGROUND = "BACKGROUND" @classmethod def _missing_(cls, value: object) -> None: From 805ec263baf0f5e58c1a8d74afe9ded269725b30 Mon Sep 17 00:00:00 2001 From: rhatgadkar-goog Date: Mon, 6 Jan 2025 19:58:42 +0000 Subject: [PATCH 4/5] Modify tests.yml to run tests for macos-latest on python 3.13 --- .github/workflows/tests.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 41d62552..e300b08a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -38,11 +38,16 @@ jobs: strategy: matrix: # psycopg 2.9.10 isn't supported on Python 3.9 for macos-14. See - # https://github.com/psycopg/psycopg2/issues/1737. So we are using - # macos-12 for now. When Python 3.9 reaches end-of-life, we should - # change this back to macos-latest. - os: [macos-12, windows-latest, ubuntu-latest] + # https://github.com/psycopg/psycopg2/issues/1737. But it is supported + # on macos-12. When Python 3.9 reaches end-of-life, we should change + # this back to only run the Mac tests on macos-latest. + os: [windows-latest, ubuntu-latest] python-version: ["3.9", "3.13"] + include: + - os: macos-12 + python-version: "3.9" + - os: macos-latest + python-version: "3.13" fail-fast: false steps: - name: Checkout code From 40bacbb678d0f76816fcf2b03143a0a54370bdbe Mon Sep 17 00:00:00 2001 From: rhatgadkar-goog Date: Tue, 7 Jan 2025 23:46:04 +0000 Subject: [PATCH 5/5] Modify requirements-test.txt to use psycopg 2.9.9 on MacOS Python 3.9 --- .github/workflows/tests.yaml | 11 +---------- requirements-test.txt | 10 +++++++++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e300b08a..8c487349 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -37,17 +37,8 @@ jobs: pull-requests: write strategy: matrix: - # psycopg 2.9.10 isn't supported on Python 3.9 for macos-14. See - # https://github.com/psycopg/psycopg2/issues/1737. But it is supported - # on macos-12. When Python 3.9 reaches end-of-life, we should change - # this back to only run the Mac tests on macos-latest. - os: [windows-latest, ubuntu-latest] + os: [macos-latest, windows-latest, ubuntu-latest] python-version: ["3.9", "3.13"] - include: - - os: macos-12 - python-version: "3.9" - - os: macos-latest - python-version: "3.13" fail-fast: false steps: - name: Checkout code diff --git a/requirements-test.txt b/requirements-test.txt index 12b94c08..605dd99b 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,7 +1,15 @@ asyncpg==0.30.0 mock==5.1.0 pg8000==1.31.2 -psycopg2-binary==2.9.10 + +# psycopg 2.9.10 isn't supported on Python 3.9 for macos-latest GitHub runner. +# It is supported for macos-12 runner: +# https://github.com/psycopg/psycopg2/issues/1737. But macos-12 runner is +# deprecated: https://github.com/actions/runner-images/issues/10721. So we +# install psycopg 2.9.9 on Python 3.9 for macos-latest runner. +psycopg2-binary==2.9.9; python_version == "3.9" and sys_platform == "darwin" +psycopg2-binary==2.9.10; python_version != "3.9" or sys_platform != "darwin" + pytest==8.3.4 pytest-asyncio==0.24.0 pytest-cov==6.0.0