Add CI (#1)
Add basic build when merged to master Add basic CI compliance and linting Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: jolheiser <john.olheiser@gmail.com> Reviewed-on: https://gitea.com/jolheiser/gitea-vet/pulls/1
This commit is contained in:
parent
6c7b81d401
commit
0185062ee4
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
kind: pipeline
|
||||
name: compliance
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
steps:
|
||||
- name: check
|
||||
pull: always
|
||||
image: golang:1.14
|
||||
environment:
|
||||
GOPROXY: https://goproxy.cn
|
||||
commands:
|
||||
- make build
|
||||
- make lint
|
||||
- make vet
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: build-master
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
pull: always
|
||||
image: techknowlogick/xgo:latest
|
||||
environment:
|
||||
GOPROXY: https://goproxy.cn
|
||||
commands:
|
||||
- make build
|
|
@ -0,0 +1,23 @@
|
|||
linters:
|
||||
enable:
|
||||
- deadcode
|
||||
- dogsled
|
||||
- dupl
|
||||
- errcheck
|
||||
- gocognit
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofmt
|
||||
- golint
|
||||
- gosimple
|
||||
- govet
|
||||
- maligned
|
||||
- misspell
|
||||
- prealloc
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unparam
|
||||
- unused
|
||||
- varcheck
|
19
Makefile
19
Makefile
|
@ -1,7 +1,22 @@
|
|||
GO ?= go
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
go build
|
||||
$(GO) build
|
||||
|
||||
.PHONY: fmt
|
||||
fmt:
|
||||
go fmt ./...
|
||||
$(GO) fmt ./...
|
||||
|
||||
.PHONY: vet
|
||||
vet: build
|
||||
$(GO) vet ./...
|
||||
$(GO) vet -vettool=gitea-vet ./...
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||
export BINARY="golangci-lint"; \
|
||||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(shell $(GO) env GOPATH)/bin v1.24.0; \
|
||||
fi
|
||||
golangci-lint run --timeout 5m
|
|
@ -1,4 +1,7 @@
|
|||
# gitea-vet
|
||||
|
||||
[![Build Status](https://drone.gitea.com/api/badges/jolheiser/gitea-vet/status.svg)](https://drone.gitea.com/jolheiser/gitea-vet)
|
||||
|
||||
`go vet` tool for Gitea
|
||||
|
||||
| Analyzer | Description |
|
||||
|
|
|
@ -22,11 +22,12 @@ func runImports(pass *analysis.Pass) (interface{}, error) {
|
|||
for _, im := range file.Imports {
|
||||
var lvl int
|
||||
val := im.Path.Value
|
||||
if importHasPrefix(val, "code.gitea.io") {
|
||||
switch {
|
||||
case importHasPrefix(val, "code.gitea.io"):
|
||||
lvl = 2
|
||||
} else if strings.Contains(val, ".") {
|
||||
case strings.Contains(val, "."):
|
||||
lvl = 3
|
||||
} else {
|
||||
default:
|
||||
lvl = 1
|
||||
}
|
||||
|
||||
|
@ -43,12 +44,3 @@ func runImports(pass *analysis.Pass) (interface{}, error) {
|
|||
func importHasPrefix(s, p string) bool {
|
||||
return strings.HasPrefix(s, "\""+p)
|
||||
}
|
||||
|
||||
func sliceHasPrefix(s string, prefixes ...string) bool {
|
||||
for _, p := range prefixes {
|
||||
if importHasPrefix(s, p) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue