Loading Makefile +112 −15 Original line number Diff line number Diff line .PHONY: all dupl build test docs all: build test # vim:ft=make # .PHONY: all build test clean install fmt fix vet lint sec security check \ help dupl docs ci BINARY_NAME=bulletin GO=go GOFLAGS=-v LDFLAGS=-w -s all: build check help: @echo "Available targets:" @echo " build - Build the binary" @echo " test - Run tests with coverage" @echo " coverage - Generate detailed HTML coverage report" @echo " fmt - Format code with gofmt" @echo " fix - Run various fixes on the code base." @echo " vet - Run go vet" @echo " lint - Run staticcheck linter" @echo " sec - Run security checks with gosec" @echo " security - Alias for sec" @echo " check - Run all checks (fmt, vet, lint, sec, test)" @echo " clean - Remove build artifacts" @echo " install - Install the binary to GOPATH/bin" @echo " docs - Generate docs" @echo " dupl - Find all duplicated code" @echo " all - Run check and build (default)" build: go generate ./... go install ./... @echo "Generating code..." $(GO) generate ./... @echo "Building..." $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) main.go @echo "Build complete: $(BINARY_NAME)" test: @echo "Running tests..." CGO_ENABLED=1 $(GO) test -v -race -coverprofile=coverage.out ./... @echo "" @echo "Tests complete" @echo "Overall coverage:" @$(GO) tool cover -func=coverage.out | tail -n 1 | sed 's/[\t ][\t ]*/ /g' coverage: test @echo "Generating coverage report..." @$(GO) tool cover -html=coverage.out -o coverage.html \ && $(GO) tool cover -func=coverage.out \ | awk '$$1 ~ /\.go:/ { \ split($$1, a, ":"); \ file = a[1]; \ cov[file] += $$3; \ cnt[file]++; \ } \ END { \ for (f in cov) { \ printf "%-50s %6.2f%%\n", f, cov[f]/cnt[f]; \ } \ } \ ' | sort \ && $(GO) tool cover -func=coverage.out | tail -n 1 | sed 's/[\t ][\t ]*/ /g' @echo "Coverage report generated: coverage.html" fmt: @echo "Checking code formatting..." @if [ -n "$$(gofmt -l .)" ]; then \ echo "The following files are not formatted:"; \ gofmt -l .; \ echo "Run 'gofmt -w .' to format them"; \ exit 1; \ fi @echo "Code formatting check passed" fix: @echo "Formatting code..." gofmt -w . go get -u ./... go tool | grep / | xargs -iX go get -tool X @echo "Code formatted" vet: @echo "Running go vet..." $(GO) vet ./... @echo "go vet passed" lint: @echo "Running staticcheck..." go tool staticcheck ./... @echo "staticcheck passed" sec: security security: @echo "Running security checks with gosec..." go tool gosec -exclude-dir=internal/gen -quiet ./... @echo "Security checks passed" check: fmt vet lint sec test @echo "All checks passed!" clean: @echo "Cleaning..." rm -f $(BINARY_NAME) rm -f coverage.out coverage.html @echo "Clean complete" install: build @echo "Installing $(BINARY_NAME)..." $(GO) install @echo "Installation complete" # Run all checks and build ci: build check dupl: find . -name '*.go' \ Loading @@ -12,16 +120,5 @@ dupl: > dupl.html xdg-open dupl.html test: @mkdir -p unit-test-output @go vet ./... @CGO_ENABLED=1 go test -cover -coverpkg=./... -coverprofile=unit-test-output/coverage.out -race ./... @go tool cover -html=unit-test-output/coverage.out @go tool cover -func unit-test-output/coverage.out \ | tail -1 | sed 's/[ \t(:][ \t(:]*/ /g;s/)/:/' docs: go tool golang.org/x/pkgsite/cmd/pkgsite -open # vim:ft=make # go.mod +48 −15 Original line number Diff line number Diff line module git.lyda.ie/pp/bulletin go 1.24.2 go 1.25.0 require ( github.com/adrg/xdg v0.5.3 Loading @@ -10,33 +10,48 @@ require ( github.com/golang-migrate/migrate/v4 v4.18.3 github.com/jmoiron/sqlx v1.4.0 github.com/rivo/tview v0.0.0-20250501113434-0c592cd31026 github.com/stretchr/testify v1.10.0 github.com/stretchr/testify v1.11.1 github.com/urfave/cli/v3 v3.3.3 golang.org/x/crypto v0.38.0 golang.org/x/sys v0.33.0 golang.org/x/term v0.32.0 golang.org/x/crypto v0.48.0 golang.org/x/sys v0.41.0 golang.org/x/term v0.40.0 modernc.org/sqlite v1.37.1 ) require ( cel.dev/expr v0.23.1 // indirect cel.dev/expr v0.24.0 // indirect cloud.google.com/go v0.121.2 // indirect cloud.google.com/go/auth v0.16.5 // indirect cloud.google.com/go/compute/metadata v0.8.0 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect github.com/anthropics/anthropic-sdk-go v1.22.0 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/bitfield/gotestdox v0.2.2 // indirect github.com/ccojocar/zxcvbn-go v1.0.4 // indirect github.com/cubicdaiya/gonp v1.0.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dnephin/pflag v1.0.7 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/fatih/color v1.18.0 // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/gdamore/encoding v1.0.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-sql-driver/mysql v1.9.2 // indirect github.com/google/cel-go v0.25.0 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/google/licensecheck v0.3.1 // indirect github.com/google/s2a-go v0.1.9 // indirect github.com/google/safehtml v0.0.3-0.20211026203422-d6f0e11a5516 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect github.com/googleapis/gax-go/v2 v2.15.0 // indirect github.com/gookit/color v1.6.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect Loading @@ -52,6 +67,7 @@ require ( github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mibk/dupl v1.0.0 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect github.com/openai/openai-go/v3 v3.18.0 // indirect github.com/pganalyze/pg_query_go/v6 v6.1.0 // indirect github.com/pingcap/errors v0.11.5-0.20240311024730-e056997136bb // indirect github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect Loading @@ -61,30 +77,45 @@ require ( github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/riza-io/grpc-go v0.2.0 // indirect github.com/securego/gosec/v2 v2.23.0 // indirect github.com/spf13/cobra v1.9.1 // indirect github.com/spf13/pflag v1.0.6 // indirect github.com/sqlc-dev/sqlc v1.29.1-0.20250428024728-34f8c1bad949 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect github.com/tetratelabs/wazero v1.9.0 // indirect github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07 // indirect github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect go.opentelemetry.io/otel v1.37.0 // indirect go.opentelemetry.io/otel/metric v1.37.0 // indirect go.opentelemetry.io/otel/trace v1.37.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect golang.org/x/mod v0.24.0 // indirect golang.org/x/net v0.40.0 // indirect golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect golang.org/x/mod v0.32.0 // indirect golang.org/x/net v0.49.0 // indirect golang.org/x/pkgsite v0.0.0-20250523174444-0e6de173c6b5 // indirect golang.org/x/sync v0.14.0 // indirect golang.org/x/text v0.25.0 // indirect golang.org/x/tools v0.33.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect google.golang.org/grpc v1.72.0 // indirect google.golang.org/protobuf v1.36.6 // indirect golang.org/x/sync v0.19.0 // indirect golang.org/x/text v0.34.0 // indirect golang.org/x/tools v0.41.0 // indirect google.golang.org/genai v1.45.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect google.golang.org/grpc v1.75.0 // indirect google.golang.org/protobuf v1.36.8 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/gotestsum v1.12.2 // indirect honnef.co/go/tools v0.7.0 // indirect modernc.org/libc v1.65.8 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.11.0 // indirect Loading @@ -93,7 +124,9 @@ require ( tool ( github.com/mibk/dupl github.com/securego/gosec/v2/cmd/gosec github.com/sqlc-dev/sqlc/cmd/sqlc golang.org/x/pkgsite/cmd/pkgsite gotest.tools/gotestsum honnef.co/go/tools/cmd/staticcheck ) go.sum +106 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
Makefile +112 −15 Original line number Diff line number Diff line .PHONY: all dupl build test docs all: build test # vim:ft=make # .PHONY: all build test clean install fmt fix vet lint sec security check \ help dupl docs ci BINARY_NAME=bulletin GO=go GOFLAGS=-v LDFLAGS=-w -s all: build check help: @echo "Available targets:" @echo " build - Build the binary" @echo " test - Run tests with coverage" @echo " coverage - Generate detailed HTML coverage report" @echo " fmt - Format code with gofmt" @echo " fix - Run various fixes on the code base." @echo " vet - Run go vet" @echo " lint - Run staticcheck linter" @echo " sec - Run security checks with gosec" @echo " security - Alias for sec" @echo " check - Run all checks (fmt, vet, lint, sec, test)" @echo " clean - Remove build artifacts" @echo " install - Install the binary to GOPATH/bin" @echo " docs - Generate docs" @echo " dupl - Find all duplicated code" @echo " all - Run check and build (default)" build: go generate ./... go install ./... @echo "Generating code..." $(GO) generate ./... @echo "Building..." $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) main.go @echo "Build complete: $(BINARY_NAME)" test: @echo "Running tests..." CGO_ENABLED=1 $(GO) test -v -race -coverprofile=coverage.out ./... @echo "" @echo "Tests complete" @echo "Overall coverage:" @$(GO) tool cover -func=coverage.out | tail -n 1 | sed 's/[\t ][\t ]*/ /g' coverage: test @echo "Generating coverage report..." @$(GO) tool cover -html=coverage.out -o coverage.html \ && $(GO) tool cover -func=coverage.out \ | awk '$$1 ~ /\.go:/ { \ split($$1, a, ":"); \ file = a[1]; \ cov[file] += $$3; \ cnt[file]++; \ } \ END { \ for (f in cov) { \ printf "%-50s %6.2f%%\n", f, cov[f]/cnt[f]; \ } \ } \ ' | sort \ && $(GO) tool cover -func=coverage.out | tail -n 1 | sed 's/[\t ][\t ]*/ /g' @echo "Coverage report generated: coverage.html" fmt: @echo "Checking code formatting..." @if [ -n "$$(gofmt -l .)" ]; then \ echo "The following files are not formatted:"; \ gofmt -l .; \ echo "Run 'gofmt -w .' to format them"; \ exit 1; \ fi @echo "Code formatting check passed" fix: @echo "Formatting code..." gofmt -w . go get -u ./... go tool | grep / | xargs -iX go get -tool X @echo "Code formatted" vet: @echo "Running go vet..." $(GO) vet ./... @echo "go vet passed" lint: @echo "Running staticcheck..." go tool staticcheck ./... @echo "staticcheck passed" sec: security security: @echo "Running security checks with gosec..." go tool gosec -exclude-dir=internal/gen -quiet ./... @echo "Security checks passed" check: fmt vet lint sec test @echo "All checks passed!" clean: @echo "Cleaning..." rm -f $(BINARY_NAME) rm -f coverage.out coverage.html @echo "Clean complete" install: build @echo "Installing $(BINARY_NAME)..." $(GO) install @echo "Installation complete" # Run all checks and build ci: build check dupl: find . -name '*.go' \ Loading @@ -12,16 +120,5 @@ dupl: > dupl.html xdg-open dupl.html test: @mkdir -p unit-test-output @go vet ./... @CGO_ENABLED=1 go test -cover -coverpkg=./... -coverprofile=unit-test-output/coverage.out -race ./... @go tool cover -html=unit-test-output/coverage.out @go tool cover -func unit-test-output/coverage.out \ | tail -1 | sed 's/[ \t(:][ \t(:]*/ /g;s/)/:/' docs: go tool golang.org/x/pkgsite/cmd/pkgsite -open # vim:ft=make #
go.mod +48 −15 Original line number Diff line number Diff line module git.lyda.ie/pp/bulletin go 1.24.2 go 1.25.0 require ( github.com/adrg/xdg v0.5.3 Loading @@ -10,33 +10,48 @@ require ( github.com/golang-migrate/migrate/v4 v4.18.3 github.com/jmoiron/sqlx v1.4.0 github.com/rivo/tview v0.0.0-20250501113434-0c592cd31026 github.com/stretchr/testify v1.10.0 github.com/stretchr/testify v1.11.1 github.com/urfave/cli/v3 v3.3.3 golang.org/x/crypto v0.38.0 golang.org/x/sys v0.33.0 golang.org/x/term v0.32.0 golang.org/x/crypto v0.48.0 golang.org/x/sys v0.41.0 golang.org/x/term v0.40.0 modernc.org/sqlite v1.37.1 ) require ( cel.dev/expr v0.23.1 // indirect cel.dev/expr v0.24.0 // indirect cloud.google.com/go v0.121.2 // indirect cloud.google.com/go/auth v0.16.5 // indirect cloud.google.com/go/compute/metadata v0.8.0 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect github.com/anthropics/anthropic-sdk-go v1.22.0 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/bitfield/gotestdox v0.2.2 // indirect github.com/ccojocar/zxcvbn-go v1.0.4 // indirect github.com/cubicdaiya/gonp v1.0.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dnephin/pflag v1.0.7 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/fatih/color v1.18.0 // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/gdamore/encoding v1.0.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-sql-driver/mysql v1.9.2 // indirect github.com/google/cel-go v0.25.0 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/google/licensecheck v0.3.1 // indirect github.com/google/s2a-go v0.1.9 // indirect github.com/google/safehtml v0.0.3-0.20211026203422-d6f0e11a5516 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect github.com/googleapis/gax-go/v2 v2.15.0 // indirect github.com/gookit/color v1.6.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect Loading @@ -52,6 +67,7 @@ require ( github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mibk/dupl v1.0.0 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect github.com/openai/openai-go/v3 v3.18.0 // indirect github.com/pganalyze/pg_query_go/v6 v6.1.0 // indirect github.com/pingcap/errors v0.11.5-0.20240311024730-e056997136bb // indirect github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect Loading @@ -61,30 +77,45 @@ require ( github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/riza-io/grpc-go v0.2.0 // indirect github.com/securego/gosec/v2 v2.23.0 // indirect github.com/spf13/cobra v1.9.1 // indirect github.com/spf13/pflag v1.0.6 // indirect github.com/sqlc-dev/sqlc v1.29.1-0.20250428024728-34f8c1bad949 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect github.com/tetratelabs/wazero v1.9.0 // indirect github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07 // indirect github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect go.opentelemetry.io/otel v1.37.0 // indirect go.opentelemetry.io/otel/metric v1.37.0 // indirect go.opentelemetry.io/otel/trace v1.37.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect golang.org/x/mod v0.24.0 // indirect golang.org/x/net v0.40.0 // indirect golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect golang.org/x/mod v0.32.0 // indirect golang.org/x/net v0.49.0 // indirect golang.org/x/pkgsite v0.0.0-20250523174444-0e6de173c6b5 // indirect golang.org/x/sync v0.14.0 // indirect golang.org/x/text v0.25.0 // indirect golang.org/x/tools v0.33.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect google.golang.org/grpc v1.72.0 // indirect google.golang.org/protobuf v1.36.6 // indirect golang.org/x/sync v0.19.0 // indirect golang.org/x/text v0.34.0 // indirect golang.org/x/tools v0.41.0 // indirect google.golang.org/genai v1.45.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect google.golang.org/grpc v1.75.0 // indirect google.golang.org/protobuf v1.36.8 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/gotestsum v1.12.2 // indirect honnef.co/go/tools v0.7.0 // indirect modernc.org/libc v1.65.8 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.11.0 // indirect Loading @@ -93,7 +124,9 @@ require ( tool ( github.com/mibk/dupl github.com/securego/gosec/v2/cmd/gosec github.com/sqlc-dev/sqlc/cmd/sqlc golang.org/x/pkgsite/cmd/pkgsite gotest.tools/gotestsum honnef.co/go/tools/cmd/staticcheck )