Skip to content

Commit 129c987

Browse files
committed
CI fixes: pytest quiet mode, Docker caching, test stability improvements
1 parent 6b25749 commit 129c987

File tree

4 files changed

+71
-14
lines changed

4 files changed

+71
-14
lines changed

.github/workflows/tests.yml

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v4
1616

1717
- name: Setup Docker Buildx
18-
uses: docker/setup-buildx-action@v2
18+
uses: docker/setup-buildx-action@v3
1919

2020
- name: Install yq
2121
run: |
@@ -32,6 +32,42 @@ jobs:
3232
kubectl version
3333
kubectl get nodes
3434
35+
- name: Create dummy kubeconfig for CI
36+
run: |
37+
# Create a dummy kubeconfig so backend can start without real k8s connection
38+
cat > backend/kubeconfig.yaml <<EOF
39+
apiVersion: v1
40+
kind: Config
41+
clusters:
42+
- name: ci-cluster
43+
cluster:
44+
server: https://host.docker.internal:6443
45+
insecure-skip-tls-verify: true
46+
users:
47+
- name: ci-user
48+
user:
49+
token: "ci-token"
50+
contexts:
51+
- name: ci
52+
context:
53+
cluster: ci-cluster
54+
user: ci-user
55+
current-context: ci
56+
EOF
57+
echo "Created dummy kubeconfig for CI"
58+
59+
- name: Pre-pull base images in parallel
60+
run: |
61+
echo "Pre-pulling base images to speed up builds..."
62+
docker pull python:3.12-slim &
63+
docker pull alpine:latest &
64+
docker pull confluentinc/cp-kafka:7.5.0 &
65+
docker pull confluentinc/cp-zookeeper:7.5.0 &
66+
docker pull mongo:7 &
67+
docker pull redis:7-alpine &
68+
wait
69+
echo "Base images pulled successfully"
70+
3571
- name: Modify Docker Compose for CI
3672
run: |
3773
cp docker-compose.yaml docker-compose.ci.yaml
@@ -73,23 +109,42 @@ jobs:
73109
cat docker-compose.ci.yaml
74110
echo "------------------------------------"
75111
76-
- name: Start services and check status
112+
- name: Build services with optimized cache
113+
uses: docker/bake-action@v6
114+
with:
115+
source: .
116+
files: docker-compose.ci.yaml
117+
load: true
118+
set: |
119+
*.cache-from=type=gha,scope=buildkit-${{ github.repository }}-${{ github.ref_name }}
120+
*.cache-from=type=gha,scope=buildkit-${{ github.repository }}-main
121+
*.cache-to=type=gha,mode=max,scope=buildkit-${{ github.repository }}-${{ github.ref_name }}
122+
*.pull=true
123+
124+
- name: Start services
77125
run: |
78-
echo "Attempting to start services..."
79-
# Try to start services. If the command fails...
80-
docker compose -f docker-compose.ci.yaml up --build -d --remove-orphans || \
126+
echo "Starting services (images already built with cache)..."
127+
docker compose -f docker-compose.ci.yaml up -d --remove-orphans || \
81128
(
82-
# ...then execute this block of code.
83129
echo "::error::Docker Compose failed to start. Dumping all logs..."
84130
docker compose -f docker-compose.ci.yaml logs
85-
exit 1 # Ensure the job fails
131+
exit 1
86132
)
87133
88134
echo "Services started. Waiting for stabilization..."
89135
sleep 45
90-
136+
91137
echo "Final status of all containers:"
92138
docker compose -f docker-compose.ci.yaml ps
139+
140+
echo "Checking cert-generator logs:"
141+
docker compose -f docker-compose.ci.yaml logs cert-generator || echo "cert-generator not found or exited"
142+
143+
echo "Checking backend container status:"
144+
docker compose -f docker-compose.ci.yaml ps backend
145+
146+
echo "Checking backend logs:"
147+
docker compose -f docker-compose.ci.yaml logs backend || echo "backend not found"
93148
94149
# Explicitly check for containers that have exited
95150
if docker compose -f docker-compose.ci.yaml ps | grep -q 'Exit'; then
@@ -130,6 +185,7 @@ jobs:
130185
pip3 install -r requirements-dev.txt
131186
132187
- name: Run backend tests with coverage
188+
timeout-minutes: 5
133189
env:
134190
BACKEND_BASE_URL: https://127.0.0.1:443
135191
# Use default MongoDB credentials for CI

backend/app/services/notification_service.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import Awaitable, Callable, Mapping
66

77
import httpx
8-
from backend.app.settings import get_settings
98

109
from app.core.exceptions import ServiceError
1110
from app.core.logging import logger
@@ -38,7 +37,7 @@
3837
from app.services.event_bus import EventBusManager
3938
from app.services.kafka_event_service import KafkaEventService
4039
from app.services.sse.redis_bus import SSERedisBus
41-
from app.settings import Settings
40+
from app.settings import Settings, get_settings
4241

4342
# Constants
4443
ENTITY_EXECUTION_TAG = "entity:execution"

backend/pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ markers = [
5555
]
5656
asyncio_mode = "auto"
5757
asyncio_default_fixture_loop_scope = "function"
58-
log_cli = true
59-
log_cli_level = "INFO"
60-
# Run tests in parallel by default; distribute by file to minimize contention
61-
addopts = "-n auto --dist loadfile"
58+
log_cli = false
59+
log_cli_level = "ERROR"
60+
log_capture = true
61+
log_level = "ERROR"
62+
addopts = "-n 4 --dist loadfile --tb=short -q --no-header -q"

cert-generator/setup-k8s.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if [ -n "$CI" ]; then
99
if ! kubectl version --request-timeout=5s >/dev/null 2>&1; then
1010
echo "WARNING: Cannot connect to Kubernetes in CI - skipping k8s setup"
1111
echo "Creating dummy kubeconfig for CI..."
12+
mkdir -p /backend
1213
cat > /backend/kubeconfig.yaml <<EOF
1314
apiVersion: v1
1415
kind: Config

0 commit comments

Comments
 (0)