-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14a5c9a
commit 21cc6ef
Showing
80 changed files
with
1,485 additions
and
1,030 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
dist | ||
helpers | ||
vendor | ||
**/*.tgz | ||
/gitlab-ci-pipelines-exporter.yml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
linters: | ||
enable-all: true | ||
disable: | ||
# Deprecated ones | ||
- golint | ||
- interfacer | ||
- maligned | ||
- scopelint | ||
|
||
# We don't want these ones | ||
- exhaustivestruct | ||
- forcetypeassert | ||
- gochecknoglobals | ||
- godox | ||
- goerr113 | ||
- ireturn | ||
- nakedret | ||
- testpackage | ||
- varnamelen | ||
|
||
# TODO | ||
- tagliatelle | ||
- promlinter | ||
- paralleltest | ||
- gocognit | ||
- gomoddirectives | ||
- forbidigo | ||
- goconst | ||
- gomnd | ||
- lll | ||
- dupl | ||
|
||
linters-settings: | ||
funlen: | ||
lines: -1 # (disabled) | ||
statements: 100 | ||
|
||
cyclop: | ||
max-complexity: 20 | ||
|
||
lll: | ||
line-length: 140 | ||
|
||
nestif: | ||
min-complexity: 18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
before: | ||
hooks: | ||
- go mod download | ||
- make man-pages | ||
- make autocomplete-scripts | ||
|
||
builds: | ||
- main: ./cmd/gitlab-ci-pipelines-exporter | ||
|
@@ -18,16 +19,49 @@ builds: | |
goarm: [6, 7] | ||
flags: | ||
- -trimpath | ||
ignore: | ||
- { goos: darwin, goarch: 386 } | ||
- { goos: darwin, goarch: arm } | ||
- { goos: windows, goarch: arm } | ||
|
||
universal_binaries: | ||
- {} | ||
|
||
archives: | ||
- name_template: '{{ .ProjectName }}_edge_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
files: | ||
- README.md | ||
- LICENSE | ||
- helpers/* | ||
|
||
nfpms: | ||
- maintainer: &author Maxime VISONNEAU <[email protected]> | ||
description: &description GitLab CI pipelines exporter (prometheus/open-metrics) | ||
license: &license Apache-2.0 | ||
homepage: &homepage https://github.com/mvisonneau/gitlab-ci-pipelines-exporter | ||
vendor: *author | ||
file_name_template: '{{ .ProjectName }}_{{ .Tag }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' | ||
bindir: /usr/local/bin | ||
formats: | ||
- apk | ||
- deb | ||
- rpm | ||
contents: | ||
- src: ./helpers/autocomplete/bash | ||
dst: /usr/share/bash-completion/completions/{{ .ProjectName }} | ||
file_info: | ||
mode: 0644 | ||
- src: ./helpers/autocomplete/zsh | ||
dst: /usr/share/zsh/vendor-completions/_{{ .ProjectName }} | ||
file_info: | ||
mode: 0644 | ||
- src: ./helpers/manpages/{{ .ProjectName }}.1.gz | ||
dst: /usr/share/man/man1/{{ .ProjectName }}.1.gz | ||
file_info: | ||
mode: 0644 | ||
- src: ./LICENSE | ||
dst: /usr/share/doc/{{ .ProjectName }}/copyright | ||
file_info: | ||
mode: 0644 | ||
|
||
release: | ||
disable: true | ||
|
@@ -36,7 +70,7 @@ snapcrafts: | |
- summary: GitLab CI pipelines exporter (prometheus/open-metrics) | ||
description: Monitor GitLab CI pipelines related metrics. | ||
license: Apache-2.0 | ||
confinement: strict | ||
confinement: classic | ||
grade: devel | ||
apps: | ||
gitlab-ci-pipelines-exporter: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
before: | ||
hooks: | ||
- go mod download | ||
- make man-pages | ||
- make autocomplete-scripts | ||
|
||
builds: | ||
- main: ./cmd/gitlab-ci-pipelines-exporter | ||
|
@@ -18,16 +19,19 @@ builds: | |
goarm: [6, 7] | ||
flags: | ||
- -trimpath | ||
ignore: | ||
- { goos: darwin, goarch: 386 } | ||
- { goos: darwin, goarch: arm } | ||
- { goos: windows, goarch: arm } | ||
|
||
universal_binaries: | ||
- {} | ||
|
||
archives: | ||
- name_template: '{{ .ProjectName }}_edge_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
files: | ||
- README.md | ||
- LICENSE | ||
- helpers/* | ||
|
||
nfpms: | ||
- maintainer: &author Maxime VISONNEAU <[email protected]> | ||
|
@@ -36,17 +40,44 @@ nfpms: | |
homepage: &homepage https://github.com/mvisonneau/gitlab-ci-pipelines-exporter | ||
vendor: *author | ||
file_name_template: '{{ .ProjectName }}_{{ .Tag }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' | ||
bindir: /usr/local/bin | ||
formats: | ||
- apk | ||
- deb | ||
- rpm | ||
contents: | ||
- src: ./helpers/autocomplete/bash | ||
dst: /usr/share/bash-completion/completions/{{ .ProjectName }} | ||
file_info: | ||
mode: 0644 | ||
- src: ./helpers/autocomplete/zsh | ||
dst: /usr/share/zsh/vendor-completions/_{{ .ProjectName }} | ||
file_info: | ||
mode: 0644 | ||
- src: ./helpers/manpages/{{ .ProjectName }}.1.gz | ||
dst: /usr/share/man/man1/{{ .ProjectName }}.1.gz | ||
file_info: | ||
mode: 0644 | ||
- src: ./LICENSE | ||
dst: /usr/share/doc/{{ .ProjectName }}/copyright | ||
file_info: | ||
mode: 0644 | ||
|
||
brews: | ||
- description: *description | ||
homepage: *homepage | ||
license: *license | ||
folder: Formula | ||
tap: | ||
owner: mvisonneau | ||
name: homebrew-tap | ||
test: | | ||
system "#{bin}/{{ .ProjectName }} -v" | ||
install: |- | ||
bin.install "{{ .ProjectName }}" | ||
bash_completion.install "./helpers/autocomplete/bash" => "{{ .ProjectName }}" | ||
zsh_completion.install "./helpers/autocomplete/zsh" => "_{{ .ProjectName }}" | ||
man1.install "./helpers/manpages/{{ .ProjectName }}.1.gz" | ||
scoop: | ||
description: *description | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,43 +5,16 @@ REPOSITORY := mvisonneau/$(NAME) | |
|
||
.PHONY: setup | ||
setup: ## Install required libraries/tools for build tasks | ||
@command -v gofumpt 2>&1 >/dev/null || go install mvdan.cc/[email protected] | ||
@command -v gosec 2>&1 >/dev/null || go install github.com/securego/gosec/v2/cmd/[email protected] | ||
@command -v ineffassign 2>&1 >/dev/null || go install github.com/gordonklaus/[email protected] | ||
@command -v misspell 2>&1 >/dev/null || go install github.com/client9/misspell/cmd/[email protected] | ||
@command -v revive 2>&1 >/dev/null || go install github.com/mgechev/[email protected] | ||
@command -v gofumpt 2>&1 >/dev/null || go install mvdan.cc/[email protected] | ||
@command -v golangci-lint 2>&1 >/dev/null || go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
|
||
.PHONY: fmt | ||
fmt: setup ## Format source code | ||
gofumpt -w $(FILES) | ||
|
||
.PHONY: lint | ||
lint: revive vet gofumpt ineffassign misspell gosec ## Run all lint related tests against the codebase | ||
|
||
.PHONY: revive | ||
revive: setup ## Test code syntax with revive | ||
revive -config .revive.toml $(FILES) | ||
|
||
.PHONY: vet | ||
vet: ## Test code syntax with go vet | ||
go vet ./... | ||
|
||
.PHONY: gofumpt | ||
gofumpt: setup ## Test code syntax with gofumpt | ||
gofumpt -d $(FILES) > gofumpt.out | ||
@if [ -s gofumpt.out ]; then cat gofumpt.out; rm gofumpt.out; exit 1; else rm gofumpt.out; fi | ||
|
||
.PHONY: ineffassign | ||
ineffassign: setup ## Test code syntax for ineffassign | ||
ineffassign ./... | ||
|
||
.PHONY: misspell | ||
misspell: setup ## Test code with misspell | ||
misspell -error $(FILES) | ||
|
||
.PHONY: gosec | ||
gosec: setup ## Test code for security vulnerabilities | ||
gosec ./... | ||
lint: setup ## Run all lint related tests upon the codebase | ||
golangci-lint run -v --fast | ||
|
||
.PHONY: test | ||
test: ## Run the tests against the codebase | ||
|
@@ -88,14 +61,27 @@ dev-env: ## Build a local development environment using Docker | |
-v $(shell pwd):/go/src/github.com/mvisonneau/$(NAME) \ | ||
-w /go/src/github.com/mvisonneau/$(NAME) \ | ||
-p 8080:8080 \ | ||
golang:1.17 \ | ||
golang:1.18 \ | ||
/bin/bash -c 'make setup; make install; bash' | ||
|
||
.PHONY: is-git-dirty | ||
is-git-dirty: ## Tests if git is in a dirty state | ||
@git status --porcelain | ||
@test $(shell git status --porcelain | grep -c .) -eq 0 | ||
|
||
.PHONY: man-pages | ||
man-pages: ## Generates man pages | ||
rm -rf helpers/manpages | ||
mkdir -p helpers/manpages | ||
go run ./cmd/tools/man | gzip -c -9 >helpers/manpages/$(NAME).1.gz | ||
|
||
.PHONY: autocomplete-scripts | ||
autocomplete-scripts: ## Download CLI autocompletion scripts | ||
rm -rf helpers/autocomplete | ||
mkdir -p helpers/autocomplete | ||
curl -sL https://raw.githubusercontent.com/urfave/cli/v2.5.0/autocomplete/bash_autocomplete > helpers/autocomplete/bash | ||
curl -sL https://raw.githubusercontent.com/urfave/cli/v2.5.0/autocomplete/zsh_autocomplete > helpers/autocomplete/zsh | ||
|
||
.PHONY: all | ||
all: lint test build coverage ## Test, builds and ship package for all supported platforms | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/mvisonneau/gitlab-ci-pipelines-exporter/internal/cli" | ||
) | ||
|
||
var version = "devel" | ||
|
||
func main() { | ||
fmt.Println(cli.NewApp(version, time.Now()).ToMan()) | ||
} |
Oops, something went wrong.