-
Notifications
You must be signed in to change notification settings - Fork 3
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
7 changed files
with
183 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: gomod | ||
directory: .sage | ||
schedule: | ||
interval: weekly |
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 go.einride.tech/backstage/.sage | ||
|
||
go 1.20 | ||
|
||
require go.einride.tech/sage v0.212.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.212.0 h1:0v5rBRBA/v1lX4hxf0EDSOhPDi366VXAybxh4Rhqu7w= | ||
go.einride.tech/sage v0.212.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,78 @@ | ||
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/sggolicenses" | ||
"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: Default, | ||
}, | ||
) | ||
} | ||
|
||
func Default(ctx context.Context) error { | ||
sg.Deps(ctx, ConvcoCheck, FormatMarkdown, FormatYaml) | ||
sg.Deps(ctx, GoLint, GoReview) | ||
sg.Deps(ctx, GoTest) | ||
sg.Deps(ctx, GoModTidy) | ||
sg.Deps(ctx, GoLicenses, GitVerifyNoDiff) | ||
return nil | ||
} | ||
|
||
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.Run(ctx) | ||
} | ||
|
||
func GoLint(ctx context.Context) error { | ||
sg.Logger(ctx).Println("linting Go files...") | ||
return sggolangcilint.Run(ctx) | ||
} | ||
|
||
func GoLicenses(ctx context.Context) error { | ||
sg.Logger(ctx).Println("checking Go licenses...") | ||
return sggolicenses.Check(ctx) | ||
} | ||
|
||
func FormatMarkdown(ctx context.Context) error { | ||
sg.Logger(ctx).Println("formatting Markdown files...") | ||
return sgmarkdownfmt.Command(ctx, "-w", ".").Run() | ||
} | ||
|
||
func FormatYaml(ctx context.Context) error { | ||
sg.Logger(ctx).Println("formatting Yaml files...") | ||
return sgyamlfmt.Run(ctx) | ||
} | ||
|
||
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) | ||
} |
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,84 @@ | ||
# Code generated by go.einride.tech/sage. DO NOT EDIT. | ||
# To learn more, see .sage/main.go and https://github.com/einride/sage. | ||
|
||
.DEFAULT_GOAL := default | ||
|
||
cwd := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
sagefile := $(abspath $(cwd)/.sage/bin/sagefile) | ||
|
||
# Setup Go. | ||
go := $(shell command -v go 2>/dev/null) | ||
export GOWORK ?= off | ||
ifndef go | ||
SAGE_GO_VERSION ?= 1.18.4 | ||
export GOROOT := $(abspath $(cwd)/.sage/tools/go/$(SAGE_GO_VERSION)/go) | ||
export PATH := $(PATH):$(GOROOT)/bin | ||
go := $(GOROOT)/bin/go | ||
os := $(shell uname | tr '[:upper:]' '[:lower:]') | ||
arch := $(shell uname -m) | ||
ifeq ($(arch),x86_64) | ||
arch := amd64 | ||
endif | ||
$(go): | ||
$(info installing Go $(SAGE_GO_VERSION)...) | ||
@mkdir -p $(dir $(GOROOT)) | ||
@curl -sSL https://go.dev/dl/go$(SAGE_GO_VERSION).$(os)-$(arch).tar.gz | tar xz -C $(dir $(GOROOT)) | ||
@touch $(GOROOT)/go.mod | ||
@chmod +x $(go) | ||
endif | ||
|
||
.PHONY: $(sagefile) | ||
$(sagefile): $(go) | ||
@cd .sage && $(go) mod tidy && $(go) run . | ||
|
||
.PHONY: sage | ||
sage: | ||
@$(MAKE) $(sagefile) | ||
|
||
.PHONY: update-sage | ||
update-sage: $(go) | ||
@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: convco-check | ||
convco-check: $(sagefile) | ||
@$(sagefile) ConvcoCheck | ||
|
||
.PHONY: default | ||
default: $(sagefile) | ||
@$(sagefile) Default | ||
|
||
.PHONY: format-markdown | ||
format-markdown: $(sagefile) | ||
@$(sagefile) FormatMarkdown | ||
|
||
.PHONY: format-yaml | ||
format-yaml: $(sagefile) | ||
@$(sagefile) FormatYaml | ||
|
||
.PHONY: git-verify-no-diff | ||
git-verify-no-diff: $(sagefile) | ||
@$(sagefile) GitVerifyNoDiff | ||
|
||
.PHONY: go-licenses | ||
go-licenses: $(sagefile) | ||
@$(sagefile) GoLicenses | ||
|
||
.PHONY: go-lint | ||
go-lint: $(sagefile) | ||
@$(sagefile) GoLint | ||
|
||
.PHONY: go-mod-tidy | ||
go-mod-tidy: $(sagefile) | ||
@$(sagefile) GoModTidy | ||
|
||
.PHONY: go-review | ||
go-review: $(sagefile) | ||
@$(sagefile) GoReview | ||
|
||
.PHONY: go-test | ||
go-test: $(sagefile) | ||
@$(sagefile) GoTest |
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