171171
172172
173173
174+ # name: CI Pipeline
175+
176+ # on:
177+ # push:
178+ # branches: [main, develop]
179+ # pull_request:
180+ # branches: [main, develop]
181+
182+ # jobs:
183+ # infra-check:
184+ # runs-on: ubuntu-latest
185+
186+ # services:
187+ # postgres:
188+ # image: postgres:16-alpine
189+ # env:
190+ # POSTGRES_USER: hooktrace
191+ # POSTGRES_PASSWORD: hooktrace_test
192+ # POSTGRES_DB: hooktrace_test
193+ # options: >-
194+ # --health-cmd pg_isready
195+ # --health-interval 10s
196+ # --health-timeout 5s
197+ # --health-retries 5
198+ # ports:
199+ # - 5432:5432
200+
201+ # redis:
202+ # image: redis:7-alpine
203+ # options: >-
204+ # --health-cmd "redis-cli ping"
205+ # --health-interval 10s
206+ # --health-timeout 5s
207+ # --health-retries 5
208+ # ports:
209+ # - 6379:6379
210+
211+ # steps:
212+ # - uses: actions/checkout@v4
213+
214+ # - name: Check Docker Compose config
215+ # run: docker compose config
216+
217+ # # Wait a bit for services to be fully ready
218+ # - name: Wait for services
219+ # run: sleep 5
220+
221+ # # Postgres check via container (no apt install)
222+ # - name: Verify Postgres is reachable
223+ # run: |
224+ # POSTGRES_CONTAINER=$(docker ps --filter "ancestor=postgres:16-alpine" --format "{{.ID}}" | head -n 1)
225+ # docker exec $POSTGRES_CONTAINER psql -U hooktrace -d hooktrace_test -c "SELECT 1;"
226+
227+ # # Redis check via container (no apt install)
228+ # - name: Verify Redis is reachable
229+ # run: |
230+ # REDIS_CONTAINER=$(docker ps --filter "ancestor=redis:7-alpine" --format "{{.ID}}" | head -n 1)
231+ # docker exec $REDIS_CONTAINER redis-cli ping
232+
233+
234+
235+
236+
237+
238+
174239name : CI Pipeline
175240
176241on :
@@ -208,24 +273,58 @@ jobs:
208273 ports :
209274 - 6379:6379
210275
276+ env :
277+ DATABASE_URL : postgresql://hooktrace:hooktrace_test@localhost:5432/hooktrace_test
278+ REDIS_URL : redis://localhost:6379
279+
211280 steps :
212281 - uses : actions/checkout@v4
213282
214283 - name : Check Docker Compose config
215284 run : docker compose config
216285
217- # Wait a bit for services to be fully ready
286+ # Wait for services
218287 - name : Wait for services
219288 run : sleep 5
220289
221- # Postgres check via container (no apt install)
290+ # Verify Postgres
222291 - name : Verify Postgres is reachable
223292 run : |
224293 POSTGRES_CONTAINER=$(docker ps --filter "ancestor=postgres:16-alpine" --format "{{.ID}}" | head -n 1)
225294 docker exec $POSTGRES_CONTAINER psql -U hooktrace -d hooktrace_test -c "SELECT 1;"
226295
227- # Redis check via container (no apt install)
296+ # Verify Redis
228297 - name : Verify Redis is reachable
229298 run : |
230299 REDIS_CONTAINER=$(docker ps --filter "ancestor=redis:7-alpine" --format "{{.ID}}" | head -n 1)
231- docker exec $REDIS_CONTAINER redis-cli ping
300+ docker exec $REDIS_CONTAINER redis-cli ping
301+
302+ # -------------------------------
303+ # SYSTEM INTEGRATION TEST
304+ # -------------------------------
305+
306+ # Start your API (from docker-compose)
307+ - name : Start API
308+ run : |
309+ docker compose up -d api
310+ sleep 10
311+
312+ # Send a test webhook
313+ - name : Send test webhook
314+ run : |
315+ curl -X POST http://localhost:3000/webhook \
316+ -H "Content-Type: application/json" \
317+ -d '{"event":"ci_test","data":{"source":"github-actions"}}'
318+
319+ # Wait for processing (important if async)
320+ - name : Wait for processing
321+ run : sleep 5
322+
323+ # Verify webhook stored in DB
324+ - name : Verify webhook stored in DB
325+ run : |
326+ POSTGRES_CONTAINER=$(docker ps --filter "ancestor=postgres:16-alpine" --format "{{.ID}}" | head -n 1)
327+
328+ docker exec $POSTGRES_CONTAINER psql -U hooktrace -d hooktrace_test -c "
329+ SELECT * FROM events ORDER BY created_at DESC LIMIT 1;
330+ "
0 commit comments