From 516aa3dab2ec149251a3a84cca64e5a6db5eaf6f Mon Sep 17 00:00:00 2001 From: prombot Date: Sat, 8 Jan 2022 00:02:26 +0000 Subject: [PATCH] Update common Prometheus files Signed-off-by: prombot --- .circleci/config.yml | 79 ++++++++++++++--------------- .github/workflows/golangci-lint.yml | 31 +++++++++++ Makefile.common | 14 +++-- 3 files changed, 78 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/golangci-lint.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 3409dfb6..79019c06 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,59 +1,54 @@ --- version: 2.1 - orbs: - prometheus: prometheus/prometheus@0.11.0 - + prometheus: prometheus/prometheus@0.15.0 executors: # Whenever the Go version is updated here, .promu.yml should also be updated. golang: docker: - - image: circleci/golang:1.17 + - image: circleci/golang:1.17 golang_memcached: docker: - - image: circleci/golang:1.17 - - image: memcached - + - image: circleci/golang:1.17 + - image: memcached jobs: test: executor: golang_memcached - steps: - - prometheus/setup_environment - - setup_remote_docker - - run: make - - prometheus/store_artifact: - file: memcached_exporter - - run: git diff --exit-code - + - prometheus/setup_environment + - setup_remote_docker + - run: make + - prometheus/store_artifact: + file: memcached_exporter + - run: git diff --exit-code workflows: version: 2 memcached_exporter: jobs: - - test: - filters: - tags: - only: /.*/ - - prometheus/build: - name: build - filters: - tags: - only: /.*/ - - prometheus/publish_master: - context: org-context - requires: - - test - - build - filters: - branches: - only: master - - prometheus/publish_release: - context: org-context - requires: - - test - - build - filters: - tags: - only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ - branches: - ignore: /.*/ + - test: + filters: + tags: + only: /.*/ + - prometheus/build: + name: build + filters: + tags: + only: /.*/ + - prometheus/publish_master: + context: org-context + requires: + - test + - build + filters: + branches: + only: master + - prometheus/publish_release: + context: org-context + requires: + - test + - build + filters: + tags: + only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ + branches: + ignore: /.*/ diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000..f96c76a6 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,31 @@ +name: golangci-lint +on: + push: + paths: + - "go.sum" + - "go.mod" + - "**.go" + - "scripts/errcheck_excludes.txt" + - ".github/workflows/golangci-lint.yml" + - ".golangci.yml" + pull_request: + paths: + - "go.sum" + - "go.mod" + - "**.go" + - "scripts/errcheck_excludes.txt" + - ".github/workflows/golangci-lint.yml" + - ".golangci.yml" + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.42.0 diff --git a/Makefile.common b/Makefile.common index a1b1ca40..bf7304e5 100644 --- a/Makefile.common +++ b/Makefile.common @@ -78,17 +78,23 @@ ifneq ($(shell which gotestsum),) endif endif -PROMU_VERSION ?= 0.12.0 +PROMU_VERSION ?= 0.13.0 PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v1.39.0 +GOLANGCI_LINT_VERSION ?= v1.42.0 # golangci-lint only supports linux, darwin and windows platforms on i386/amd64. # windows isn't included here because of the path separator being different. ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386)) - GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint + # If we're in CI and there is an Actions file, that means the linter + # is being run in Actions, so we don't need to run it here. + ifeq (,$(CIRCLE_JOB)) + GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint + else ifeq (,$(wildcard .github/workflows/golangci-lint.yml)) + GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint + endif endif endif @@ -154,7 +160,7 @@ endif update-go-deps: @echo ">> updating Go dependencies" @for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \ - $(GO) get $$m; \ + $(GO) get -d $$m; \ done GO111MODULE=$(GO111MODULE) $(GO) mod tidy ifneq (,$(wildcard vendor))