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/
0 commit comments