Skip to content

Commit 3114292

Browse files
committed
ci: now frontend and backend have completely separate flows
1 parent 74d915f commit 3114292

File tree

4 files changed

+317
-303
lines changed

4 files changed

+317
-303
lines changed

.github/workflows/backend-ci.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Backend CI
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
paths:
7+
- 'backend/**'
8+
- '.github/workflows/backend-ci.yml'
9+
- 'docker-compose.ci.yaml'
10+
pull_request:
11+
branches: [main, dev]
12+
paths:
13+
- 'backend/**'
14+
- '.github/workflows/backend-ci.yml'
15+
- 'docker-compose.ci.yaml'
16+
workflow_dispatch:
17+
18+
jobs:
19+
integration:
20+
name: Integration Tests
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v6
24+
25+
- name: Set up uv
26+
uses: astral-sh/setup-uv@v7
27+
with:
28+
enable-cache: true
29+
cache-dependency-glob: "backend/uv.lock"
30+
31+
- name: Install Python dependencies
32+
run: |
33+
cd backend
34+
uv python install 3.12
35+
uv sync --frozen
36+
37+
- name: Setup Docker Buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Setup Kubernetes (k3s)
41+
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'
48+
49+
- name: Create kubeconfig for CI
50+
run: |
51+
cat > backend/kubeconfig.yaml <<EOF
52+
apiVersion: v1
53+
kind: Config
54+
clusters:
55+
- name: ci-cluster
56+
cluster:
57+
server: https://host.docker.internal:6443
58+
insecure-skip-tls-verify: true
59+
users:
60+
- name: ci-user
61+
user:
62+
token: "ci-token"
63+
contexts:
64+
- name: ci
65+
context:
66+
cluster: ci-cluster
67+
user: ci-user
68+
current-context: ci
69+
EOF
70+
71+
- name: Setup CI Compose
72+
uses: ./.github/actions/setup-ci-compose
73+
with:
74+
kubeconfig-path: /home/runner/.kube/config
75+
76+
- name: Build services
77+
uses: docker/bake-action@v6
78+
with:
79+
source: .
80+
files: docker-compose.ci.yaml
81+
load: true
82+
set: |
83+
*.cache-from=type=gha,scope=buildkit-${{ github.repository }}-${{ github.ref_name }}
84+
*.cache-from=type=gha,scope=buildkit-${{ github.repository }}-main
85+
*.cache-to=type=gha,mode=max,scope=buildkit-${{ github.repository }}-${{ github.ref_name }}
86+
*.pull=true
87+
env:
88+
BUILDKIT_PROGRESS: plain
89+
90+
- name: Start services
91+
run: |
92+
docker compose -f docker-compose.ci.yaml up -d --remove-orphans
93+
docker compose -f docker-compose.ci.yaml ps
94+
95+
- name: Wait for backend
96+
run: |
97+
curl --retry 60 --retry-delay 5 --retry-all-errors -ksf https://127.0.0.1:443/api/v1/health/live
98+
docker compose -f docker-compose.ci.yaml ps
99+
kubectl get pods -A -o wide
100+
101+
- name: Run integration tests
102+
timeout-minutes: 5
103+
env:
104+
BACKEND_BASE_URL: https://127.0.0.1:443
105+
MONGO_ROOT_USER: root
106+
MONGO_ROOT_PASSWORD: rootpassword
107+
MONGODB_HOST: 127.0.0.1
108+
MONGODB_PORT: 27017
109+
MONGODB_URL: mongodb://root:[email protected]:27017/?authSource=admin
110+
SCHEMA_SUBJECT_PREFIX: "ci.${{ github.run_id }}."
111+
run: |
112+
cd backend
113+
uv run pytest tests/integration -v --cov=app --cov-branch --cov-report=xml --cov-report=term
114+
115+
- name: Upload coverage to Codecov
116+
uses: codecov/codecov-action@v5
117+
if: always()
118+
with:
119+
token: ${{ secrets.CODECOV_TOKEN }}
120+
files: backend/coverage.xml
121+
flags: backend
122+
name: backend-coverage
123+
slug: HardMax71/Integr8sCode
124+
fail_ci_if_error: false
125+
126+
- name: Collect logs
127+
if: failure()
128+
run: |
129+
mkdir -p logs
130+
docker compose -f docker-compose.ci.yaml logs > logs/docker-compose.log
131+
docker compose -f docker-compose.ci.yaml logs backend > logs/backend.log
132+
docker compose -f docker-compose.ci.yaml logs mongo > logs/mongo.log
133+
kubectl get events --sort-by='.metadata.creationTimestamp' > logs/k8s-events.log 2>&1 || true
134+
kubectl describe pods -A > logs/k8s-describe-pods.log 2>&1 || true
135+
136+
- name: Upload logs
137+
if: failure()
138+
uses: actions/upload-artifact@v6
139+
with:
140+
name: backend-logs
141+
path: logs/

0 commit comments

Comments
 (0)