Skip to content

Commit 42d3b33

Browse files
committed
Cleanup repo
- Move from `internal/tools` to `go tool` - Remove golangci-lint. It's unused, and needs to be properly integrated again, but until then it's dead code - Remove coveralls - it's unused - Move from goimports to gci - Fix protoc-gen-go being globally installed - Fix fuzz testing - Regenerate `pb/gostatsd.pb.go` with actually used version There is still a few things that are suboptimal: - Re-add linting - Fail the build if `pb/gostatsd.pb.go` is out of date - Move to `go test -fuzz` - Track coverage
1 parent da43711 commit 42d3b33

File tree

14 files changed

+259
-1931
lines changed

14 files changed

+259
-1931
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ jobs:
1414
with:
1515
# Go version needs to be the same in: CI config, README, Dockerfiles, and Makefile
1616
go-version: 1.24.2
17-
- name: Setup CI
18-
run: make tools
1917
- name: Test
2018
run: |
2119
make check-fmt
22-
make build-all
20+
make build
2321
make check
2422
make test-race
2523
make bench-race

.golangci.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
40.0.5
2+
------
3+
- Clean up a bunch of old stuff in the repo
4+
- Bumps some library versions
5+
16
40.0.4
27
------
38
- Emit latency metrics for forwarder requests

Makefile

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,24 @@ LAMBDA_PKG := github.com/atlassian/gostatsd/cmd/lambda-extension
1717
PROTOBUF_VERSION ?= 26.1
1818
PROJECT_ROOT_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
1919
TOOLS_DIR := $(PROJECT_ROOT_DIR)/.tools
20-
TOOLS_SRC_DIR := $(PROJECT_ROOT_DIR)/internal/tools
21-
ALL_TOOLS_PACKAGES := $(shell grep -E '(^|\s)_\s+\".*\"$$' < $(TOOLS_SRC_DIR)/tools.go | tr -d '"' | awk '{print $$2;}')
22-
ALL_TOOLS_COMMAND := $(sort $(addprefix $(TOOLS_DIR)/,$(notdir $(ALL_TOOLS_PACKAGES))))
23-
24-
.PHONY: tools
25-
tools: $(ALL_TOOLS_COMMAND)
26-
27-
$(ALL_TOOLS_COMMAND): $(TOOLS_DIR) $(TOOLS_SRC_DIR)/go.mod
28-
cd $(TOOLS_SRC_DIR) && CGO_ENABLED=0 go build -o $(TOOLS_DIR)/$(notdir $@) $(filter %/$(notdir $@),$(ALL_TOOLS_PACKAGES))
29-
30-
$(TOOLS_DIR):
31-
mkdir -p $(TOOLS_DIR)
3220

3321
.tools/bin/protoc:
22+
mkdir -p $(TOOLS_DIR)
3423
curl -L -O https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOBUF_VERSION)/protoc-$(PROTOBUF_VERSION)-linux-x86_64.zip
3524
unzip -o -d $(TOOLS_DIR) protoc-$(PROTOBUF_VERSION)-linux-x86_64.zip
3625
rm protoc-$(PROTOBUF_VERSION)-linux-x86_64.zip
3726

3827
pb/gostatsd.pb.go: pb/gostatsd.proto .tools/bin/protoc
39-
GOPATH="$(TOOLS_DIR):$(shell go env GOPATH)/bin" $(TOOLS_DIR)/bin/protoc --go_out=.\
40-
--go_opt=paths=source_relative $<
28+
@# protoc requires the protoc-gen-go plugin to be on the PATH. In order to maintain the
29+
@# usage of `go tool` and properly pinned versions, we install protoc-gen-go to a temporary
30+
@# directory, run protoc, then clean up the temporary directory.
31+
@#
32+
@# Note: go install will use the version defined in go.mod
33+
@TMPBIN=$(shell pwd)/$(shell mktemp -d protoc-gen-go.XXXXXXXXXX) ; \
34+
GOBIN=$$TMPBIN go install google.golang.org/protobuf/cmd/protoc-gen-go ; \
35+
PATH=$$TMPBIN:$$PATH $(TOOLS_DIR)/bin/protoc --go_out=. --go_opt=paths=source_relative $< ; \
36+
rm $$TMPBIN/protoc-gen-go ; \
37+
rmdir $$TMPBIN
4138

4239
build:
4340
CGO_ENABLED=$(CGO_ENABLED) GOEXPERIMENT=boringcrypto \
@@ -66,20 +63,23 @@ build-gostatsd-fips:
6663
build-lambda-fips:
6764
@$(MAKE) build PKG=$(LAMBDA_PKG) BINARY_NAME="lambda-extension" GOBUILD_OPTIONAL_FLAGS="-tags fips"
6865

69-
build-all: pb/gostatsd.pb.go tools
70-
7166
test-all: check-fmt cover test-race bench bench-race check
7267

7368
test-all-full: check-fmt cover test-race-full bench-full bench-race-full check
7469

75-
check-fmt: $(TOOLS_DIR)/goimports
76-
@# Since gofmt and goimports dont return 1 on changes, this !() stuff will trigger a build failure if theres any problems.
77-
! (gofmt -l -s $$(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./pb/*") | grep .)
78-
! ($(TOOLS_DIR)/goimports -l -local github.com/atlassian/gostatsd $$(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./pb/*") | grep .)
70+
check-fmt:
71+
@# This has three quirks:
72+
@# 1. gci reads from stdin if it's not a character device (ie, if it's a file). By redirecting /dev/null, it won't read from it
73+
@# 2. gofmt and gci don't return 1 for failure, so the `| ( ! grep . )` will return 1 if there is any output at all, failing the step
74+
@# 3. if there's actual errors being printed, we want the stderr to go to stdout so it triggers #2
75+
@go mod tidy
76+
@echo Checking for any changes...
77+
gofmt -d $$(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./pb/*") 2>&1 | ( ! grep .)
78+
go tool github.com/daixiang0/gci diff . -s standard -s default -s localmodule --skip-generated --skip-vendor </dev/null 2>&1 | ( ! grep .)
7979

8080
fix-fmt:
81-
gofmt -w -s $$(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./pb/*")
82-
go run golang.org/x/tools/cmd/goimports -w -l -local github.com/atlassian/gostatsd $$(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./pb/*")
81+
gofmt -w $$(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./pb/*")
82+
go tool github.com/daixiang0/gci diff . -s standard -s default -s localmodule --skip-generated --skip-vendor
8383

8484
test-full: pb/gostatsd.pb.go
8585
go test ./...
@@ -110,12 +110,8 @@ cover: pb/gostatsd.pb.go
110110
go tool cover -func=coverage.out
111111
go tool cover -html=coverage.out
112112

113-
coveralls: $(TOOLS_DIR)/goveralls pb/gostatsd.pb.go
114-
./cover.sh
115-
$(TOOLS_DIR)/goveralls -coverprofile=coverage.out -service=travis-ci
116-
117113
junit-test: build
118-
go test -short -v ./... | go-junit-report > test-report.xml
114+
go test -short -v ./... | go tool github.com/jstemmer/go-junit-report > test-report.xml
119115

120116
check: pb/gostatsd.pb.go
121117
go install ./cmd/gostatsd
@@ -125,9 +121,9 @@ check-all: pb/gostatsd.pb.go
125121
go install ./cmd/gostatsd
126122
go install ./cmd/tester
127123

128-
fuzz: $(TOOLS_DIR)/go-fuzz-build $(TOOLS_DIR)/go-fuzz
129-
$(TOOLS_DIR)/go-fuzz-build github.com/atlassian/gostatsd/pkg/statsd
130-
$(TOOLS_DIR)/go-fuzz -bin=./statsd-fuzz.zip -workdir=test_fixtures/lexer_fuzz
124+
fuzz:
125+
go tool github.com/dvyukov/go-fuzz/go-fuzz-build github.com/atlassian/gostatsd/internal/lexer
126+
go tool github.com/dvyukov/go-fuzz/go-fuzz -bin=./lexer-fuzz.zip -workdir=test_fixtures/lexer_fuzz
131127

132128
git-hook:
133129
cp dev/push-hook.sh .git/hooks/pre-push

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ gostatsd
33

44
[![Godoc](https://godoc.org/github.com/atlassian/gostatsd?status.svg)](https://godoc.org/github.com/atlassian/gostatsd)
55
[![Build Status](https://travis-ci.org/atlassian/gostatsd.svg?branch=master)](https://travis-ci.org/atlassian/gostatsd)
6-
[![Coverage Status](https://coveralls.io/repos/github/atlassian/gostatsd/badge.svg?branch=master)](https://coveralls.io/github/atlassian/gostatsd?branch=master)
76
[![GitHub tag](https://img.shields.io/github/tag/atlassian/gostatsd.svg?maxAge=86400)](https://github.com/atlassian/gostatsd)
87
[![Docker Pulls](https://img.shields.io/docker/pulls/atlassianlabs/gostatsd.svg)](https://hub.docker.com/r/atlassianlabs/gostatsd/)
98
[![Docker Stars](https://img.shields.io/docker/stars/atlassianlabs/gostatsd.svg)](https://hub.docker.com/r/atlassianlabs/gostatsd/)

go.mod

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ require (
1818
github.com/magiconair/properties v1.8.7
1919
github.com/pierrec/lz4/v4 v4.1.19
2020
github.com/sirupsen/logrus v1.9.0
21-
github.com/spf13/pflag v1.0.5
21+
github.com/spf13/pflag v1.0.6
2222
github.com/spf13/viper v1.17.0
2323
github.com/stretchr/testify v1.9.0
2424
github.com/tilinna/clock v1.1.0
2525
go.opentelemetry.io/proto/otlp v1.0.0
2626
go.uber.org/multierr v1.11.0
2727
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
28-
golang.org/x/net v0.35.0
29-
golang.org/x/sync v0.11.0
28+
golang.org/x/net v0.39.0
29+
golang.org/x/sync v0.13.0
3030
golang.org/x/time v0.3.0
31-
google.golang.org/protobuf v1.34.1
31+
google.golang.org/protobuf v1.36.5
3232
k8s.io/api v0.25.2
3333
k8s.io/apimachinery v0.25.2
3434
k8s.io/client-go v0.25.2
@@ -50,49 +50,63 @@ require (
5050
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.5 // indirect
5151
github.com/aws/aws-sdk-go-v2/service/sts v1.26.6 // indirect
5252
github.com/aws/smithy-go v1.22.0 // indirect
53-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
53+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
54+
github.com/daixiang0/gci v0.13.6 // indirect
5455
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
5556
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
57+
github.com/dvyukov/go-fuzz v0.0.0-20240924070022-e577bee5275c // indirect
58+
github.com/elazarl/go-bindata-assetfs v1.0.1 // indirect
5659
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
5760
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
5861
github.com/fsnotify/fsnotify v1.6.0 // indirect
59-
github.com/go-logr/logr v1.2.3 // indirect
62+
github.com/go-logr/logr v1.4.2 // indirect
6063
github.com/go-openapi/jsonpointer v0.19.5 // indirect
6164
github.com/go-openapi/jsonreference v0.19.5 // indirect
6265
github.com/go-openapi/swag v0.19.14 // indirect
6366
github.com/gogo/protobuf v1.3.2 // indirect
6467
github.com/golang/protobuf v1.5.4 // indirect
6568
github.com/google/gnostic v0.5.7-v3refs // indirect
66-
github.com/google/go-cmp v0.6.0 // indirect
69+
github.com/google/go-cmp v0.7.0 // indirect
6770
github.com/google/gofuzz v1.1.0 // indirect
6871
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
6972
github.com/hashicorp/hcl v1.0.0 // indirect
73+
github.com/hexops/gotextdiff v1.0.3 // indirect
7074
github.com/imdario/mergo v0.3.8 // indirect
75+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
7176
github.com/jmespath/go-jmespath v0.4.0 // indirect
7277
github.com/josharian/intern v1.0.0 // indirect
78+
github.com/jstemmer/go-junit-report v0.9.1 // indirect
7379
github.com/mailru/easyjson v0.7.6 // indirect
7480
github.com/mitchellh/mapstructure v1.5.0 // indirect
7581
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
7682
github.com/modern-go/reflect2 v1.0.2 // indirect
7783
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
78-
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
84+
github.com/onsi/ginkgo/v2 v2.23.3 // indirect
85+
github.com/onsi/gomega v1.36.3 // indirect
86+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
7987
github.com/pkg/errors v0.9.1 // indirect
8088
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
81-
github.com/rogpeppe/go-internal v1.10.0 // indirect
89+
github.com/rogpeppe/go-internal v1.14.1 // indirect
8290
github.com/sagikazarmark/locafero v0.3.0 // indirect
8391
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
8492
github.com/sourcegraph/conc v0.3.0 // indirect
85-
github.com/spf13/afero v1.10.0 // indirect
93+
github.com/spf13/afero v1.14.0 // indirect
8694
github.com/spf13/cast v1.5.1 // indirect
95+
github.com/spf13/cobra v1.9.1 // indirect
96+
github.com/stephens2424/writerset v1.0.2 // indirect
8797
github.com/subosito/gotenv v1.6.0 // indirect
8898
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 // indirect
99+
go.uber.org/atomic v1.9.0 // indirect
100+
go.uber.org/zap v1.24.0 // indirect
101+
golang.org/x/mod v0.24.0 // indirect
89102
golang.org/x/oauth2 v0.28.0 // indirect
90-
golang.org/x/sys v0.30.0 // indirect
91-
golang.org/x/term v0.29.0 // indirect
92-
golang.org/x/text v0.22.0 // indirect
93-
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
94-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
95-
google.golang.org/grpc v1.63.2 // indirect
103+
golang.org/x/sys v0.32.0 // indirect
104+
golang.org/x/term v0.31.0 // indirect
105+
golang.org/x/text v0.24.0 // indirect
106+
golang.org/x/tools v0.32.0 // indirect
107+
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 // indirect
108+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4 // indirect
109+
google.golang.org/grpc v1.71.0 // indirect
96110
gopkg.in/inf.v0 v0.9.1 // indirect
97111
gopkg.in/ini.v1 v1.67.0 // indirect
98112
gopkg.in/yaml.v2 v2.4.0 // indirect
@@ -104,3 +118,11 @@ require (
104118
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
105119
sigs.k8s.io/yaml v1.2.0 // indirect
106120
)
121+
122+
tool (
123+
github.com/daixiang0/gci
124+
github.com/dvyukov/go-fuzz/go-fuzz
125+
github.com/dvyukov/go-fuzz/go-fuzz-build
126+
github.com/jstemmer/go-junit-report
127+
google.golang.org/protobuf/cmd/protoc-gen-go
128+
)

0 commit comments

Comments
 (0)