Update common Prometheus files
authorprombot <prometheus-team@googlegroups.com>
Sun, 12 Sep 2021 00:02:50 +0000 (00:02 +0000)
committerprombot <prometheus-team@googlegroups.com>
Sun, 12 Sep 2021 00:02:50 +0000 (00:02 +0000)
Signed-off-by: prombot <prometheus-team@googlegroups.com>
.github/workflows/golangci-lint.yml [new file with mode: 0644]
Makefile.common

diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml
new file mode 100644 (file)
index 0000000..431fef7
--- /dev/null
@@ -0,0 +1,29 @@
+name: golangci-lint
+on:
+  push:
+    paths:
+      - "go.sum"
+      - "go.mod"
+      - "**.go"
+      - "scripts/errcheck_excludes.txt"
+      - ".github/workflows/golangci-lint.yml"
+  pull_request:
+    paths:
+      - "go.sum"
+      - "go.mod"
+      - "**.go"
+      - "scripts/errcheck_excludes.txt"
+      - ".github/workflows/golangci-lint.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
index a1b1ca40f4b028ffb46a77de0af43617fb4afab3..99e8f9f1b3279ff557006c4de9059a2e578863fe 100644 (file)
@@ -83,12 +83,18 @@ PROMU_URL     := https://github.com/prometheus/promu/releases/download/v$(PROMU_
 
 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