Compare commits

..
1 Commits
Author SHA1 Message Date
Brian Bjarke JensenandCursor aebddb60a2 Migrate Python workflows to python-repositories-ci runner label.
PR Title Check / check-title (pull_request) Successful in 6s
Test Python Package / unit-tests (pull_request) Successful in 59s
Code Quality Pipeline / code-quality (pull_request) Successful in 24s
Test Python Package / integration-tests (pull_request) Successful in 1m47s
Test Python Package / coverage-report (pull_request) Successful in 16s
Co-authored-by: Cursor <[email protected]>
2026-07-09 22:56:38 +02:00
11 changed files with 33 additions and 42 deletions
+2 -2
View File
@@ -17,7 +17,7 @@ on:
env:
REGISTRY: gitea.lille-vemmelund.dk
REGISTRY_USER: ci-bot
IMAGE: gitea.lille-vemmelund.dk/lillevemmelund/python-repositories-ci
IMAGE: gitea.lille-vemmelund.dk/brian/python-repositories-ci
jobs:
build-and-push:
@@ -37,7 +37,7 @@ jobs:
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
run: |
echo "$CI_RUNNER_TOKEN" > /tmp/uv_token
docker build --network=host -f docker/ci/Dockerfile \
docker build -f docker/ci/Dockerfile \
--secret id=uv_token,src=/tmp/uv_token \
-t "${IMAGE}:latest" \
.
+1 -1
View File
@@ -5,10 +5,10 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
docker.io \
git \
&& rm -rf /var/lib/apt/lists/*
COPY --from=docker:27-cli /usr/local/bin/docker /usr/local/bin/docker
COPY --from=ghcr.io/astral-sh/uv:0.7.0 /uv /usr/local/bin/uv
ENV UV_PYTHON_INSTALL_DIR=/opt/uv-python \
+5 -5
View File
@@ -14,10 +14,10 @@ Built from [`docker/ci/Dockerfile`](../docker/ci/Dockerfile):
- Docker CLI (integration tests via testcontainers)
- Dev dependencies from `uv.lock` (`uv sync --all-extras --no-install-project`)
Published to the Gitea container registry (owner segment must be lowercase for Docker):
Published to the Gitea container registry:
- `gitea.lille-vemmelund.dk/lillevemmelund/python-repositories-ci:latest`
- `gitea.lille-vemmelund.dk/lillevemmelund/python-repositories-ci:YYYYMMDDHHmm` (timestamped rollback tag)
- `gitea.lille-vemmelund.dk/brian/python-repositories-ci:latest`
- `gitea.lille-vemmelund.dk/brian/python-repositories-ci:YYYYMMDDHHmm` (timestamped rollback tag)
## Rebuild triggers
@@ -108,7 +108,7 @@ homelab-platform
[`platform/gitea-runners/values.yaml`](https://gitea.lille-vemmelund.dk/LilleVemmelund/homelab-platform/src/branch/main/platform/gitea-runners/values.yaml):
```yaml
python-repositories-ci:docker://gitea.lille-vemmelund.dk/lillevemmelund/python-repositories-ci:latest
python-repositories-ci:docker://gitea.lille-vemmelund.dk/brian/python-repositories-ci:latest
```
After label changes, roll runner pods so they re-register with Gitea.
@@ -137,7 +137,7 @@ bash scripts/ci/build-ci-image.sh --push
```
Run from the repo root on the branch you want to test. Runners pull
`gitea.lille-vemmelund.dk/lillevemmelund/python-repositories-ci:latest` from the registry;
`gitea.lille-vemmelund.dk/brian/python-repositories-ci:latest` from the registry;
they do not care which git branch built it.
Override registry settings if needed:
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "python-repositories"
version = "2.0.3"
version = "2.0.2"
description = "Various python repository interfaces exposed as a python package."
authors = [
{ name = "Brian Bjarke Jensen", email = "[email protected]" }
@@ -73,7 +73,7 @@ class ConnectionAwareAdapter(ConnectionAwareInterface, ContextAwareInterface):
self._invalidate_health_cache()
return
if self._is_client_ready() and self.is_connected():
self.logger.info("Already connected", connection_name=self.connection_name)
self.logger.info(f"Already connected to {self.connection_name}")
return
self.disconnect()
self._establish_connection()
+6 -11
View File
@@ -88,7 +88,7 @@ class MinioAdapter(ObjectRepositoryInterface, ConnectionAwareAdapter):
raise ConnectionError(
f"Bucket '{bucket}' does not exist on Minio at {endpoint}"
)
self.logger.info("Creating bucket", bucket=bucket)
self.logger.info(f"Creating bucket '{bucket}'")
client.make_bucket(bucket)
self._client = client
self._bucket_name = bucket
@@ -138,7 +138,7 @@ class MinioAdapter(ObjectRepositoryInterface, ConnectionAwareAdapter):
content_type=content_type,
)
self.logger.debug(
"Put object", object_name=object_name, bucket=self._bucket_name
f"Put object '{object_name}' into bucket '{self._bucket_name}'"
)
def get(self, object_name: str) -> BytesIO | None:
@@ -163,15 +163,13 @@ class MinioAdapter(ObjectRepositoryInterface, ConnectionAwareAdapter):
buffer.write(chunk)
buffer.seek(0)
self.logger.debug(
"Got object", object_name=object_name, bucket=self._bucket_name
f"Got object '{object_name}' from bucket '{self._bucket_name}'"
)
return buffer
except minio.S3Error as exc:
if exc.code == "NoSuchKey":
self.logger.warning(
"Object not found",
object_name=object_name,
bucket=self._bucket_name,
f"Object '{object_name}' not found in bucket '{self._bucket_name}'"
)
return None
raise
@@ -195,7 +193,7 @@ class MinioAdapter(ObjectRepositoryInterface, ConnectionAwareAdapter):
object_name=object_name,
)
self.logger.debug(
"Deleted object", object_name=object_name, bucket=self._bucket_name
f"Deleted object '{object_name}' from bucket '{self._bucket_name}'"
)
def list_objects(self, prefix: str = "") -> list[str]:
@@ -217,9 +215,6 @@ class MinioAdapter(ObjectRepositoryInterface, ConnectionAwareAdapter):
obj.object_name for obj in objects if obj.object_name is not None
]
self.logger.debug(
"Listed objects",
count=len(object_names),
bucket=self._bucket_name,
prefix=prefix,
f"Listed {len(object_names)} object(s) in bucket '{self._bucket_name}' with prefix '{prefix}'"
)
return object_names
@@ -101,7 +101,7 @@ class RedisAdapter(JsonRepositoryInterface, ConnectionAwareAdapter):
assert self._client is not None
# Set data
self._client.json().set(key, self.path, data)
self.logger.debug("Set key", key=key, data_keys=list(data.keys()))
self.logger.debug(f"Set {key} to {data}")
def get(self, key: str) -> dict[str, Any] | None:
"""Get a JSON object from Redis."""
@@ -116,7 +116,7 @@ class RedisAdapter(JsonRepositoryInterface, ConnectionAwareAdapter):
dict[str, Any] | None,
self._client.json().get(key),
)
self.logger.debug("Got value", key=key, found=data is not None)
self.logger.debug(f"Got {data} from {key}")
return data
def delete(self, key: str) -> None:
@@ -129,7 +129,7 @@ class RedisAdapter(JsonRepositoryInterface, ConnectionAwareAdapter):
assert self._client is not None
# Delete data
self._client.json().delete(key)
self.logger.debug("Deleted key", key=key)
self.logger.debug(f"Deleted {key}")
def _validate_pattern(self, pattern: str) -> None:
if not isinstance(pattern, str) or len(pattern) == 0:
@@ -147,7 +147,7 @@ class RedisAdapter(JsonRepositoryInterface, ConnectionAwareAdapter):
self._client.keys(pattern),
)
keys: list[str] = [key.decode(self.encoding) for key in keys_raw]
self.logger.debug("Listed keys", pattern=pattern, count=len(keys))
self.logger.debug(f"Got {keys} matching {pattern}")
return keys
def scan_keys(
+4 -4
View File
@@ -15,7 +15,7 @@
# Optional overrides:
# REGISTRY=gitea.lille-vemmelund.dk
# REGISTRY_USER=ci-bot
# IMAGE_OWNER=lillevemmelund
# IMAGE_OWNER=brian
# IMAGE_NAME=python-repositories-ci
set -euo pipefail
@@ -24,7 +24,7 @@ REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
REGISTRY="${REGISTRY:-gitea.lille-vemmelund.dk}"
REGISTRY_USER="${REGISTRY_USER:-ci-bot}"
IMAGE_OWNER="${IMAGE_OWNER:-lillevemmelund}"
IMAGE_OWNER="${IMAGE_OWNER:-brian}"
IMAGE_NAME="${IMAGE_NAME:-python-repositories-ci}"
IMAGE="${IMAGE:-${REGISTRY}/${IMAGE_OWNER}/${IMAGE_NAME}}"
@@ -52,7 +52,7 @@ cd "$REPO_ROOT"
if [[ "$MODE" == "local" ]]; then
echo "=== Building local CI image (no push): python-repositories-ci:local ==="
docker build --network=host -f docker/ci/Dockerfile \
docker build -f docker/ci/Dockerfile \
--secret "id=uv_token,src=${TOKEN_FILE}" \
-t python-repositories-ci:local \
.
@@ -64,7 +64,7 @@ echo "=== Logging in to ${REGISTRY} as ${REGISTRY_USER} ==="
echo "$CI_RUNNER_TOKEN" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin
echo "=== Building ${IMAGE}:latest ==="
docker build --network=host -f docker/ci/Dockerfile \
docker build -f docker/ci/Dockerfile \
--secret "id=uv_token,src=${TOKEN_FILE}" \
-t "${IMAGE}:latest" \
.
+6 -9
View File
@@ -102,8 +102,7 @@ def test_should_log_info_when_already_connected(
"""Test that the MinioAdapter logs info when connect is called while already connected."""
with caplog.at_level(logging.INFO):
minio_adapter.connect()
assert "Already connected" in caplog.text
assert "Minio" in caplog.text
assert "Already connected to Minio" in caplog.text
def test_should_raise_connection_error_when_unable_to_connect() -> None:
@@ -151,8 +150,7 @@ def test_connect_creates_bucket_when_create_bucket_if_missing_enabled(
with caplog.at_level(logging.INFO):
adapter.connect()
assert "Creating bucket" in caplog.text
assert bucket_name in caplog.text
assert f"Creating bucket '{bucket_name}'" in caplog.text
def test_should_log_error_on_exception_during_exit(
@@ -235,11 +233,10 @@ def test_should_log_warning_when_getting_nonexistent_object(
with caplog.at_level("WARNING"):
result = adapter.get(object_name)
assert result is None
assert "Object not found" in caplog.text
assert object_name in caplog.text
bucket_name = adapter._bucket_name
assert bucket_name is not None
assert bucket_name in caplog.text
assert (
f"Object '{object_name}' not found in bucket '{adapter._bucket_name}'"
in caplog.text
)
def test_should_reraise_s3error_other_than_no_such_key() -> None:
+1 -2
View File
@@ -56,8 +56,7 @@ def test_should_log_info_when_already_connected(
"""Test that the RedisAdapter logs info when connect is called while already connected."""
with caplog.at_level(logging.INFO):
redis_adapter.connect()
assert "Already connected" in caplog.text
assert "Redis" in caplog.text
assert "Already connected to Redis" in caplog.text
def test_should_raise_connection_error_when_unable_to_connect() -> None:
Generated
+2 -2
View File
@@ -1,5 +1,5 @@
version = 1
revision = 2
revision = 3
requires-python = ">=3.12"
resolution-markers = [
"python_full_version >= '3.15'",
@@ -1056,7 +1056,7 @@ wheels = [
[[package]]
name = "python-repositories"
version = "2.0.3"
version = "2.0.2"
source = { editable = "." }
dependencies = [
{ name = "python-dotenv" },