Skip to content

Commit

Permalink
tests should work with and without LEGACY_DEPS. legacydeps-flavour im…
Browse files Browse the repository at this point in the history
…age generation documented and configured in CI
  • Loading branch information
alexbarcelo committed Feb 12, 2025
1 parent 72cc393 commit d26304e
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 67 deletions.
8 changes: 6 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
# Now un-exclude:
#
!src
!compile-protos.sh
!compile_protos.py
!dynamic_dependencies.py
!dataclay-common
!requirements.txt
!requirements-legacydeps.txt
!requirements-dev.txt
!pyproject.toml
!README.md
!MANIFEST.in
!tests
!tox.ini
.dockerignore

# Reexclude protos
src/dataclay/proto
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.legacy-deps
platforms: linux/amd64,linux/arm64
build-args:
PYTHON_VERSION=${{ matrix.python-version }}-bullseye
LEGACY_DEPS=True
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}-legacydeps
labels: ${{ steps.meta.outputs.labels }}
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ ARG PYTHON_VERSION=3.10-bookworm
# install dataclay
FROM python:$PYTHON_VERSION
COPY . /app

ARG LEGACY_DEPS=False
RUN python -m pip install --upgrade pip \
&& python -m pip install /app[telemetry]
&& python -m pip install --config-settings=LEGACY_DEPS=$LEGACY_DEPS /app[telemetry]

# prepare dataclay storage dir
RUN mkdir -p /data/storage;
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ ARG PYTHON_VERSION=3.10-bookworm
# install dataclay
FROM python:$PYTHON_VERSION
COPY . /app

ARG LEGACY_DEPS=False
RUN python -m pip install --upgrade pip \
&& python -m pip install -e /app[telemetry,dev]
&& python -m pip install --config-settings=LEGACY_DEPS=$LEGACY_DEPS -e /app[telemetry,dev]

# prepare dataclay storage dir
RUN mkdir -p /data/storage;
Expand Down
22 changes: 0 additions & 22 deletions Dockerfile.legacy-deps

This file was deleted.

16 changes: 0 additions & 16 deletions Dockerfile.legacy-deps.dev

This file was deleted.

16 changes: 16 additions & 0 deletions PUBLISH.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@
docker buildx build --platform linux/amd64,linux/arm64 \
-t ghcr.io/bsc-dom/dataclay:$VERSION-py3.13-bookworm \
--build-arg PYTHON_VERSION=3.13-bookworm --push .
# Repeat for Python 3.9 and 3.10 with the _legacy dependency flavour_
# Build and push Python 3.9 bookworm
docker buildx build --platform linux/amd64,linux/arm64 \
-t ghcr.io/bsc-dom/dataclay:$VERSION-legacydeps-py3.9-bookworm \
--build-arg PYTHON_VERSION=3.9-bookworm \
--build-arg LEGACY_DEPS=True \
--push .
# Build and push Python 3.10 bookworm
docker buildx build --platform linux/amd64,linux/arm64 \
-t ghcr.io/bsc-dom/dataclay:$VERSION-legacydeps-py3.10-bookworm \
-t ghcr.io/bsc-dom/dataclay:$VERSION-legacydeps \
--build-arg PYTHON_VERSION=3.10-bookworm \
--build-arg LEGACY_DEPS=True \
--push .
```

6. Publish the release distribution to PyPI:
Expand Down
2 changes: 1 addition & 1 deletion compile_protos.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def find_config_settings_in_hatchling() -> dict[str, Any]:
and module.__name__.startswith("hatchling.build")
and "config_settings" in frame.f_locals
):
return frame.f_locals["config_settings"]
return frame.f_locals["config_settings"] or {}

return {}

Expand Down
2 changes: 1 addition & 1 deletion dynamic_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def find_config_settings_in_hatchling() -> dict[str, Any]:
and module.__name__.startswith("hatchling.build")
and "config_settings" in frame.f_locals
):
return frame.f_locals["config_settings"]
return frame.f_locals["config_settings"] or {}

return {}

Expand Down
18 changes: 3 additions & 15 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,9 @@ def tests(session):
@nox.session(python=["3.9", "3.10"], tags=["citests"])
def legacy_deps_tests(session):
"""Run the test suite with legacy dependencies."""
session.install("grpcio-tools==1.48.2", "pytest", "pytest-asyncio", "pytest-docker", "pytest-cov", "-r", "requirements-legacydeps.txt")
session.run(
# See compile-protos.sh, it should be the same command
"python3",
"-m",
"grpc_tools.protoc",
"--proto_path=dataclay-common",
"--python_out=src",
"--grpc_python_out=src",
"dataclay-common/dataclay/proto/common/common.proto",
"dataclay-common/dataclay/proto/backend/backend.proto",
"dataclay-common/dataclay/proto/metadata/metadata.proto",
)

session.install(".", "--no-deps")
session.install("pytest", "pytest-asyncio", "pytest-docker", "pytest-cov")

session.install("--config-settings=LEGACY_DEPS=True", ".")
session.run("pytest", "--disable-warnings", "--cov", "--cov-report=term-missing", "--build-legacy-deps", "tests/functional")


Expand Down
10 changes: 3 additions & 7 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ def python_version():


@pytest.fixture(scope="session")
def docker_setup(python_version, request, docker_compose_legacy_deps_file):
def docker_setup(python_version, request):
legacy_deps = request.config.getoption("--build-legacy-deps")
f_flag = f"-f {docker_compose_legacy_deps_file} " if legacy_deps else ""
legacy_arg = f" --build-arg LEGACY_DEPS=True " if legacy_deps else " "
return [
f"{ f_flag }build --build-arg PYTHON_VERSION={python_version}-bookworm",
f"build{ legacy_arg }--build-arg PYTHON_VERSION={python_version}-bookworm",
"up -d",
]

@pytest.fixture(scope="session")
def docker_compose_legacy_deps_file(pytestconfig):
return os.path.join(str(pytestconfig.rootdir), "tests/functional", "docker-compose.legacy-deps.yml")


@pytest.fixture(scope="session")
def docker_compose_file(pytestconfig):
Expand Down

0 comments on commit d26304e

Please sign in to comment.