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 17, 2022
1 parent 78290a7 commit 2c1305a
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .mage/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ 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.17.0
go.einride.tech/mage-tools v0.25.0
)

require (
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
)
8 changes: 6 additions & 2 deletions .mage/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ 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.17.0 h1:2TgDv0KukR61WbAk+AWz6vBkb7E1ryMYc37zcgelvPw=
go.einride.tech/mage-tools v0.17.0/go.mod h1:Z6r1+t7AAzM8G59LtsD8nM4anNGDHyo2lioYRXL8Ggs=
go.einride.tech/mage-tools v0.25.0 h1:LpqFR/2qXsUJ7096pTgrcI3OdftpCzI3VPLWGaiJLyQ=
go.einride.tech/mage-tools v0.25.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=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 2 additions & 0 deletions .mage/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"go.einride.tech/mage-tools/mgpath"
"go.einride.tech/mage-tools/mgtool"
"go.einride.tech/mage-tools/targets/mgbuf"
"go.einride.tech/mage-tools/targets/mgyamlfmt"

// mage:import
"go.einride.tech/mage-tools/targets/mggo"
Expand Down Expand Up @@ -56,6 +57,7 @@ func All() {
mg.Deps(
mg.F(mgconvco.ConvcoCheck, "origin/master..HEAD"),
mgmarkdownfmt.FormatMarkdown,
mgyamlfmt.FormatYaml,
GoStringer,
Proto.All,
)
Expand Down
8 changes: 0 additions & 8 deletions .mage/mgmake_gen.go

This file was deleted.

35 changes: 14 additions & 21 deletions .mage/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package main

import (
"context"
"fmt"
"os"
"path/filepath"

Expand Down Expand Up @@ -40,40 +39,34 @@ func (Proto) BufLint() {
mg.Deps(mgbuf.BufLint)
}

func (Proto) ProtocGenGo() error {
logger := mglog.Logger("protoc-gen-go")
newer, err := target.Glob("build/protoc-gen-go", ".../go.mod")
if err != nil {
return nil
}
if !newer {
return nil
}
logger.Info("building binary...")
return sh.Run("go", "build", "-o", "build/protoc-gen-go", "google.golang.org/protobuf/cmd/protoc-gen-go")
func (Proto) ProtocGenGo(ctx context.Context) error {
_, err := mgtool.GoInstallWithModfile(
ctx,
"google.golang.org/protobuf/cmd/protoc-gen-go",
mgpath.FromGitRoot("go.mod"),
)
return err
}

func (Proto) ProtocGenGoAip() error {
logger := mglog.Logger("protoc-gen-go-aip")
logger.Info("building binary...")
return sh.Run("go", "build", "-o", "build/protoc-gen-go-aip", "../cmd/protoc-gen-go-aip")
return sh.Run("go", "build", "-o", filepath.Join(mgpath.Bins(), "protoc-gen-go-aip"), "../cmd/protoc-gen-go-aip")
}

func (Proto) ProtocGenGoGrpc(ctx context.Context) error {
_, err := mgtool.GoInstall(ctx, "google.golang.org/grpc/cmd/protoc-gen-go-grpc", "v1.2.0")
return err
}

func (Proto) BufGenerate(ctx context.Context) error {
logger := mglog.Logger("buf-generate")
ctx = logr.NewContext(ctx, logger)
goGrpc, err := mgtool.GoInstall(ctx, "google.golang.org/grpc/cmd/protoc-gen-go-grpc", "v1.2.0")
if err != nil {
return err
}
mg.Deps(
Proto.ProtocGenGo,
Proto.ProtocGenGoGrpc,
Proto.ProtocGenGoAip,
)
path := fmt.Sprintf("%s:%s:%s", os.Getenv("PATH"), filepath.Dir(goGrpc), "../.mage/tools/protoc/3.15.7/bin")
if err := os.Setenv("PATH", path); err != nil {
return err
}
logger.Info("generating protobuf stubs...")
return mgbuf.Buf(ctx, "generate", "--template", "buf.gen.yaml", "--path", "einride")
}
Expand Down
10 changes: 0 additions & 10 deletions .mage/tools.mk

This file was deleted.

53 changes: 30 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,61 @@

.DEFAULT_GOAL := all

include .mage/tools.mk
magefile := .mage/tools/bin/magefile

$(magefile): .mage/go.mod .mage/*.go
@cd .mage && go run go.einride.tech/mage-tools/cmd/build

.PHONY: clean-mage-tools
clean-mage-tools:
@git clean -fdx .mage/tools

.PHONY: all
all: $(mage)
@$(mage) all
all: $(magefile)
@$(magefile) all

.PHONY: buf-generate-testdata
buf-generate-testdata: $(mage)
@$(mage) bufGenerateTestdata
buf-generate-testdata: $(magefile)
@$(magefile) bufGenerateTestdata

.PHONY: convco-check
convco-check: $(mage)
convco-check: $(magefile)
ifndef rev
$(error missing argument rev="...")
endif
@$(mage) convcoCheck $(rev)
@$(magefile) convcoCheck $(rev)

.PHONY: format-markdown
format-markdown: $(mage)
@$(mage) formatMarkdown
format-markdown: $(magefile)
@$(magefile) formatMarkdown

.PHONY: git-verify-no-diff
git-verify-no-diff: $(mage)
@$(mage) gitVerifyNoDiff
git-verify-no-diff: $(magefile)
@$(magefile) gitVerifyNoDiff

.PHONY: go-mod-tidy
go-mod-tidy: $(mage)
@$(mage) goModTidy
go-mod-tidy: $(magefile)
@$(magefile) goModTidy

.PHONY: go-stringer
go-stringer: $(mage)
@$(mage) goStringer
go-stringer: $(magefile)
@$(magefile) goStringer

.PHONY: go-test
go-test: $(mage)
@$(mage) goTest
go-test: $(magefile)
@$(magefile) goTest

.PHONY: golangci-lint
golangci-lint: $(mage)
@$(mage) golangciLint
golangci-lint: $(magefile)
@$(magefile) golangciLint

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

.PHONY: protoc-gen-go-aip
protoc-gen-go-aip: $(mage)
@$(mage) protocGenGoAip
protoc-gen-go-aip: $(magefile)
@$(magefile) protocGenGoAip

.PHONY: proto
proto:
Expand Down
45 changes: 28 additions & 17 deletions proto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,50 @@

.DEFAULT_GOAL := all

include ../.mage/tools.mk
magefile := ../.mage/tools/bin/magefile

$(magefile): ../.mage/go.mod ../.mage/*.go
@cd ../.mage && go run go.einride.tech/mage-tools/cmd/build

.PHONY: clean-mage-tools
clean-mage-tools:
@git clean -fdx ../.mage/tools

.PHONY: all
all: $(mage)
@$(mage) proto:all
all: $(magefile)
@$(magefile) proto:all

.PHONY: api-linter-lint
api-linter-lint: $(mage)
@$(mage) proto:apiLinterLint
api-linter-lint: $(magefile)
@$(magefile) proto:apiLinterLint

.PHONY: buf-generate
buf-generate: $(mage)
@$(mage) proto:bufGenerate
buf-generate: $(magefile)
@$(magefile) proto:bufGenerate

.PHONY: buf-lint
buf-lint: $(mage)
@$(mage) proto:bufLint
buf-lint: $(magefile)
@$(magefile) proto:bufLint

.PHONY: build-descriptor
build-descriptor: $(mage)
@$(mage) proto:buildDescriptor
build-descriptor: $(magefile)
@$(magefile) proto:buildDescriptor

.PHONY: clang-format-proto
clang-format-proto: $(mage)
clang-format-proto: $(magefile)
ifndef path
$(error missing argument path="...")
endif
@$(mage) proto:clangFormatProto $(path)
@$(magefile) proto:clangFormatProto $(path)

.PHONY: protoc-gen-go
protoc-gen-go: $(mage)
@$(mage) proto:protocGenGo
protoc-gen-go: $(magefile)
@$(magefile) proto:protocGenGo

.PHONY: protoc-gen-go-aip
protoc-gen-go-aip: $(mage)
@$(mage) proto:protocGenGoAip
protoc-gen-go-aip: $(magefile)
@$(magefile) proto:protocGenGoAip

.PHONY: protoc-gen-go-grpc
protoc-gen-go-grpc: $(magefile)
@$(magefile) proto:protocGenGoGrpc
1 change: 0 additions & 1 deletion proto/api-linter.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
- included_paths: ["**"]
disabled_rules:
- core::0191 # file options managed by buf
5 changes: 3 additions & 2 deletions proto/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ plugins:
- name: go
out: gen
opt: module=go.einride.tech/aip/proto/gen
path: ./build/protoc-gen-go
path: ../.mage/tools/bin/protoc-gen-go

- name: go-grpc
out: gen
opt:
- module=go.einride.tech/aip/proto/gen
- require_unimplemented_servers=false
path: ../.mage/tools/bin/protoc-gen-go-grpc

- name: go-aip
out: gen
opt: module=go.einride.tech/aip/proto/gen
path: ./build/protoc-gen-go-aip
path: ../.mage/tools/bin/protoc-gen-go-aip

0 comments on commit 2c1305a

Please sign in to comment.