|
15 | 15 | - uses: actions/checkout@v4 |
16 | 16 |
|
17 | 17 | - name: Setup Docker Buildx |
18 | | - uses: docker/setup-buildx-action@v2 |
| 18 | + uses: docker/setup-buildx-action@v3 |
19 | 19 |
|
20 | 20 | - name: Install yq |
21 | 21 | run: | |
|
32 | 32 | kubectl version |
33 | 33 | kubectl get nodes |
34 | 34 |
|
| 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 | +
|
35 | 71 | - name: Modify Docker Compose for CI |
36 | 72 | run: | |
37 | 73 | cp docker-compose.yaml docker-compose.ci.yaml |
@@ -73,23 +109,42 @@ jobs: |
73 | 109 | cat docker-compose.ci.yaml |
74 | 110 | echo "------------------------------------" |
75 | 111 |
|
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 |
77 | 125 | 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 || \ |
81 | 128 | ( |
82 | | - # ...then execute this block of code. |
83 | 129 | echo "::error::Docker Compose failed to start. Dumping all logs..." |
84 | 130 | docker compose -f docker-compose.ci.yaml logs |
85 | | - exit 1 # Ensure the job fails |
| 131 | + exit 1 |
86 | 132 | ) |
87 | 133 | |
88 | 134 | echo "Services started. Waiting for stabilization..." |
89 | 135 | sleep 45 |
90 | | - |
| 136 | +
|
91 | 137 | echo "Final status of all containers:" |
92 | 138 | 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" |
93 | 148 | |
94 | 149 | # Explicitly check for containers that have exited |
95 | 150 | if docker compose -f docker-compose.ci.yaml ps | grep -q 'Exit'; then |
@@ -130,6 +185,7 @@ jobs: |
130 | 185 | pip3 install -r requirements-dev.txt |
131 | 186 |
|
132 | 187 | - name: Run backend tests with coverage |
| 188 | + timeout-minutes: 5 |
133 | 189 | env: |
134 | 190 | BACKEND_BASE_URL: https://127.0.0.1:443 |
135 | 191 | # Use default MongoDB credentials for CI |
|
0 commit comments