Skip to content

Commit c86129f

Browse files
committed
compose profiles, simpler deploy
1 parent da86acc commit c86129f

File tree

4 files changed

+331
-154
lines changed

4 files changed

+331
-154
lines changed

.github/actions/setup-ci-compose/action.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/workflows/backend-ci.yml

Lines changed: 92 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
integration:
2020
name: Integration Tests
2121
runs-on: ubuntu-latest
22+
2223
steps:
2324
- uses: actions/checkout@v6
2425

@@ -34,91 +35,134 @@ jobs:
3435
uv python install 3.12
3536
uv sync --frozen
3637
37-
- name: Setup Docker Buildx
38-
uses: docker/setup-buildx-action@v3
38+
- name: Start infrastructure services
39+
run: |
40+
docker compose -f docker-compose.ci.yaml up -d --wait --wait-timeout 120
41+
docker compose -f docker-compose.ci.yaml ps
3942
40-
- name: Setup Kubernetes (k3s)
43+
- name: Run integration tests (non-k8s)
44+
timeout-minutes: 10
45+
env:
46+
MONGO_ROOT_USER: root
47+
MONGO_ROOT_PASSWORD: rootpassword
48+
MONGODB_HOST: 127.0.0.1
49+
MONGODB_PORT: 27017
50+
MONGODB_URL: mongodb://root:[email protected]:27017/?authSource=admin
51+
KAFKA_BOOTSTRAP_SERVERS: localhost:9092
52+
SCHEMA_REGISTRY_URL: http://localhost:8081
53+
REDIS_HOST: localhost
54+
REDIS_PORT: 6379
55+
SCHEMA_SUBJECT_PREFIX: "ci.${{ github.run_id }}."
56+
COVERAGE_CORE: sysmon
4157
run: |
42-
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik --tls-san host.docker.internal" sh -
43-
mkdir -p /home/runner/.kube
44-
sudo k3s kubectl config view --raw > /home/runner/.kube/config
45-
sudo chmod 600 /home/runner/.kube/config
46-
export KUBECONFIG=/home/runner/.kube/config
47-
timeout 90 bash -c 'until sudo k3s kubectl cluster-info; do sleep 5; done'
58+
cd backend
59+
uv run pytest tests/integration -v -rs \
60+
--ignore=tests/integration/k8s \
61+
--cov=app --cov-branch \
62+
--cov-report=xml --cov-report=term
4863
49-
- name: Create kubeconfig for CI Docker containers
64+
- name: Upload coverage to Codecov
65+
uses: codecov/codecov-action@v5
66+
if: always()
67+
with:
68+
token: ${{ secrets.CODECOV_TOKEN }}
69+
files: backend/coverage.xml
70+
flags: backend
71+
name: backend-coverage
72+
fail_ci_if_error: false
73+
verbose: true
74+
75+
- name: Collect logs
76+
if: failure()
5077
run: |
51-
# Copy real k3s kubeconfig with valid credentials, but change server address
52-
# from 127.0.0.1 to host.docker.internal for Docker container networking
53-
# (k3s was started with --tls-san host.docker.internal so the cert is valid)
54-
sed 's|https://127.0.0.1:6443|https://host.docker.internal:6443|g' \
55-
/home/runner/.kube/config > backend/kubeconfig.yaml
56-
chmod 644 backend/kubeconfig.yaml
57-
58-
- name: Setup CI Compose
59-
uses: ./.github/actions/setup-ci-compose
78+
mkdir -p logs
79+
docker compose -f docker-compose.ci.yaml logs > logs/docker-compose.log 2>&1
80+
docker compose -f docker-compose.ci.yaml logs kafka > logs/kafka.log 2>&1
81+
docker compose -f docker-compose.ci.yaml logs schema-registry > logs/schema-registry.log 2>&1
82+
83+
- name: Upload logs
84+
if: failure()
85+
uses: actions/upload-artifact@v6
6086
with:
61-
kubeconfig-path: /home/runner/.kube/config
87+
name: backend-logs
88+
path: logs/
89+
90+
k8s-integration:
91+
name: K8s Integration Tests
92+
runs-on: ubuntu-latest
93+
94+
steps:
95+
- uses: actions/checkout@v6
6296

63-
- name: Build services
64-
uses: docker/bake-action@v6
97+
- name: Set up uv
98+
uses: astral-sh/setup-uv@v7
6599
with:
66-
source: .
67-
files: docker-compose.ci.yaml
68-
load: true
69-
set: |
70-
*.cache-from=type=gha,scope=buildkit-${{ github.repository }}-${{ github.ref_name }}
71-
*.cache-from=type=gha,scope=buildkit-${{ github.repository }}-main
72-
*.cache-to=type=gha,mode=max,scope=buildkit-${{ github.repository }}-${{ github.ref_name }}
73-
*.pull=true
74-
env:
75-
BUILDKIT_PROGRESS: plain
100+
enable-cache: true
101+
cache-dependency-glob: "backend/uv.lock"
76102

77-
- name: Start services
103+
- name: Install Python dependencies
78104
run: |
79-
docker compose -f docker-compose.ci.yaml up -d --remove-orphans --wait --wait-timeout 180
105+
cd backend
106+
uv python install 3.12
107+
uv sync --frozen
108+
109+
- name: Start infrastructure services
110+
run: |
111+
docker compose -f docker-compose.ci.yaml up -d --wait --wait-timeout 120
80112
docker compose -f docker-compose.ci.yaml ps
81-
kubectl get pods -A -o wide
82113
83-
- name: Run integration tests
114+
- name: Setup Kubernetes (k3s)
115+
run: |
116+
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik" sh -
117+
mkdir -p /home/runner/.kube
118+
sudo k3s kubectl config view --raw > /home/runner/.kube/config
119+
sudo chmod 600 /home/runner/.kube/config
120+
export KUBECONFIG=/home/runner/.kube/config
121+
timeout 90 bash -c 'until sudo k3s kubectl cluster-info; do sleep 5; done'
122+
kubectl create namespace integr8scode --dry-run=client -o yaml | kubectl apply -f -
123+
124+
- name: Run k8s integration tests
84125
timeout-minutes: 10
85126
env:
86-
BACKEND_BASE_URL: https://127.0.0.1:443
87127
MONGO_ROOT_USER: root
88128
MONGO_ROOT_PASSWORD: rootpassword
89-
MONGODB_HOST: 127.0.0.1
90-
MONGODB_PORT: 27017
91129
MONGODB_URL: mongodb://root:[email protected]:27017/?authSource=admin
130+
KAFKA_BOOTSTRAP_SERVERS: localhost:9092
131+
SCHEMA_REGISTRY_URL: http://localhost:8081
132+
REDIS_HOST: localhost
133+
REDIS_PORT: 6379
92134
SCHEMA_SUBJECT_PREFIX: "ci.${{ github.run_id }}."
93-
COVERAGE_CORE: sysmon # Python 3.12+ faster coverage instrumentation
135+
KUBECONFIG: /home/runner/.kube/config
136+
K8S_NAMESPACE: integr8scode
137+
COVERAGE_CORE: sysmon
94138
run: |
95139
cd backend
96-
uv run pytest tests/integration -v -rs --cov=app --cov-branch --cov-report=xml --cov-report=term
140+
uv run pytest tests/integration/k8s -v -rs \
141+
--cov=app --cov-branch \
142+
--cov-report=xml --cov-report=term
97143
98144
- name: Upload coverage to Codecov
99145
uses: codecov/codecov-action@v5
100146
if: always()
101147
with:
102148
token: ${{ secrets.CODECOV_TOKEN }}
103149
files: backend/coverage.xml
104-
flags: backend
105-
name: backend-coverage
150+
flags: backend-k8s
151+
name: backend-k8s-coverage
106152
fail_ci_if_error: false
107153
verbose: true
108154

109155
- name: Collect logs
110156
if: failure()
111157
run: |
112158
mkdir -p logs
113-
docker compose -f docker-compose.ci.yaml logs > logs/docker-compose.log
114-
docker compose -f docker-compose.ci.yaml logs backend > logs/backend.log
115-
docker compose -f docker-compose.ci.yaml logs mongo > logs/mongo.log
116-
kubectl get events --sort-by='.metadata.creationTimestamp' > logs/k8s-events.log 2>&1 || true
159+
docker compose -f docker-compose.ci.yaml logs > logs/docker-compose.log 2>&1
160+
kubectl get events --sort-by='.metadata.creationTimestamp' -A > logs/k8s-events.log 2>&1 || true
117161
kubectl describe pods -A > logs/k8s-describe-pods.log 2>&1 || true
118162
119163
- name: Upload logs
120164
if: failure()
121165
uses: actions/upload-artifact@v6
122166
with:
123-
name: backend-logs
167+
name: k8s-logs
124168
path: logs/

.github/workflows/frontend-ci.yml

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -81,59 +81,18 @@ jobs:
8181
export KUBECONFIG=/home/runner/.kube/config
8282
timeout 90 bash -c 'until sudo k3s kubectl cluster-info; do sleep 5; done'
8383
84-
- name: Create kubeconfig for CI
84+
- name: Create kubeconfig for Docker containers
8585
run: |
86-
cat > backend/kubeconfig.yaml <<EOF
87-
apiVersion: v1
88-
kind: Config
89-
clusters:
90-
- name: ci-cluster
91-
cluster:
92-
server: https://host.docker.internal:6443
93-
insecure-skip-tls-verify: true
94-
users:
95-
- name: ci-user
96-
user:
97-
token: "ci-token"
98-
contexts:
99-
- name: ci
100-
context:
101-
cluster: ci-cluster
102-
user: ci-user
103-
current-context: ci
104-
EOF
105-
106-
- name: Setup CI Compose
107-
uses: ./.github/actions/setup-ci-compose
108-
with:
109-
kubeconfig-path: /home/runner/.kube/config
110-
111-
- name: Build services
112-
uses: docker/bake-action@v6
113-
with:
114-
source: .
115-
files: docker-compose.ci.yaml
116-
load: true
117-
set: |
118-
*.cache-from=type=gha,scope=buildkit-${{ github.repository }}-${{ github.ref_name }}
119-
*.cache-from=type=gha,scope=buildkit-${{ github.repository }}-main
120-
*.cache-to=type=gha,mode=max,scope=buildkit-${{ github.repository }}-${{ github.ref_name }}
121-
*.pull=true
122-
env:
123-
BUILDKIT_PROGRESS: plain
86+
# Copy k3s kubeconfig with host.docker.internal for container networking
87+
sed 's|https://127.0.0.1:6443|https://host.docker.internal:6443|g' \
88+
/home/runner/.kube/config > backend/kubeconfig.yaml
89+
chmod 644 backend/kubeconfig.yaml
12490
125-
- name: Start services
91+
- name: Build and start full stack
12692
run: |
127-
docker compose -f docker-compose.ci.yaml up -d --remove-orphans
93+
docker compose -f docker-compose.ci.yaml --profile full up -d --build --wait --wait-timeout 300
12894
docker compose -f docker-compose.ci.yaml ps
12995
130-
- name: Wait for services
131-
run: |
132-
echo "Waiting for backend..."
133-
curl --retry 60 --retry-delay 5 --retry-all-errors -ksf https://127.0.0.1:443/api/v1/health/live
134-
echo "Waiting for frontend..."
135-
curl --retry 60 --retry-delay 5 --retry-all-errors -ksf https://127.0.0.1:5001/
136-
13796
- name: Seed test users
13897
run: |
13998
docker compose -f docker-compose.ci.yaml exec -T backend uv run python scripts/seed_users.py
@@ -155,9 +114,11 @@ jobs:
155114
if: failure()
156115
run: |
157116
mkdir -p logs
158-
docker compose -f docker-compose.ci.yaml logs > logs/docker-compose.log
159-
docker compose -f docker-compose.ci.yaml logs backend > logs/backend.log
160-
docker compose -f docker-compose.ci.yaml logs frontend > logs/frontend.log
117+
docker compose -f docker-compose.ci.yaml logs > logs/docker-compose.log 2>&1
118+
docker compose -f docker-compose.ci.yaml logs backend > logs/backend.log 2>&1
119+
docker compose -f docker-compose.ci.yaml logs frontend > logs/frontend.log 2>&1
120+
docker compose -f docker-compose.ci.yaml logs kafka > logs/kafka.log 2>&1
121+
kubectl get events --sort-by='.metadata.creationTimestamp' -A > logs/k8s-events.log 2>&1 || true
161122
162123
- name: Upload logs
163124
if: failure()

0 commit comments

Comments
 (0)