ci: optimize pipeline with image retagging and conditional tests
This commit is contained in:
1 parent
86d2cd0138
commit
bcb3c702ff
5 files changed
+272
-61
No files matched your search
+19
-6
@@ -4,11 +4,17 @@
|
||||
FROM node:22-alpine AS frontend-builder
|
||||
WORKDIR /app/frontend
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm install --no-audit --no-fund
|
||||
RUN --mount=type=cache,target=/root/.npm npm install --no-audit --no-fund
|
||||
COPY frontend/ ./
|
||||
# Version shown in the header: the git tag for releases (set by CI), otherwise "<package version>-dev"
|
||||
ARG APP_VERSION=""
|
||||
RUN npx tsc --noEmit && npm run lint && npm run test:run && APP_VERSION="${APP_VERSION}" npm run build
|
||||
ARG SKIP_TESTS=0
|
||||
RUN if [ "$SKIP_TESTS" != "1" ]; then \
|
||||
npx tsc --noEmit && npm run lint && npm run test:run; \
|
||||
else \
|
||||
echo "Skipping frontend tests (SKIP_TESTS=1)"; \
|
||||
fi && \
|
||||
APP_VERSION="${APP_VERSION}" npm run build
|
||||
|
||||
# ==============================================================================
|
||||
# Stage 2: Go Backend Lint, Unit Tests & Binary Build (Cached Go module & sqlite layer)
|
||||
@@ -19,7 +25,8 @@ RUN apk add --no-cache git ca-certificates
|
||||
|
||||
# Cache Go modules & pre-compile heavy dependencies (modernc.org/sqlite) in a dedicated layer
|
||||
COPY go.mod ./
|
||||
RUN go get github.com/go-chi/chi/v5@v5.2.0 \
|
||||
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
|
||||
go get github.com/go-chi/chi/v5@v5.2.0 \
|
||||
github.com/go-chi/cors@v1.2.1 \
|
||||
github.com/golang-jwt/jwt/v5@v5.2.1 \
|
||||
github.com/gorilla/websocket@v1.5.3 \
|
||||
@@ -38,10 +45,16 @@ COPY cmd/ ./cmd/
|
||||
COPY internal/ ./internal/
|
||||
COPY --from=frontend-builder /app/frontend/dist ./cmd/server/dist
|
||||
|
||||
ARG SKIP_TESTS=0
|
||||
# Run go mod tidy, static analysis (go vet), unit tests (go test), and compile final binary
|
||||
RUN go mod tidy && \
|
||||
CGO_ENABLED=0 go vet ./... && \
|
||||
CGO_ENABLED=0 go test -v ./... && \
|
||||
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
|
||||
go mod tidy && \
|
||||
if [ "$SKIP_TESTS" != "1" ]; then \
|
||||
CGO_ENABLED=0 go vet ./... && \
|
||||
CGO_ENABLED=0 go test -v ./...; \
|
||||
else \
|
||||
echo "Skipping backend tests (SKIP_TESTS=1)"; \
|
||||
fi && \
|
||||
CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/mindsift ./cmd/server
|
||||
|
||||
# ==============================================================================
|
||||
|
||||
Reference in new issue
Block a user