nitter/build/lint.go
Peter Kurfer c1c1667d9f
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is passing
feat(gitea): add lint-pr command
lint-pr runs golangci-lint, captures the result and uses it directly without temporary files
It also allows to automatically retrieve the PRs base commit and run golangci-lint only against changes in the current PR
2023-03-09 12:15:35 +01:00

42 lines
608 B
Go

//go:build mage
package main
import (
"context"
"fmt"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
func Lint(ctx context.Context) {
mg.CtxDeps(ctx, Generate)
mg.CtxDeps(ctx, Format)
mg.Deps(LintGo)
}
func LintGo() (err error) {
if IsPRBuild {
return lintGoPR()
}
return sh.RunV(
"golangci-lint",
"run",
"-v",
"--issues-exit-code=1",
)
}
func lintGoPR() error {
return GoRun(
"main.go",
"gitea",
"lint-pr",
"--from-pr-base",
fmt.Sprintf("--namespace=%s", repoOwner),
fmt.Sprintf("--repo=%s", repoName),
fmt.Sprintf("--pull-index=%d", prIndex),
)
}