diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index d713ebc..4c315a4 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -12,6 +12,8 @@ jobs: - uses: actions/setup-go@v2 with: go-version: '1.18' + - name: Checkout peers + run: make ci_checkout_peers CLONE_DEPTH=2 - name: Run coverage run: make calculate_coverage diff --git a/Makefile b/Makefile index 7a8ab8b..e1f188d 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,11 @@ -GOHOME ?= ${HOME} -GOPATH ?= ${GOHOME} -GOBIN ?= ${GOPATH}/bin - -ZZZGO = $(wildcard ../xop*-go/*.zzzgo ../xop*-go/*/*.zzzgo ../xop*-go/*/*/*.zzzgo) -ZZZGENERATED = $(patsubst %.zzzgo, %.go, $(ZZZGO)) -PB = xopproto/ingest.pb.go xopproto/ingest_grpc.pb.go -TOOLS = ${GOBIN}/gofumpt ${GOBIN}/goimports ${GOBIN}/enumer -TEST_ONLY ?= - +ME = xop-go RELATED = xopresty-go xopotel-go -all: $(ZZZGENERATED) $(PB) .gitattributes - go generate ./... - go build ./... - for i in $(RELATED); do (echo $$i ...; cd ../$$i && go generate ./... && go build ./...); done - +include Makefile.common ci_checkout_peers:; - branch="$${GITHUB_REF##*/}"; for i in $(RELATED); do (cd ..; git clone https://github.com/xoplog/$$i --depth 1 -b $$branch || git clone https://github.com/xoplog/$$i --depth 1); done - -.gitattributes: $(ZZZGENERATED) - echo '*.zzzgo linguist-language=Go' > $@ - echo 'doc.go linguist-documentation' >> $@ - echo '*.md linguist-documentation' >> $@ - echo '*.pb.go linguist-generated' >> $@ - for i in $(ZZZGENERATED); do echo "$$i linguist-generated" >> $@; done + branch="$${GITHUB_REF##*/}"; for i in $(RELATED); do (cd ..; git clone https://github.com/xoplog/$$i --depth $(CLONE_DEPTH) -b $$branch || git clone https://github.com/xoplog/$$i --depth $(CLONE_DEPTH)); done test: $(ZZZGENERATED) testadjuster go generate ./... @@ -49,23 +29,6 @@ citest: XOPLEVEL_xoptestutil=warn XOPLEVEL_foo=debug go test -tags xoptesting ./xoptest/xoptestutil -run TestAdjuster -count 1 XOPLEVEL_xoptestutil=debug XOPLEVEL_foo=warn go test -tags xoptesting ./xoptest/xoptestutil -run TestAdjuster -count 1 -${GOBIN}/gofumpt:; - go install mvdan.cc/gofumpt@latest - -${GOBIN}/goimports:; - go install golang.org/x/tools/cmd/goimports@latest - -${GOBIN}/enumer:; - go install github.com/dmarkham/enumer@latest - -%.go : %.zzzgo tools/xopzzz/xopzzz.go $(TOOLS) Makefile - go run tools/xopzzz/xopzzz.go < $< > $@.tmp - -chmod +w $@ - gofumpt -w $@.tmp - goimports -w $@.tmp - -mv $@.tmp $@ - -chmod -w $@ - calculate_coverage: echo "mode: atomic" > coverage.txt for d in $$(go list ./...); do \ @@ -84,21 +47,6 @@ calculate_coverage: egrep -v 'xoptestutil/|xopoteltest/' > coverage.txt.tmp mv coverage.txt.tmp coverage.txt -coverage: calculate_coverage - go tool cover -html=coverage.txt - -golanglint: - # binary will be $(go env GOPATH)/bin/golangci-lint - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.52.2 - golangci-lint --version - -lint:; - golangci-lint run - -misspell:; - go install github.com/client9/misspell/cmd/misspell@latest - misspell -w `find . -name \*.md` - OTEL_TAG="v1.12.0" ../opentelemetry-specification: diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 0000000..7250059 --- /dev/null +++ b/Makefile.common @@ -0,0 +1,55 @@ + +GOHOME ?= ${HOME} +GOPATH ?= ${GOHOME} +GOBIN ?= ${GOPATH}/bin + +ZZZGO = $(wildcard ../xop*-go/*.zzzgo ../xop*-go/*/*.zzzgo ../xop*-go/*/*/*.zzzgo) +ZZZGENERATED = $(patsubst %.zzzgo, %.go, $(ZZZGO)) +PB = xopproto/ingest.pb.go xopproto/ingest_grpc.pb.go +TOOLS = ${GOBIN}/gofumpt ${GOBIN}/goimports ${GOBIN}/enumer +TEST_ONLY ?= +CLONE_DEPTH ?= 1 + +all: $(ZZZGENERATED) $(PB) .gitattributes + go generate ./... + go build ./... + for i in $(RELATED); do (echo $$i ...; cd ../$$i && go generate ./... && go build ./...); done + +.gitattributes: $(ZZZGENERATED) + echo '*.zzzgo linguist-language=Go' > $@ + echo 'doc.go linguist-documentation' >> $@ + echo '*.md linguist-documentation' >> $@ + echo '*.pb.go linguist-generated' >> $@ + for i in $(ZZZGENERATED); do echo "$$i linguist-generated" >> $@; done + +${GOBIN}/gofumpt:; + go install mvdan.cc/gofumpt@latest + +${GOBIN}/goimports:; + go install golang.org/x/tools/cmd/goimports@latest + +${GOBIN}/enumer:; + go install github.com/dmarkham/enumer@latest + +%.go : %.zzzgo tools/xopzzz/xopzzz.go $(TOOLS) Makefile + go run tools/xopzzz/xopzzz.go < $< > $@.tmp + -chmod +w $@ + gofumpt -w $@.tmp + goimports -w $@.tmp + -mv $@.tmp $@ + -chmod -w $@ + +coverage: calculate_coverage + go tool cover -html=coverage.txt + +golanglint: + # binary will be $(go env GOPATH)/bin/golangci-lint + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.52.2 + golangci-lint --version + +lint:; + golangci-lint run + +misspell:; + go install github.com/client9/misspell/cmd/misspell@latest + misspell -w `find . -name \*.md` diff --git a/Makefile.peer b/Makefile.peer new file mode 100644 index 0000000..3eaf8c6 --- /dev/null +++ b/Makefile.peer @@ -0,0 +1,25 @@ + +include Makefile.common + +test: $(ZZZGENERATED) testadjuster + go generate ./... + go test -tags xoptesting ./... -failfast $(TEST_ONLY) + go test -tags xoptesting -race ./... -failfast $(TEST_ONLY) + +citest: + go test ./... -failfast + go test -race ./... -failfast + +calculate_coverage: + echo "mode: atomic" > coverage.txt + for d in $$(go list ./...); do \ + go test -race -covermode=atomic -coverprofile=profile.out -coverpkg=github.com/xoplog/$(ME)/... $$d; \ + if [ -f profile.out ]; then \ + grep -v ^mode profile.out >> coverage.txt; \ + rm profile.out; \ + fi; \ + done + grep -v '\.pb.go:' coverage.txt | \ + egrep -v 'xoptestutil/|xopoteltest/' > coverage.txt.tmp + mv coverage.txt.tmp coverage.txt +