ci: add pre-commit and remove those checks from test step
This commit is contained in:
+21
-4
@@ -1,12 +1,31 @@
|
|||||||
include:
|
include:
|
||||||
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
|
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
|
||||||
|
|
||||||
image: golang:1.19.1
|
image: golang:1.19.4
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- deps
|
- deps
|
||||||
- test
|
- test
|
||||||
|
|
||||||
|
run-pre-commit:
|
||||||
|
stage: .pre
|
||||||
|
image: golang:1.19
|
||||||
|
variables:
|
||||||
|
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
|
||||||
|
cache:
|
||||||
|
- key:
|
||||||
|
files:
|
||||||
|
- .pre-commit-config.yaml
|
||||||
|
paths:
|
||||||
|
- ${PRE_COMMIT_HOME}
|
||||||
|
before_script:
|
||||||
|
- apt update && apt install -y python3 python3-pip ruby git
|
||||||
|
- go install github.com/lietu/go-pre-commit@latest
|
||||||
|
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0
|
||||||
|
- pip install pre-commit
|
||||||
|
script:
|
||||||
|
- pre-commit run --all-files
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
stage: deps
|
stage: deps
|
||||||
script:
|
script:
|
||||||
@@ -17,8 +36,6 @@ test:
|
|||||||
dependencies:
|
dependencies:
|
||||||
- deps
|
- deps
|
||||||
script:
|
script:
|
||||||
- go fmt $(go list ./...)
|
|
||||||
- go vet $(go list ./...)
|
|
||||||
- CGO_ENABLED=1 go test -mod=readonly -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=$(go list ./... | tr '\n' , | sed 's/,$//') ./...
|
- CGO_ENABLED=1 go test -mod=readonly -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=$(go list ./... | tr '\n' , | sed 's/,$//') ./...
|
||||||
- go tool cover -html=coverage.txt -o coverage.html
|
- go tool cover -html=coverage.txt -o coverage.html
|
||||||
- go tool cover -func=coverage.txt
|
- go tool cover -func=coverage.txt
|
||||||
@@ -28,7 +45,7 @@ test:
|
|||||||
|
|
||||||
vulnerabilities:
|
vulnerabilities:
|
||||||
stage: test
|
stage: test
|
||||||
image: golang:1.19.2
|
image: golang:1.19.4
|
||||||
script:
|
script:
|
||||||
- go install golang.org/x/vuln/cmd/govulncheck@latest
|
- go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||||
- govulncheck ./...
|
- govulncheck ./...
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# See https://pre-commit.com for more information
|
||||||
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.4.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-yaml
|
||||||
|
args:
|
||||||
|
- --allow-multiple-documents
|
||||||
|
- id: check-added-large-files
|
||||||
|
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||||
|
rev: 3.0.0
|
||||||
|
hooks:
|
||||||
|
- id: markdownlint
|
||||||
|
- repo: https://gitlab.com/devopshq/gitlab-ci-linter
|
||||||
|
rev: v1.0.3
|
||||||
|
hooks:
|
||||||
|
- id: gitlab-ci-linter
|
||||||
|
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
|
||||||
|
rev: v9.3.0
|
||||||
|
hooks:
|
||||||
|
- id: commitlint
|
||||||
|
stages: [ commit-msg ]
|
||||||
|
additional_dependencies: [ '@commitlint/config-conventional' ]
|
||||||
|
- repo: https://github.com/lietu/go-pre-commit
|
||||||
|
rev: v0.0.1
|
||||||
|
hooks:
|
||||||
|
- id: errcheck
|
||||||
|
- id: go-fmt-goimports
|
||||||
|
- id: go-test
|
||||||
|
- id: golangci-lint
|
||||||
|
- id: gofumpt
|
||||||
|
- id: staticcheck
|
||||||
|
- repo: https://github.com/dnephin/pre-commit-golang
|
||||||
|
rev: v0.5.1
|
||||||
|
hooks:
|
||||||
|
- id: go-mod-tidy
|
||||||
Reference in New Issue
Block a user