From 48432805287f4ba3fd0b1ce009f58ab5513908b7 Mon Sep 17 00:00:00 2001 From: pdmurray Date: Mon, 11 Nov 2024 11:06:09 -0800 Subject: [PATCH] [BUG] Fix python version compatibility issues affecting tests --- .github/workflows/test_conda_store.yaml | 2 +- .../test_conda_store_server_integration.yaml | 17 +++++++++++------ .../conda_store_server/_internal/schema.py | 4 ++-- .../conda_store_server/_internal/utils.py | 8 +++----- .../conda_store_server/server/auth.py | 6 +++--- conda-store-server/environment-dev.yaml | 4 ++-- conda-store-server/pyproject.toml | 2 +- .../tests/user_journeys/utils/api_utils.py | 8 ++++---- 8 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test_conda_store.yaml b/.github/workflows/test_conda_store.yaml index 67269811d..7d728351f 100644 --- a/.github/workflows/test_conda_store.yaml +++ b/.github/workflows/test_conda_store.yaml @@ -40,7 +40,7 @@ jobs: - name: "Set up Python 🐍" uses: actions/setup-python@v5 with: - python-version-file: .python-version-default + python-version: ${{ matrix.python-version }} cache: "pip" - name: "Install Dependencies 📦" diff --git a/.github/workflows/test_conda_store_server_integration.yaml b/.github/workflows/test_conda_store_server_integration.yaml index 4edc6645d..31e3d14c2 100644 --- a/.github/workflows/test_conda_store_server_integration.yaml +++ b/.github/workflows/test_conda_store_server_integration.yaml @@ -30,6 +30,7 @@ jobs: strategy: matrix: test-type: ["playwright", "integration", "user-journey"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] defaults: run: shell: bash -el {0} @@ -38,10 +39,6 @@ jobs: - name: "Checkout Repository 🛎" uses: actions/checkout@v4 - - name: "Get project's default Python version 🏷️" - run: | - echo "PYTHON_VERSION_DEFAULT=$(cat .python-version-default)" >> $GITHUB_ENV - - name: "Set up conda env 🐍" uses: conda-incubator/setup-miniconda@v3 with: @@ -49,7 +46,7 @@ jobs: miniforge-version: latest auto-activate-base: false activate-environment: conda-store-server-dev - python-version: ${{ env.PYTHON_VERSION_DEFAULT }} + python-version: ${{ matrix.python-version }} - name: "Install dependencies 📦" run: | @@ -78,7 +75,7 @@ jobs: uses: actions/upload-artifact@v4 if: matrix.test-type == 'playwright' with: - name: playwright-tests + name: playwright-tests-${{ matrix.python-version }} path: conda-store-server/test-results - name: "Run integration tests ✅" @@ -91,6 +88,14 @@ jobs: python -m pytest -m "user_journey" if: matrix.test-type == 'user-journey' + # These mirror the tests run while building the conda package + # See https://github.com/conda-forge/conda-store-feedstock/ for details + - name: "Run basic import tests ✅" + run: | + python -c "import conda_store_server" + conda-store-server --help + conda-store-worker --help + - name: "Get Docker logs 🔍" if: ${{ failure() }} run: | diff --git a/conda-store-server/conda_store_server/_internal/schema.py b/conda-store-server/conda_store_server/_internal/schema.py index 96dd735d6..87da460ff 100644 --- a/conda-store-server/conda_store_server/_internal/schema.py +++ b/conda-store-server/conda_store_server/_internal/schema.py @@ -8,7 +8,7 @@ import os import re import sys -from typing import Any, Callable, Dict, List, Optional, TypeAlias, Union +from typing import Any, Callable, Dict, List, Optional, Union from conda_lock.lockfile.v1.models import Lockfile from pydantic import BaseModel, Field, ValidationError, constr, validator @@ -36,7 +36,7 @@ def _datetime_factory(offset: datetime.timedelta): # Authentication Schema ######################### -RoleBindings: TypeAlias = Dict[constr(regex=ARN_ALLOWED), List[str]] +RoleBindings = Dict[constr(regex=ARN_ALLOWED), List[str]] class Permissions(enum.Enum): diff --git a/conda-store-server/conda_store_server/_internal/utils.py b/conda-store-server/conda_store_server/_internal/utils.py index 1ad717202..e4162ac84 100644 --- a/conda-store-server/conda_store_server/_internal/utils.py +++ b/conda-store-server/conda_store_server/_internal/utils.py @@ -11,7 +11,7 @@ import subprocess import sys import time -from typing import AnyStr +from typing import Tuple from filelock import FileLock @@ -154,9 +154,7 @@ def callable_or_value(v, *args, **kwargs): return v -def compile_arn_sql_like( - arn: str, allowed_regex: re.Pattern[AnyStr] -) -> tuple[str, str]: +def compile_arn_sql_like(arn: str, allowed_regex: re.Pattern) -> Tuple[str, str]: """Turn an arn into a string suitable for use in a SQL LIKE statement. Parameters @@ -172,7 +170,7 @@ def compile_arn_sql_like( Returns ------- - tuple[str, str] + Tuple[str, str] (namespace regex, environment regex) to match in a sql LIKE statement. See conda_store_server.server.auth.Authentication.filter_environments for usage. diff --git a/conda-store-server/conda_store_server/server/auth.py b/conda-store-server/conda_store_server/server/auth.py index d2ee4a43a..d375f992a 100644 --- a/conda-store-server/conda_store_server/server/auth.py +++ b/conda-store-server/conda_store_server/server/auth.py @@ -7,7 +7,7 @@ import re import secrets from collections import defaultdict -from typing import Iterable, Optional, Set +from typing import Iterable, Optional, Set, Tuple import jwt import requests @@ -228,7 +228,7 @@ def compile_arn_regex(arn: str) -> re.Pattern: return re.compile(regex_arn) @staticmethod - def compile_arn_sql_like(arn: str) -> tuple[str, str]: + def compile_arn_sql_like(arn: str) -> Tuple[str, str]: """Turn an arn into a string suitable for use in a SQL LIKE statement. The use of this function is discouraged; use @@ -247,7 +247,7 @@ def compile_arn_sql_like(arn: str) -> tuple[str, str]: Returns ------- - tuple[str, str] + Tuple[str, str] (namespace regex, environment regex) to match in a sql LIKE statement. See conda_store_server.server.auth.Authentication.filter_environments for usage. diff --git a/conda-store-server/environment-dev.yaml b/conda-store-server/environment-dev.yaml index 3e73865e2..23f203e24 100644 --- a/conda-store-server/environment-dev.yaml +++ b/conda-store-server/environment-dev.yaml @@ -13,8 +13,8 @@ channels: - conda-forge - nodefaults dependencies: - # must be kept in sync with .python-version-default - - python=3.12 + # must be kept in sync with the min supported version in pyproject.toml + - python >=3.8 # conda builds - conda # dev dependencies diff --git a/conda-store-server/pyproject.toml b/conda-store-server/pyproject.toml index 318466b03..7e513f818 100644 --- a/conda-store-server/pyproject.toml +++ b/conda-store-server/pyproject.toml @@ -61,7 +61,7 @@ dependencies = [ "pymysql", # pyyaml>5.3.1 is broken with cython>=3 transitive dependency # See https://github.com/yaml/pyyaml/issues/724 for details - "pyyaml==5.3.1", + "pyyaml<=5.3.1", "redis", "requests", "pydantic >=1.10.16,<2.0a0", diff --git a/conda-store-server/tests/user_journeys/utils/api_utils.py b/conda-store-server/tests/user_journeys/utils/api_utils.py index e561b6784..ceec96df1 100644 --- a/conda-store-server/tests/user_journeys/utils/api_utils.py +++ b/conda-store-server/tests/user_journeys/utils/api_utils.py @@ -251,7 +251,7 @@ def get_builds( self, environment: Optional[str] = None, namespace: Optional[str] = None, - ) -> dict[str, Any]: + ) -> Dict[str, Any]: """Get information about an environment. Parameters @@ -263,7 +263,7 @@ def get_builds( Returns ------- - dict[str, Any] + Dict[str, Any] Dict of build properties; see API docs for api/v1/build/ for more information. """ @@ -278,7 +278,7 @@ def get_builds( "data" ] - def get_environment(self, namespace: str, environment: str) -> dict[str, Any]: + def get_environment(self, namespace: str, environment: str) -> Dict[str, Any]: """Get information about an environment. Parameters @@ -290,7 +290,7 @@ def get_environment(self, namespace: str, environment: str) -> dict[str, Any]: Returns ------- - dict[str, Any] + Dict[str, Any] Dict of environment properties; see API docs for api/v1/environment/{namespace}/{environment}/ for more information. """