Bring the repo up to the standard layout (closes #1)
check / check (push) Failing after 3s

Adds the canonical .gitignore, .dockerignore and .editorconfig; the
first two also name this repo's build output, root-anchored so
cmd/bsdaily/ stays in. The Dockerfile gains a lint phase on the
golangci-lint image already pinned and a test phase on the Debian Go
image with sqlite3 and zstd; the build stage copies a file from each,
so a plain docker build cannot skip them. script/lint and script/test
build their phase uncached and tagged; script/cibuild, script/docker
and the CI workflow are the canonical copies. Nothing installs
golangci-lint on the host. REPO_POLICIES.md is re-vendored.

.golangci.yml and the lint cleanup: #6
Judgement call: .gitignore adds Go build output, per the Go styleguide.

Model: opus-5-5
This commit is contained in:
2026-10-06 01:05:34 +00:00
parent e2dd090309
commit 699d980c92
14 changed files with 626 additions and 158 deletions
+34 -17
View File
@@ -1,9 +1,9 @@
# Lint stage
# golangci/golangci-lint:v2.12.2-alpine
# Lint phase. The linter is invoked directly rather than through `make
# lint` or `script/lint`, which are themselves a docker build and would
# recurse into a daemon that does not exist in a build step.
# golangci/golangci-lint:v2.12.2-alpine, 2026-06-28
FROM golangci/golangci-lint:v2.12.2-alpine@sha256:91b27804074a0bacea298707f016911e60cf0cdbc6c7bf5ccacb5f0606d18d60 AS lint
RUN apk add --no-cache make build-base
WORKDIR /src
# Copy go mod files first for better layer caching
@@ -13,22 +13,42 @@ RUN go mod download
# Copy source code
COPY . .
# Run formatting check and linter
RUN make fmt-check
RUN make lint
RUN golangci-lint run ./...
# Build stage
# golang:1.26.4-alpine
# Test phase, invoking `go test` directly for the same reason. -race
# needs cgo and so a C compiler, which the Debian Go image ships and the
# alpine one does not. The tool shells out to sqlite3, zstdmt and
# zstdcat, so tests that run it need them installed.
# golang:1.26.4-trixie, 2026-10-05
FROM golang:1.26.4-trixie@sha256:68b7145ec43d1820b9a56704554b53d1520aa2a15cb5233e374188a31b2a1bce AS test
RUN apt-get update \
&& apt-get install -y --no-install-recommends sqlite3 zstd \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go test -timeout 90s -race -cover ./... || \
{ echo "--- Rerunning with -v for details ---"; \
go test -timeout 90s -race -v ./...; exit 1; }
# Build stage. Nothing is wanted from either phase above; the copies
# are what make BuildKit build them first, so this stage cannot run
# unless lint and test passed. A plain `docker build .` builds only the
# last stage and what it depends on, so the runtime stage stays last.
# golang:1.26.4-alpine, 2026-06-28
FROM golang:1.26.4-alpine@sha256:3ad57304ad93bbec8548a0437ad9e06a455660655d9af011d58b993f6f615648 AS builder
# Depend on lint stage passing
COPY --from=lint /src/go.sum /dev/null
COPY --from=test /src/go.sum /dev/null
ARG VERSION=dev
# Install build deps plus the sqlite3 and zstd CLIs the tests/tool shell out to
RUN apk add --no-cache make build-base sqlite zstd
WORKDIR /src
# Copy go mod files first for better layer caching
@@ -38,14 +58,11 @@ RUN go mod download
# Copy source code
COPY . .
# Run tests
RUN make test
# Build (pure Go, no CGO required since we use modernc.org/sqlite)
RUN CGO_ENABLED=0 go build -o /bsdaily ./cmd/bsdaily
# Runtime stage
# alpine:3.21
# alpine:3.21, 2026-06-28
FROM alpine:3.21@sha256:48b0309ca019d89d40f670aa1bc06e426dc0931948452e8491e3d65087abc07d
# bsdaily shells out to sqlite3, zstdmt, zstdcat at runtime