Files
Luncher/.woodpecker/workflow.yaml
T
batmanisko fe6bb3290e
ci/woodpecker/push/workflow Pipeline was canceled
ci/woodpecker/pr/workflow Pipeline was canceled
feat: přidání testů – Jest unit testy + Playwright E2E + CI pipeline
Server:
- Jest unit testy (88 testů): auth, utils, restaurants, service, voting, pizza
- in-memory storage mock pro izolaci testů
- oprava race condition při inicializaci Redis (storageReady promise)
- dev route dostupná i pro NODE_ENV=test
- getStatsMock deterministický (nahrazení Math.random)
- exporty interních helperů pro testovatelnost
- /api/health endpoint pro Playwright readiness check
- tsconfig vylučuje test soubory z produkčního buildu

E2E (e2e/):
- Playwright s Firefoxem + Chromiem
- testy: login, menu, výběr jídla, pizza day životní cyklus, QR/nastavení
- trusted-header auth bypass pro testy, video + trace při selhání

CI (Woodpecker):
- pipeline spouštěna na všech větvích a PR (nejen master)
- redis-stack-server service pro E2E – čistý Redis per větev automaticky
- kroky: unit testy, build, E2E testy (parallel kde možné)
- Docker build zůstává pouze pro master

Co-Authored-By: Claude Opus (extra usage) 4.7 <noreply@anthropic.com>
2026-04-29 00:25:22 +02:00

124 lines
3.3 KiB
YAML

variables:
- &node_image "node:22-alpine"
- &playwright_image "mcr.microsoft.com/playwright:v1.59.1-jammy"
- &branch "master"
# Spustit na všech větvích a pull requestech.
# Docker build probíhá jen na master větvi (viz when: v posledních krocích).
when:
- event: [push, pull_request]
services:
redis:
image: redis/redis-stack-server:7.2.0-RC3
environment:
REDIS_ARGS: "--save '' --loglevel warning"
steps:
- name: Generate TypeScript types
image: *node_image
commands:
- cd types
- yarn install --frozen-lockfile
- yarn openapi-ts
- name: Install server dependencies
image: *node_image
commands:
- cd server
- yarn install --frozen-lockfile
depends_on: [Generate TypeScript types]
- name: Install client dependencies
image: *node_image
commands:
- cd client
- yarn install --frozen-lockfile
depends_on: [Generate TypeScript types]
- name: Install e2e dependencies
image: *playwright_image
commands:
- cd e2e
- yarn install --frozen-lockfile
depends_on: [Generate TypeScript types]
- name: Server unit tests
image: *node_image
environment:
NODE_ENV: test
JWT_SECRET: test-secret-min-32-chars-aaaaaaa!
MOCK_DATA: "true"
STORAGE: json
commands:
- cd server
- yarn test
depends_on: [Install server dependencies]
- name: Build server
image: *node_image
commands:
- cd server
- yarn build
depends_on: [Install server dependencies]
- name: Build client
image: *node_image
commands:
- cd client
- yarn build
depends_on: [Install client dependencies]
- name: Playwright E2E tests
image: *playwright_image
environment:
CI: "true"
NODE_ENV: test
JWT_SECRET: test-secret-min-32-chars-aaaaaaa!
MOCK_DATA: "true"
STORAGE: redis
REDIS_HOST: redis
REDIS_PORT: "6379"
HTTP_REMOTE_USER_ENABLED: "true"
HTTP_REMOTE_USER_HEADER_NAME: remote-user
HTTP_REMOTE_TRUSTED_IPS: "0.0.0.0/0,::/0"
commands:
# Zkopírujeme build klienta do server/public, aby Express mohl SPA servírovat
- cp -r client/dist server/public
- cd e2e
- yarn playwright install firefox --with-deps
- yarn test
depends_on: [Build server, Build client, Install e2e dependencies]
- name: Build Docker image
depends_on: [Build server, Build client]
image: woodpeckerci/plugin-docker-buildx
when:
- event: push
branch: *branch
settings:
dockerfile: Dockerfile-Woodpecker
platforms: linux/amd64
registry:
from_secret: REPO_URL
username:
from_secret: REPO_USERNAME
password:
from_secret: REPO_PASSWORD
repo:
from_secret: REPO_NAME
- name: Discord notification - build
image: appleboy/drone-discord
depends_on: [Build Docker image]
when:
- status: [success, failure]
event: push
branch: *branch
settings:
webhook_id:
from_secret: DISCORD_WEBHOOK_ID
webhook_token:
from_secret: DISCORD_WEBHOOK_TOKEN
message: "{{#success build.status}}✅ Sestavení {{build.number}} proběhlo úspěšně.{{else}}❌ Sestavení {{build.number}} selhalo.{{/success}}\n\nPipeline: {{build.link}}\nPoslední commit: {{commit.message}}Autor: {{commit.author}}"