mirror of https://gitea.com/gitea/tea
Update gitea-vet v0.2.0 (#164)
tagged version v0.2.0 make vendor Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/164 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: techknowlogick <techknowlogick@gitea.io>pull/166/head
parent
edd180a8f5
commit
eb37f14923
@ -0,0 +1,30 @@
|
||||
# The full repository name
|
||||
repo: gitea/gitea-vet
|
||||
|
||||
# Service type (gitea or github)
|
||||
service: gitea
|
||||
|
||||
# Base URL for Gitea instance if using gitea service type (optional)
|
||||
base-url: https://gitea.com
|
||||
|
||||
# Changelog groups and which labeled PRs to add to each group
|
||||
groups:
|
||||
-
|
||||
name: BREAKING
|
||||
labels:
|
||||
- breaking
|
||||
-
|
||||
name: FEATURES
|
||||
labels:
|
||||
- feature
|
||||
-
|
||||
name: BUGFIXES
|
||||
labels:
|
||||
- bug
|
||||
-
|
||||
name: ENHANCEMENTS
|
||||
labels:
|
||||
- enhancement
|
||||
|
||||
# regex indicating which labels to skip for the changelog
|
||||
skip-labels: skip-changelog|backport\/.+
|
@ -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
|
@ -0,0 +1,6 @@
|
||||
## [0.2.0](https://gitea.com/gitea/gitea-vet/pulls?q=&type=all&state=closed&milestone=1272) - 2020-07-20
|
||||
|
||||
* FEATURES
|
||||
* Add migrations check (#5)
|
||||
* BUGFIXES
|
||||
* Correct Import Paths (#6)
|
@ -0,0 +1,22 @@
|
||||
GO ?= go
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
$(GO) build
|
||||
|
||||
.PHONY: fmt
|
||||
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
|
@ -0,0 +1,11 @@
|
||||
# gitea-vet
|
||||
|
||||
[![Build Status](https://drone.gitea.com/api/badges/gitea/gitea-vet/status.svg)](https://drone.gitea.com/gitea/gitea-vet)
|
||||
|
||||
`go vet` tool for Gitea
|
||||
|
||||
| Analyzer | Description |
|
||||
|------------|-----------------------------------------------------------------------------|
|
||||
| Imports | Checks for import sorting. stdlib->code.gitea.io->other |
|
||||
| License | Checks file headers for some form of `Copyright...YYYY...Gitea/Gogs` |
|
||||
| Migrations | Checks for black-listed packages in `code.gitea.io/gitea/models/migrations` |
|
@ -0,0 +1,59 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package checks
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/analysis"
|
||||
)
|
||||
|
||||
var Migrations = &analysis.Analyzer{
|
||||
Name: "migrations",
|
||||
Doc: "check migrations for black-listed packages.",
|
||||
Run: checkMigrations,
|
||||
}
|
||||
|
||||
var migrationBlacklist = []string{
|
||||
"code.gitea.io/gitea/models",
|
||||
"code.gitea.io/gitea/modules/structs",
|
||||
}
|
||||
|
||||
func checkMigrations(pass *analysis.Pass) (interface{}, error) {
|
||||
if !strings.EqualFold(pass.Pkg.Path(), "code.gitea.io/gitea/models/migrations") {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if _, err := exec.LookPath("go"); err != nil {
|
||||
return nil, errors.New("go was not found in the PATH")
|
||||
}
|
||||
|
||||
depsCmd := exec.Command("go", "list", "-f", `{{join .Deps "\n"}}`, "code.gitea.io/gitea/models/migrations")
|
||||
depsOut, err := depsCmd.Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
deps := strings.Split(string(depsOut), "\n")
|
||||
for _, dep := range deps {
|
||||
if stringInSlice(dep, migrationBlacklist) {
|
||||
pass.Reportf(0, "code.gitea.io/gitea/models/migrations cannot depend on the following packages: %s", migrationBlacklist)
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func stringInSlice(needle string, haystack []string) bool {
|
||||
for _, h := range haystack {
|
||||
if strings.EqualFold(needle, h) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
2
vendor/gitea.com/jolheiser/gitea-vet/go.mod → vendor/code.gitea.io/gitea-vet/go.mod
generated
vendored
2
vendor/gitea.com/jolheiser/gitea-vet/go.mod → vendor/code.gitea.io/gitea-vet/go.mod
generated
vendored
@ -1,4 +1,4 @@
|
||||
module gitea.com/jolheiser/gitea-vet
|
||||
module code.gitea.io/gitea-vet
|
||||
|
||||
go 1.14
|
||||
|
0
vendor/gitea.com/jolheiser/gitea-vet/go.sum → vendor/code.gitea.io/gitea-vet/go.sum
generated
vendored
0
vendor/gitea.com/jolheiser/gitea-vet/go.sum → vendor/code.gitea.io/gitea-vet/go.sum
generated
vendored
@ -1,7 +0,0 @@
|
||||
.PHONY: build
|
||||
build:
|
||||
go build
|
||||
|
||||
.PHONY: fmt
|
||||
fmt:
|
||||
go fmt ./...
|
@ -1,7 +0,0 @@
|
||||
# gitea-vet
|
||||
`go vet` tool for Gitea
|
||||
|
||||
| Analyzer | Description |
|
||||
|----------|---------------------------------------------------------------------|
|
||||
| Imports | Checks for import sorting. stdlib->code.gitea.io->other |
|
||||
| License | Checks file headers for some form of `Copyright...YYYY...Gitea/Gogs`|
|
Loading…
Reference in New Issue