Run go test inside Docker build instead of separate docker run step
Some checks failed
Deploy to NAS / deploy (push) Failing after 3m0s
Some checks failed
Deploy to NAS / deploy (push) Failing after 3m0s
Bind-mounted source causes Go module resolution issues in the runner container. Tests now run as a Dockerfile layer (after go mod download, before SPA inject + go build) — no bind mount, no extra step needed. A failed test aborts the build and the deploy never happens. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -25,14 +25,6 @@ jobs:
|
||||
- name: Write .env
|
||||
run: printf 'DB_PASSWORD=%s\n' '${{ secrets.DB_PASSWORD }}' > ${{ vars.DEPLOY_DIR }}/.env
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
docker run --rm \
|
||||
-v ${{ vars.DEPLOY_DIR }}:/src \
|
||||
-w /src/backend \
|
||||
golang:1.25-alpine \
|
||||
go test ./...
|
||||
|
||||
- name: Build & Deploy
|
||||
run: docker compose -f ${{ vars.DEPLOY_DIR }}/docker-compose.yml up --build -d
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ WORKDIR /app
|
||||
COPY backend/go.mod backend/go.sum ./
|
||||
RUN go mod download
|
||||
COPY backend/ ./
|
||||
RUN go test ./...
|
||||
# Inject built SPA into embed path
|
||||
COPY --from=webapp-builder /webapp/dist ./internal/api/webapp/
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /server ./cmd/server
|
||||
|
||||
Reference in New Issue
Block a user