Skip to content

Commit

Permalink
ci: bump mage tools
Browse files Browse the repository at this point in the history
  • Loading branch information
odsod committed Jan 26, 2022
1 parent e1b60a2 commit 38658eb
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .mage/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module mage-tools
go 1.17

require (
github.com/go-logr/logr v1.2.2
github.com/magefile/mage v1.12.1
go.einride.tech/mage-tools v0.33.0
go.einride.tech/mage-tools v0.40.0
)

require (
github.com/go-logr/logr v1.2.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
Expand Down
4 changes: 2 additions & 2 deletions .mage/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHL
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/magefile/mage v1.12.1 h1:oGdAbhIUd6iKamKlDGVtU6XGdy5SgNuCWn7gCTgHDtU=
github.com/magefile/mage v1.12.1/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
go.einride.tech/mage-tools v0.33.0 h1:vilDjf/4RTE0X+SWFYk6E3uoOR8l97G5D5ZYqKc0D+4=
go.einride.tech/mage-tools v0.33.0/go.mod h1:pFpCBZ0U7a6862mks4y6v5xBkT4IhdrcJdEeTEjweMI=
go.einride.tech/mage-tools v0.40.0 h1:NE63Pjn3aD6g+44sz3sYH4iAP8z5J9gnUV1/q3PDsco=
go.einride.tech/mage-tools v0.40.0/go.mod h1:pFpCBZ0U7a6862mks4y6v5xBkT4IhdrcJdEeTEjweMI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
Expand Down
58 changes: 34 additions & 24 deletions .mage/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ package main
import (
"context"

"github.com/go-logr/logr"
"github.com/magefile/mage/mg"
"go.einride.tech/mage-tools/mglog"
"go.einride.tech/mage-tools/mglogr"
"go.einride.tech/mage-tools/mgmake"
"go.einride.tech/mage-tools/mgpath"
"go.einride.tech/mage-tools/mgtool"
"go.einride.tech/mage-tools/tools/mgconvco"
"go.einride.tech/mage-tools/tools/mggitverifynodiff"
"go.einride.tech/mage-tools/tools/mggit"
"go.einride.tech/mage-tools/tools/mggo"
"go.einride.tech/mage-tools/tools/mggolangcilint"
"go.einride.tech/mage-tools/tools/mggoreview"
Expand Down Expand Up @@ -42,51 +44,59 @@ func All() {
)
mg.Deps(
GolangciLint,
Goreview,
GoReview,
GoTest,
)
mg.SerialDeps(
GoModTidy,
mggitverifynodiff.GitVerifyNoDiff,
GitVerifyNoDiff,
)
}

func FormatYAML() error {
mglog.Logger("format-yaml").Info("formatting...")
return mgyamlfmt.FormatYAML()
}

func ConvcoCheck(ctx context.Context) error {
mglog.Logger("convco-check").Info("checking...")
ctx = logr.NewContext(ctx, mglogr.New("convco-check"))
logr.FromContextOrDiscard(ctx).Info("checking git commits...")
return mgconvco.Command(ctx, "check", "origin/master..HEAD").Run()
}

func FormatYAML(ctx context.Context) error {
ctx = logr.NewContext(ctx, mglogr.New("format-yaml"))
logr.FromContextOrDiscard(ctx).Info("formatting YAML files...")
return mgyamlfmt.FormatYAML(ctx)
}

func FormatMarkdown(ctx context.Context) error {
mglog.Logger("format-markdown").Info("formatting..")
ctx = logr.NewContext(ctx, mglogr.New("format-markdown"))
logr.FromContextOrDiscard(ctx).Info("formatting Markdown files...")
return mgmarkdownfmt.Command(ctx, "-w", ".").Run()
}

func GolangciLint(ctx context.Context) error {
mglog.Logger("golangci-lint").Info("running...")
return mggolangcilint.LintCommand(ctx).Run()
ctx = logr.NewContext(ctx, mglogr.New("golangci-lint"))
logr.FromContextOrDiscard(ctx).Info("linting Go files...")
return mggolangcilint.RunCommand(ctx).Run()
}

func Goreview(ctx context.Context) error {
mglog.Logger("goreview").Info("running...")
func GoReview(ctx context.Context) error {
ctx = logr.NewContext(ctx, mglogr.New("go-review"))
logr.FromContextOrDiscard(ctx).Info("reviewing Go files...")
return mggoreview.Command(ctx, "-c", "1", "./...").Run()
}

func GoModTidy() error {
mglog.Logger("go-mod-tidy").Info("tidying Go module files...")
return mggo.GoModTidy().Run()
func GoModTidy(ctx context.Context) error {
ctx = logr.NewContext(ctx, mglogr.New("go-mod-tidy"))
logr.FromContextOrDiscard(ctx).Info("tidying Go module files...")
return mgtool.Command(ctx, "go", "mod", "tidy", "-v").Run()
}

func GoTest() error {
mglog.Logger("go-test").Info("running Go unit tests..")
return mggo.GoTest().Run()
func GoTest(ctx context.Context) error {
ctx = logr.NewContext(ctx, mglogr.New("go-test"))
logr.FromContextOrDiscard(ctx).Info("running Go tests...")
return mggo.TestCommand(ctx).Run()
}

func GitVerifyNoDiff() error {
mglog.Logger("git-verify-no-diff").Info("verifying that git has no diff..")
return mggitverifynodiff.GitVerifyNoDiff()
func GitVerifyNoDiff(ctx context.Context) error {
ctx = logr.NewContext(ctx, mglogr.New("git-verify-no-diff"))
logr.FromContextOrDiscard(ctx).Info("verifying that git has no diff...")
return mggit.VerifyNoDiff(ctx)
}
31 changes: 22 additions & 9 deletions .mage/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ package main

import (
"context"

"github.com/go-logr/logr"
"github.com/magefile/mage/mg"
"go.einride.tech/mage-tools/mglog"
"go.einride.tech/mage-tools/mglogr"
"go.einride.tech/mage-tools/mgpath"
"go.einride.tech/mage-tools/mgtool"
"go.einride.tech/mage-tools/tools/mgbuf"
Expand All @@ -27,19 +29,24 @@ func (Proto) All() {
}

func (Proto) BufLint(ctx context.Context) error {
mglog.Logger("buf-lint").Info("linting protos...")
ctx = logr.NewContext(ctx, mglogr.New("buf-lint"))
logr.FromContextOrDiscard(ctx).Info("linting proto files...")
cmd := mgbuf.Command(ctx, "lint")
cmd.Dir = mgpath.FromGitRoot("proto")
return cmd.Run()
}

func (Proto) ClangFormatProto() error {
mglog.Logger("clang-format-proto").Info("formatting protos...")
cmd := mgclangformat.FormatProtoCommand(mgpath.FromGitRoot("proto"))
func (Proto) ClangFormatProto(ctx context.Context) error {
ctx = logr.NewContext(ctx, mglogr.New("clang-format-proto"))
logr.FromContextOrDiscard(ctx).Info("formatting proto files...")
protoFiles := mgpath.FindFilesWithExtension(mgpath.FromGitRoot("proto"), ".proto")
cmd := mgclangformat.FormatProtoCommand(ctx, protoFiles...)
return cmd.Run()
}

func (Proto) ProtocGenGo(ctx context.Context) error {
ctx = logr.NewContext(ctx, mglogr.New("protoc-gen-go"))
logr.FromContextOrDiscard(ctx).Info("installing...")
_, err := mgtool.GoInstallWithModfile(
ctx,
"google.golang.org/protobuf/cmd/protoc-gen-go",
Expand All @@ -49,13 +56,17 @@ func (Proto) ProtocGenGo(ctx context.Context) error {
}

func (Proto) ProtocGenGoGRPC(ctx context.Context) error {
ctx = logr.NewContext(ctx, mglogr.New("protoc-gen-go-grpc"))
logr.FromContextOrDiscard(ctx).Info("installing...")
_, err := mgtool.GoInstall(ctx, "google.golang.org/grpc/cmd/protoc-gen-go-grpc", "v1.2.0")
return err
}

func (Proto) ProtocGenGoCLI() error {
mglog.Logger("protoc-gen-go-aip").Info("building binary...")
func (Proto) ProtocGenGoCLI(ctx context.Context) error {
ctx = logr.NewContext(ctx, mglogr.New("protoc-gen-go-cli"))
logr.FromContextOrDiscard(ctx).Info("building binary...")
return mgtool.Command(
ctx,
"go",
"build",
"-o",
Expand All @@ -68,7 +79,8 @@ func (Proto) BufGenerate(ctx context.Context) error {
mg.Deps(
Proto.ProtocGenGo,
)
mglog.Logger("buf-generate").Info("generating protobuf stubs...")
ctx = logr.NewContext(ctx, mglogr.New("buf-generate"))
logr.FromContextOrDiscard(ctx).Info("generating proto stubs...")
cmd := mgbuf.Command(ctx, "generate", "--template", "buf.gen.yaml", "--path", "einride")
cmd.Dir = mgpath.FromGitRoot("proto")
return cmd.Run()
Expand All @@ -80,7 +92,8 @@ func (Proto) BufGenerateExample(ctx context.Context) error {
Proto.ProtocGenGoGRPC,
Proto.ProtocGenGoCLI,
)
mglog.Logger("buf-generate-example").Info("generating example protobuf stubs...")
ctx = logr.NewContext(ctx, mglogr.New("buf-generate-example"))
logr.FromContextOrDiscard(ctx).Info("generating example proto stubs...")
cmd := mgbuf.Command(
ctx,
"generate",
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ git-verify-no-diff: $(magefile)
go-mod-tidy: $(magefile)
@$(magefile) goModTidy

.PHONY: go-review
go-review: $(magefile)
@$(magefile) goReview

.PHONY: go-test
go-test: $(magefile)
@$(magefile) goTest
Expand All @@ -44,10 +48,6 @@ go-test: $(magefile)
golangci-lint: $(magefile)
@$(magefile) golangciLint

.PHONY: goreview
goreview: $(magefile)
@$(magefile) goreview

.PHONY: proto
proto:
make -C proto

0 comments on commit 38658eb

Please sign in to comment.