-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
158 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,20 +8,14 @@ jobs: | |
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ^1.17 | ||
- name: Setup Sage | ||
uses: einride/sage/actions/setup@master | ||
|
||
- name: Make | ||
run: make | ||
|
||
- name: Report Code Coverage | ||
uses: codecov/[email protected] | ||
with: | ||
file: .mage/tools/go/coverage/go-test.txt | ||
file: .sage/build/go/coverage/go-test.txt | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module sage | ||
|
||
go 1.17 | ||
|
||
require go.einride.tech/sage v0.106.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
go.einride.tech/sage v0.106.0 h1:HtfQDCPZTfNA3QLdB7lDqA8vPsgMmn6ERR4Y+qqJFcU= | ||
go.einride.tech/sage v0.106.0/go.mod h1:EzV5uciFX7/2ho8EKB5K9JghOfXIxlzs694b+Tkl5GQ= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"go.einride.tech/sage/sg" | ||
"go.einride.tech/sage/tools/sgconvco" | ||
"go.einride.tech/sage/tools/sggit" | ||
"go.einride.tech/sage/tools/sggo" | ||
"go.einride.tech/sage/tools/sggolangcilint" | ||
"go.einride.tech/sage/tools/sggoreview" | ||
"go.einride.tech/sage/tools/sgmarkdownfmt" | ||
"go.einride.tech/sage/tools/sgyamlfmt" | ||
) | ||
|
||
func main() { | ||
sg.GenerateMakefiles( | ||
sg.Makefile{ | ||
Path: sg.FromGitRoot("Makefile"), | ||
DefaultTarget: All, | ||
}, | ||
) | ||
} | ||
|
||
func All(ctx context.Context) error { | ||
sg.Deps(ctx, ConvcoCheck, FormatMarkdown, FormatYAML) | ||
sg.Deps(ctx, GoLint, GoReview) | ||
sg.Deps(ctx, SpannerGenerate) | ||
sg.SerialDeps(ctx, GoTest, GoModTidy, GitVerifyNoDiff) | ||
return nil | ||
} | ||
|
||
func FormatYAML(ctx context.Context) error { | ||
sg.Logger(ctx).Println("formatting YAML files...") | ||
return sgyamlfmt.Command(ctx, "-d", sg.FromGitRoot(), "-r").Run() | ||
} | ||
|
||
func GoModTidy(ctx context.Context) error { | ||
sg.Logger(ctx).Println("tidying Go module files...") | ||
return sg.Command(ctx, "go", "mod", "tidy", "-v").Run() | ||
} | ||
|
||
func GoTest(ctx context.Context) error { | ||
sg.Logger(ctx).Println("running Go tests...") | ||
return sggo.TestCommand(ctx).Run() | ||
} | ||
|
||
func GoReview(ctx context.Context) error { | ||
sg.Logger(ctx).Println("reviewing Go files...") | ||
return sggoreview.Command(ctx, "-c", "1", "./...").Run() | ||
} | ||
|
||
func GoLint(ctx context.Context) error { | ||
sg.Logger(ctx).Println("linting Go files...") | ||
return sggolangcilint.Run(ctx) | ||
} | ||
|
||
func FormatMarkdown(ctx context.Context) error { | ||
sg.Logger(ctx).Println("formatting Markdown files...") | ||
return sgmarkdownfmt.Command(ctx, "-w", ".").Run() | ||
} | ||
|
||
func ConvcoCheck(ctx context.Context) error { | ||
sg.Logger(ctx).Println("checking git commits...") | ||
return sgconvco.Command(ctx, "check", "origin/master..HEAD").Run() | ||
} | ||
|
||
func GitVerifyNoDiff(ctx context.Context) error { | ||
sg.Logger(ctx).Println("verifying that git has no diff...") | ||
return sggit.VerifyNoDiff(ctx) | ||
} | ||
|
||
func SpannerGenerate(ctx context.Context) error { | ||
sg.Logger(ctx).Println("generating Spanner code...") | ||
return sg.Command(ctx, "go", "run", ".", "generate").Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,62 @@ | ||
# Code generated by go.einride.tech/mage-tools. DO NOT EDIT. | ||
# To learn more, see .mage/magefile.go and https://github.com/einride/mage-tools. | ||
# Code generated by go.einride.tech/sage. DO NOT EDIT. | ||
# To learn more, see .sage/sagefile.go and https://github.com/einride/sage. | ||
|
||
.DEFAULT_GOAL := all | ||
|
||
magefile := .mage/tools/bin/magefile | ||
sagefile := .sage/bin/sagefile | ||
|
||
$(magefile): .mage/go.mod .mage/*.go | ||
@cd .mage && go run go.einride.tech/mage-tools/cmd/build | ||
$(sagefile): .sage/go.mod .sage/*.go | ||
@cd .sage && go mod tidy && go run . | ||
|
||
.PHONY: clean-mage-tools | ||
clean-mage-tools: | ||
@git clean -fdx .mage/tools | ||
.PHONY: sage | ||
sage: | ||
@git clean -fxq $(sagefile) | ||
@$(MAKE) $(sagefile) | ||
|
||
.PHONY: update-sage | ||
update-sage: | ||
@cd .sage && go get -d go.einride.tech/sage@latest && go mod tidy && go run . | ||
|
||
.PHONY: clean-sage | ||
clean-sage: | ||
@git clean -fdx .sage/tools .sage/bin .sage/build | ||
|
||
.PHONY: all | ||
all: $(magefile) | ||
@$(magefile) all | ||
all: $(sagefile) | ||
@$(sagefile) All | ||
|
||
.PHONY: convco-check | ||
convco-check: $(magefile) | ||
ifndef rev | ||
$(error missing argument rev="...") | ||
endif | ||
@$(magefile) convcoCheck $(rev) | ||
convco-check: $(sagefile) | ||
@$(sagefile) ConvcoCheck | ||
|
||
.PHONY: format-markdown | ||
format-markdown: $(magefile) | ||
@$(magefile) formatMarkdown | ||
format-markdown: $(sagefile) | ||
@$(sagefile) FormatMarkdown | ||
|
||
.PHONY: format-yaml | ||
format-yaml: $(magefile) | ||
@$(magefile) formatYaml | ||
format-yaml: $(sagefile) | ||
@$(sagefile) FormatYAML | ||
|
||
.PHONY: git-verify-no-diff | ||
git-verify-no-diff: $(magefile) | ||
@$(magefile) gitVerifyNoDiff | ||
git-verify-no-diff: $(sagefile) | ||
@$(sagefile) GitVerifyNoDiff | ||
|
||
.PHONY: go-lint | ||
go-lint: $(sagefile) | ||
@$(sagefile) GoLint | ||
|
||
.PHONY: go-mod-tidy | ||
go-mod-tidy: $(magefile) | ||
@$(magefile) goModTidy | ||
go-mod-tidy: $(sagefile) | ||
@$(sagefile) GoModTidy | ||
|
||
.PHONY: go-test | ||
go-test: $(magefile) | ||
@$(magefile) goTest | ||
.PHONY: go-review | ||
go-review: $(sagefile) | ||
@$(sagefile) GoReview | ||
|
||
.PHONY: golangci-lint | ||
golangci-lint: $(magefile) | ||
@$(magefile) golangciLint | ||
.PHONY: go-test | ||
go-test: $(sagefile) | ||
@$(sagefile) GoTest | ||
|
||
.PHONY: spanner-generate | ||
spanner-generate: $(magefile) | ||
@$(magefile) spannerGenerate | ||
spanner-generate: $(sagefile) | ||
@$(sagefile) SpannerGenerate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters