feat: add linters (#11)
Reviewed-on: #11 Co-authored-by: Jan Klattenhoff <jan@kjan.email> Co-committed-by: Jan Klattenhoff <jan@kjan.email>
This commit is contained in:
parent
1b86948c60
commit
e332ef87cb
3 changed files with 15 additions and 1 deletions
4
.golangci.yml
Normal file
4
.golangci.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
version: "2"
|
||||
linters:
|
||||
enable:
|
||||
- revive
|
|
@ -1,3 +1,4 @@
|
|||
// Package validation General validation tasks
|
||||
package validation
|
||||
|
||||
import (
|
||||
|
@ -6,6 +7,7 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
// ValidateConventionalCommit validates if string follows conventional commit
|
||||
func ValidateConventionalCommit(commit string) error {
|
||||
// Regex to match the commit format
|
||||
// type(scope)!: description
|
||||
|
|
10
main.go
10
main.go
|
@ -1,3 +1,4 @@
|
|||
// Package main is the main package
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -8,6 +9,7 @@ import (
|
|||
"git.kjan.de/actions/pull-request-lint/internal/validation"
|
||||
)
|
||||
|
||||
// GithubEvent represents a github actions event
|
||||
type GithubEvent struct {
|
||||
PullRequest struct {
|
||||
Title string `json:"title"`
|
||||
|
@ -26,7 +28,13 @@ func main() {
|
|||
fmt.Printf("Error opening %s: %v\n", eventPath, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer eventFile.Close()
|
||||
defer func() {
|
||||
closeFileErr := eventFile.Close()
|
||||
if closeFileErr != nil {
|
||||
fmt.Println("Error closing eventFile")
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
|
||||
var event GithubEvent
|
||||
decoder := json.NewDecoder(eventFile)
|
||||
|
|
Loading…
Add table
Reference in a new issue