Skip to content

Commit 582da55

Browse files
authored
tools: moved to new go 1.24 approach using go get -tool and upgraded to golangci v2 (#1009)
1 parent 9005b58 commit 582da55

58 files changed

Lines changed: 2183 additions & 368 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/prerelease.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mkdir -p ${HOME}/.cache/snapcraft/{download,stage-packages}
2727
# Build the binaries using a prerelease tag
2828
git tag -d edge
2929
git tag -f ${PRERELEASE_TAG}
30-
goreleaser release \
30+
go tool github.com/goreleaser/goreleaser/v2 release \
3131
--clean \
3232
--skip=validate \
3333
-f .goreleaser.pre.yml

.github/workflows/release.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ jobs:
6262
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
6363
passphrase: ${{ secrets.GPG_PASSPHRASE }}
6464

65-
- name: Install goreleaser
66-
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6
67-
with:
68-
version: v1.24.0
69-
install-only: true
70-
7165
- name: Run goreleaser
7266
run: make ${{ github.ref == 'refs/heads/main' && 'pre' || '' }}release
7367
env:

.golangci.yml

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,53 @@
1+
---
2+
version: "2"
3+
14
linters:
2-
enable-all: true
3-
disable:
4-
# Deprecated
5-
- gomnd
6-
7-
# We don't want these ones
8-
- forcetypeassert
9-
- gochecknoglobals
10-
- godox
11-
- ireturn
12-
- nakedret
13-
- testpackage
14-
- varnamelen
15-
- interfacebloat
16-
- wsl
17-
18-
# TODO
19-
- tagliatelle
20-
- promlinter
21-
- paralleltest
22-
- gocognit
23-
- gomoddirectives
24-
- forbidigo
25-
- goconst
26-
- mnd
27-
- lll
28-
- dupl
29-
- depguard
30-
- tagalign
31-
32-
linters-settings:
33-
funlen:
34-
lines: -1 # (disabled)
35-
statements: 100
36-
37-
cyclop:
38-
max-complexity: 20
39-
40-
lll:
41-
line-length: 140
42-
43-
nestif:
44-
min-complexity: 18
45-
46-
gci:
47-
sections:
48-
- standard
49-
- default
50-
- prefix(github.com/mvisonneau)
5+
default: none
6+
enable:
7+
- errcheck
8+
- gosec
9+
- govet
10+
- ineffassign
11+
- staticcheck
12+
- unused
13+
14+
settings:
15+
funlen:
16+
lines: -1 # (disabled)
17+
statements: 100
18+
19+
cyclop:
20+
max-complexity: 20
21+
22+
lll:
23+
line-length: 140
24+
25+
nestif:
26+
min-complexity: 18
27+
28+
gosec:
29+
excludes:
30+
# https://github.com/golangci/golangci-lint/discussions/4939
31+
# Disabled by default in golangci because it's too noisy, too many false positives
32+
- G115
33+
staticcheck:
34+
checks:
35+
- all
36+
# Seems buggy
37+
- -ST1000
38+
# Not personally fond of having to remove those embedded field calls.
39+
- -QF1008
40+
41+
formatters:
42+
enable:
43+
- gci
44+
- gofmt
45+
- gofumpt
46+
- goimports
47+
48+
settings:
49+
gci:
50+
sections:
51+
- standard
52+
- default
53+
- prefix(github.com/mvisonneau)

.goreleaser.pre.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version: 2
12
before:
23
hooks:
34
- make man-pages
@@ -19,6 +20,9 @@ builds:
1920
goarm: [6, 7]
2021
flags:
2122
- -trimpath
23+
ignore:
24+
- { goos: darwin, goarch: 386 }
25+
- { goos: darwin, goarch: arm }
2226

2327
universal_binaries:
2428
- {}
@@ -37,7 +41,7 @@ nfpms:
3741
- maintainer: &author Maxime VISONNEAU <maxime.visonneau@gmail.com>
3842
description: &description GitLab CI pipelines exporter (prometheus/open-metrics)
3943
license: &license Apache-2.0
40-
homepage: &homepage https://github.com/mvisonneau/gitlab-ci-pipelines-exporter
44+
homepage: https://github.com/mvisonneau/gitlab-ci-pipelines-exporter
4145
vendor: *author
4246
file_name_template: '{{ .ProjectName }}_edge_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
4347
bindir: /usr/local/bin
@@ -51,7 +55,7 @@ nfpms:
5155
file_info:
5256
mode: 0644
5357
- src: ./helpers/autocomplete/zsh
54-
dst: /usr/share/zsh/vendor-completions/_{{ .ProjectName }}
58+
dst: /usr/share/zsh/vendor-completions/_{{ .ProjectName }}
5559
file_info:
5660
mode: 0644
5761
- src: ./helpers/manpages/{{ .ProjectName }}.1.gz
@@ -66,16 +70,14 @@ nfpms:
6670
release:
6771
disable: true
6872

69-
# Disabling until https://github.com/canonical/snapcraft/issues/4769 is resolved
70-
#snapcrafts:
71-
# - summary: GitLab CI pipelines exporter (prometheus/open-metrics)
72-
# description: Monitor GitLab CI pipelines related metrics.
73-
# license: Apache-2.0
74-
# confinement: strict
75-
# grade: devel
76-
# apps:
77-
# gitlab-ci-pipelines-exporter:
78-
# plugs: [home, network, network-bind]
73+
snapcrafts:
74+
- summary: *description
75+
description: Monitor GitLab CI pipelines related metrics.
76+
license: *license
77+
grade: devel
78+
apps:
79+
gitlab-ci-pipelines-exporter:
80+
plugs: [home, network, network-bind]
7981

8082
dockers:
8183
- image_templates:

.goreleaser.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version: 2
12
before:
23
hooks:
34
- make man-pages
@@ -19,6 +20,9 @@ builds:
1920
goarm: [6, 7]
2021
flags:
2122
- -trimpath
23+
ignore:
24+
- { goos: darwin, goarch: 386 }
25+
- { goos: darwin, goarch: arm }
2226

2327
universal_binaries:
2428
- {}
@@ -51,7 +55,7 @@ nfpms:
5155
file_info:
5256
mode: 0644
5357
- src: ./helpers/autocomplete/zsh
54-
dst: /usr/share/zsh/vendor-completions/_{{ .ProjectName }}
58+
dst: /usr/share/zsh/vendor-completions/_{{ .ProjectName }}
5559
file_info:
5660
mode: 0644
5761
- src: ./helpers/manpages/{{ .ProjectName }}.1.gz
@@ -67,7 +71,7 @@ brews:
6771
- description: *description
6872
homepage: *homepage
6973
license: *license
70-
folder: Formula
74+
directory: Formula
7175
repository:
7276
owner: mvisonneau
7377
name: homebrew-tap
@@ -87,15 +91,14 @@ scoops:
8791
owner: mvisonneau
8892
name: scoops
8993

90-
# Disabling until https://github.com/canonical/snapcraft/issues/4769 is resolved
91-
#snapcrafts:
92-
# - summary: *description
93-
# description: Monitor GitLab CI pipelines related metrics.
94-
# license: *license
95-
# grade: stable
96-
# apps:
97-
# gitlab-ci-pipelines-exporter:
98-
# plugs: [home, network, network-bind]
94+
snapcrafts:
95+
- summary: *description
96+
description: Monitor GitLab CI pipelines related metrics.
97+
license: *license
98+
grade: stable
99+
apps:
100+
gitlab-ci-pipelines-exporter:
101+
plugs: [home, network, network-bind]
99102

100103
dockers:
101104
- image_templates:

Makefile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ FILES := $(shell git ls-files */*.go)
33
COVERAGE_FILE := coverage.out
44
REPOSITORY := mvisonneau/$(NAME)
55
.DEFAULT_GOAL := help
6-
GOLANG_VERSION := 1.23
6+
7+
GOLANG_VERSION := 1.24
8+
GOLANGCI_LINT := go tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint
9+
GORELEASER := go tool github.com/goreleaser/goreleaser/v2
710

811
.PHONY: fmt
912
fmt: ## Format source code
10-
go run mvdan.cc/gofumpt@v0.8.0 -w $(shell git ls-files **/*.go)
11-
go run github.com/daixiang0/gci@v0.13.6 write -s standard -s default -s "prefix(github.com/mvisonneau)" .
13+
$(GOLANGCI_LINT) fmt -v
1214

1315
.PHONY: lint
1416
lint: ## Run all lint related tests upon the codebase
15-
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8 run -v --fast
17+
$(GOLANGCI_LINT) run -v
1618

1719
.PHONY: test
1820
test: ## Run the tests against the codebase
@@ -29,15 +31,15 @@ install: ## Build and install locally the binary (dev purpose)
2931
go install ./cmd/$(NAME)
3032

3133
.PHONY: build
32-
build: ## Build the binaries using local GOOS
33-
go build ./cmd/$(NAME)
34+
build: ## Build the binaries
35+
$(GORELEASER) build --clean --snapshot
3436

3537
.PHONY: release
3638
release: ## Build & release the binaries (stable)
3739
mkdir -p ${HOME}/.cache/snapcraft/download
3840
mkdir -p ${HOME}/.cache/snapcraft/stage-packages
3941
git tag -d edge
40-
goreleaser release --clean
42+
$(GORELEASER) release --clean
4143
find dist -type f -name "*.snap" -exec snapcraft upload --release stable,edge '{}' \;
4244

4345
.PHONY: protoc

0 commit comments

Comments
 (0)