Improve test infrastructure and organization
- Add test-runner stage to Dockerfile for isolated test execution - Refactor Makefile test targets: separate unit and integration tests - Unit tests now run on host (fast, no containers required) - Integration tests run in containers matching production environment - Add dedicated 'tests' service to docker-compose.yml - Update test-integration target to use containerized test runner - Improve service health checks and wait conditions - Add test environment variables for consistent testing This change separates unit tests (fast, local) from integration tests (full environment, containerized) for better developer experience and more reliable CI/CD pipelines.
This commit is contained in:
+23
@@ -38,6 +38,29 @@ RUN npm run build:ts
|
||||
# Build the application
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./cmd/server
|
||||
|
||||
# Test runner stage - includes Go runtime and test dependencies
|
||||
# This stage is ONLY used for running tests, never deployed to production
|
||||
FROM golang:1.25-alpine AS test-runner
|
||||
|
||||
RUN apk --no-cache add ca-certificates curl
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy everything from builder (includes compiled binary, source code, and dependencies)
|
||||
COPY --from=builder /app ./
|
||||
|
||||
# Install kepubify for conversion tests
|
||||
RUN wget -O /usr/bin/kepubify https://github.com/pgaskin/kepubify/releases/latest/download/kepubify-linux-64bit \
|
||||
&& chmod +x /usr/bin/kepubify
|
||||
|
||||
# Set test environment variables
|
||||
ENV TEST_MODE=true
|
||||
ENV RATE_LIMIT_ENABLED=false
|
||||
ENV REQUESTS_PER_MINUTE=1000
|
||||
|
||||
# Default command for running tests
|
||||
CMD ["go", "test", "./cmd/server/tests", "-v", "-timeout", "5m"]
|
||||
|
||||
# Final stage
|
||||
FROM alpine:latest
|
||||
|
||||
|
||||
Reference in New Issue
Block a user