From 2feda42e447efac5bfe39bb226d7025af73c0947 Mon Sep 17 00:00:00 2001 From: Bartlomiej Plotka Date: Tue, 13 Jun 2023 15:54:49 +0200 Subject: [PATCH] Fixed README & CHANGELOG; Added fmt makefile command (+bingo) for easier contributions. (#1289) * Fixed README; Added fmt command for easier contributions. Signed-off-by: bwplotka * Updated golint. Signed-off-by: bwplotka * Update Makefile Co-authored-by: Kemal Akkoyun Signed-off-by: Bartlomiej Plotka --------- Signed-off-by: bwplotka Signed-off-by: Bartlomiej Plotka Co-authored-by: Kemal Akkoyun --- .bingo/.gitignore | 13 +++++++++++++ .bingo/README.md | 14 ++++++++++++++ .bingo/Variables.mk | 25 +++++++++++++++++++++++++ .bingo/go.mod | 1 + .bingo/goimports.mod | 5 +++++ .bingo/goimports.sum | 6 ++++++ .bingo/variables.env | 12 ++++++++++++ .github/workflows/go.yml | 3 --- .github/workflows/golangci-lint.yml | 5 +++-- CHANGELOG.md | 6 ++---- Makefile | 6 ++++++ README.md | 6 +++--- prometheus/desc.go | 4 ++-- tutorial/whatsup/main.go | 3 ++- tutorial/whatsup/reference/main.go | 3 ++- 15 files changed, 96 insertions(+), 16 deletions(-) create mode 100644 .bingo/.gitignore create mode 100644 .bingo/README.md create mode 100644 .bingo/Variables.mk create mode 100644 .bingo/go.mod create mode 100644 .bingo/goimports.mod create mode 100644 .bingo/goimports.sum create mode 100644 .bingo/variables.env diff --git a/.bingo/.gitignore b/.bingo/.gitignore new file mode 100644 index 0000000..9efccf6 --- /dev/null +++ b/.bingo/.gitignore @@ -0,0 +1,13 @@ + +# Ignore everything +* + +# But not these files: +!.gitignore +!*.mod +!*.sum +!README.md +!Variables.mk +!variables.env + +*tmp.mod diff --git a/.bingo/README.md b/.bingo/README.md new file mode 100644 index 0000000..7a5c2d4 --- /dev/null +++ b/.bingo/README.md @@ -0,0 +1,14 @@ +# Project Development Dependencies. + +This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by https://github.com/bwplotka/bingo. + +* Run `bingo get` to install all tools having each own module file in this directory. +* Run `bingo get ` to install that have own module file in this directory. +* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $() variable where is the .bingo/.mod. +* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool. +* For go: Import `.bingo/variables.go` to for variable names. +* See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies. + +## Requirements + +* Go 1.14+ diff --git a/.bingo/Variables.mk b/.bingo/Variables.mk new file mode 100644 index 0000000..9c12d9e --- /dev/null +++ b/.bingo/Variables.mk @@ -0,0 +1,25 @@ +# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.8. DO NOT EDIT. +# All tools are designed to be build inside $GOBIN. +BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +GOPATH ?= $(shell go env GOPATH) +GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin +GO ?= $(shell which go) + +# Below generated variables ensure that every time a tool under each variable is invoked, the correct version +# will be used; reinstalling only if needed. +# For example for goimports variable: +# +# In your main Makefile (for non array binaries): +# +#include .bingo/Variables.mk # Assuming -dir was set to .bingo . +# +#command: $(GOIMPORTS) +# @echo "Running goimports" +# @$(GOIMPORTS) +# +GOIMPORTS := $(GOBIN)/goimports-v0.9.3 +$(GOIMPORTS): $(BINGO_DIR)/goimports.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/goimports-v0.9.3" + @cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=goimports.mod -o=$(GOBIN)/goimports-v0.9.3 "golang.org/x/tools/cmd/goimports" + diff --git a/.bingo/go.mod b/.bingo/go.mod new file mode 100644 index 0000000..610249a --- /dev/null +++ b/.bingo/go.mod @@ -0,0 +1 @@ +module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files. \ No newline at end of file diff --git a/.bingo/goimports.mod b/.bingo/goimports.mod new file mode 100644 index 0000000..e989669 --- /dev/null +++ b/.bingo/goimports.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.20 + +require golang.org/x/tools v0.9.3 // cmd/goimports diff --git a/.bingo/goimports.sum b/.bingo/goimports.sum new file mode 100644 index 0000000..5a2e605 --- /dev/null +++ b/.bingo/goimports.sum @@ -0,0 +1,6 @@ +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM= +golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= diff --git a/.bingo/variables.env b/.bingo/variables.env new file mode 100644 index 0000000..7d2f9f5 --- /dev/null +++ b/.bingo/variables.env @@ -0,0 +1,12 @@ +# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.8. DO NOT EDIT. +# All tools are designed to be build inside $GOBIN. +# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk. +GOBIN=${GOBIN:=$(go env GOBIN)} + +if [ -z "$GOBIN" ]; then + GOBIN="$(go env GOPATH)/bin" +fi + + +GOIMPORTS="${GOBIN}/goimports-v0.9.3" + diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 0432d61..20b61d4 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -37,9 +37,6 @@ jobs: env: CI: true - - name: Run lint - run: make lint - - name: Run style and unused if: ${{ matrix.go_version == '1.20' }} run: make style unused \ No newline at end of file diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index b199485..29e1f56 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -32,6 +32,7 @@ jobs: run: sudo apt-get update && sudo apt-get -y install libsnmp-dev if: github.repository == 'prometheus/snmp_exporter' - name: Lint - uses: golangci/golangci-lint-action@v3.2.0 + uses: golangci/golangci-lint-action@v3.4.0 with: - version: v1.45.2 + args: --verbose + version: v1.51.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b97d30..b56755b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,11 @@ ## Unreleased -## 1.15.0 / 2023-04-13 - -## What's Changed +## 1.15.1 / 2023-05-3 * [BUGFIX] Fixed promhttp.Instrument* handlers wrongly trying to attach exemplar to unsupported metrics (e.g. summary), \ causing panics #1253 -## What's Changed +## 1.15.0 / 2023-04-13 * [BUGFIX] Fix issue with atomic variables on ppc64le #1171 * [BUGFIX] Support for multiple samples within same metric #1181 diff --git a/Makefile b/Makefile index 1236816..490d0be 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +include .bingo/Variables.mk include Makefile.common .PHONY: test @@ -26,3 +27,8 @@ generate-go-collector-test-files: docker run --rm -v $(PWD):/workspace -w /workspace golang:$$GO_VERSION go run prometheus/gen_go_collector_metrics_set.go; \ mv -f go_collector_metrics* prometheus; \ done + +.PHONY: fmt +fmt: common-format + $(GOIMPORTS) -local github.com/prometheus/client_golang -w . + \ No newline at end of file diff --git a/README.md b/README.md index 63a300e..85d98f4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Prometheus Go client library -[![CI](https://github.com/prometheus/client_golang/actions/workflows/ci.yml/badge.svg)](https://github.com/prometheus/client_golang/actions/workflows/ci.yml) -[[![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/client_golang)](https://goreportcard.com/report/github.com/prometheus/client_golang) +[![CI](https://github.com/prometheus/client_golang/actions/workflows/go.yml/badge.svg)](https://github.com/prometheus/client_golang/actions/workflows/ci.yml) +[![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/client_golang)](https://goreportcard.com/report/github.com/prometheus/client_golang) [![Go Reference](https://pkg.go.dev/badge/github.com/prometheus/client_golang.svg)](https://pkg.go.dev/github.com/prometheus/client_golang) [![Slack](https://img.shields.io/badge/join%20slack-%23prometheus--client_golang-brightgreen.svg)](https://slack.cncf.io/) @@ -79,7 +79,7 @@ To cut a minor version: 3. Change the `VERSION` file. 4. Update `CHANGELOG` (only user-impacting changes to mention). 5. Create PR, and get it reviewed. -6. Once merged, create a release with the `release-.` tag on GitHub with the ` / ` title. +6. Once merged, create a release with the `release-.` tag on GitHub with the `` title. 7. Announce on the prometheus-announce mailing list, slack and Twitter. 8. Merge the release branch back to the `main` using the "merge without squashing" approach (!). diff --git a/prometheus/desc.go b/prometheus/desc.go index 1233154..deedc2d 100644 --- a/prometheus/desc.go +++ b/prometheus/desc.go @@ -18,12 +18,12 @@ import ( "sort" "strings" - "github.com/prometheus/client_golang/prometheus/internal" - "github.com/cespare/xxhash/v2" dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/model" "google.golang.org/protobuf/proto" + + "github.com/prometheus/client_golang/prometheus/internal" ) // Desc is the descriptor used by every Prometheus Metric. It is essentially diff --git a/tutorial/whatsup/main.go b/tutorial/whatsup/main.go index fa044e4..b4252f3 100644 --- a/tutorial/whatsup/main.go +++ b/tutorial/whatsup/main.go @@ -31,11 +31,12 @@ import ( "github.com/efficientgo/core/errcapture" "github.com/efficientgo/core/errors" "github.com/oklog/run" + "github.com/prometheus/common/model" + "github.com/prometheus/client_golang/api" v1 "github.com/prometheus/client_golang/api/prometheus/v1" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/tutorial/internal" - "github.com/prometheus/common/model" ) func main() { diff --git a/tutorial/whatsup/reference/main.go b/tutorial/whatsup/reference/main.go index abd143f..3c41151 100644 --- a/tutorial/whatsup/reference/main.go +++ b/tutorial/whatsup/reference/main.go @@ -31,6 +31,8 @@ import ( "github.com/efficientgo/core/errcapture" "github.com/efficientgo/core/errors" "github.com/oklog/run" + "github.com/prometheus/common/model" + "github.com/prometheus/client_golang/api" v1 "github.com/prometheus/client_golang/api/prometheus/v1" "github.com/prometheus/client_golang/prometheus" @@ -38,7 +40,6 @@ import ( "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/tutorial/internal" - "github.com/prometheus/common/model" ) func main() {