Skip to content

Commit

Permalink
[BUG] Fix python version compatibility issues affecting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray committed Nov 11, 2024
1 parent 92a199b commit 717fa47
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_conda_store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 📦"
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/test_conda_store_server_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -38,18 +39,14 @@ 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:
environment-file: conda-store-server/environment-dev.yaml
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: |
Expand Down Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions conda-store-server/conda_store_server/_internal/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 3 additions & 5 deletions conda-store-server/conda_store_server/_internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import subprocess
import sys
import time
from typing import AnyStr
from typing import Tuple

from filelock import FileLock

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions conda-store-server/conda_store_server/server/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions conda-store-server/environment-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion conda-store-server/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions conda-store-server/tests/user_journeys/utils/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
"""
Expand All @@ -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
Expand All @@ -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.
"""
Expand Down

0 comments on commit 717fa47

Please sign in to comment.