-
Notifications
You must be signed in to change notification settings - Fork 11
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
33 changed files
with
425 additions
and
456 deletions.
There are no files selected for viewing
File renamed without changes.
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 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,34 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Sage | ||
uses: einride/sage/actions/setup@master | ||
|
||
- name: Make | ||
run: make | ||
|
||
- name: Release | ||
uses: go-semantic-release/action@v1.17 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
allow-initial-development-versions: true | ||
|
||
- name: Fetch tags | ||
run: git fetch --force --tags | ||
|
||
- name: Run goreleaser | ||
uses: goreleaser/goreleaser-action@v2.9.1 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,15 @@ | ||
name: review | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
make: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Sage | ||
uses: einride/sage/actions/setup@master | ||
|
||
- name: Make | ||
run: make |
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,62 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
|
||
"go.einride.tech/sage/sg" | ||
"go.einride.tech/sage/sgtool" | ||
) | ||
|
||
const ( | ||
name = "eslint" | ||
packageJSONContent = `{ | ||
"dependencies": { | ||
"@einride/eslint-plugin": "4.2.0", | ||
"eslint": "8.5.0" | ||
} | ||
}` | ||
) | ||
|
||
func eslintCommand(ctx context.Context, args ...string) *exec.Cmd { | ||
sg.Deps(ctx, prepareEslintCommand) | ||
// eslint plugins should be resolved from the tool dir | ||
defaultArgs := []string{ | ||
"--resolve-plugins-relative-to", | ||
sg.FromToolsDir(name), | ||
} | ||
cmd := sg.Command(ctx, sg.FromBinDir(name), append(defaultArgs, args...)...) | ||
return cmd | ||
} | ||
|
||
func prepareEslintCommand(ctx context.Context) error { | ||
toolDir := sg.FromToolsDir(name) | ||
binary := filepath.Join(toolDir, "node_modules", ".bin", name) | ||
packageJSON := filepath.Join(toolDir, "package.json") | ||
if err := os.MkdirAll(toolDir, 0o755); err != nil { | ||
return err | ||
} | ||
if err := os.WriteFile(packageJSON, []byte(packageJSONContent), 0o600); err != nil { | ||
return err | ||
} | ||
sg.Logger(ctx).Println("installing packages...") | ||
if err := sg.Command( | ||
ctx, | ||
"npm", | ||
"--silent", | ||
"install", | ||
"--prefix", | ||
toolDir, | ||
"--no-save", | ||
"--no-audit", | ||
"--ignore-script", | ||
).Run(); err != nil { | ||
return err | ||
} | ||
if _, err := sgtool.CreateSymlink(binary); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
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,56 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"go.einride.tech/sage/sg" | ||
"go.einride.tech/sage/tools/sgbuf" | ||
) | ||
|
||
type Proto sg.Namespace | ||
|
||
func (Proto) All(ctx context.Context) error { | ||
sg.SerialDeps(ctx, Proto.Build) | ||
sg.Deps(ctx, Proto.BufLint, Proto.BufFormat, Proto.BufGenerate) | ||
return nil | ||
} | ||
|
||
func (Proto) Build(ctx context.Context) error { | ||
sg.Logger(ctx).Println("installing binary...") | ||
return sg.Command( | ||
ctx, | ||
"go", | ||
"build", | ||
"-o", | ||
sg.FromBinDir("protoc-gen-typescript-http"), | ||
".", | ||
).Run() | ||
} | ||
|
||
func (Proto) BufLint(ctx context.Context) error { | ||
sg.Logger(ctx).Println("linting proto files...") | ||
cmd := sgbuf.Command(ctx, "lint") | ||
cmd.Dir = sg.FromGitRoot("examples", "proto") | ||
return cmd.Run() | ||
} | ||
|
||
func (Proto) BufFormat(ctx context.Context) error { | ||
sg.Logger(ctx).Println("formatting proto files...") | ||
cmd := sgbuf.Command(ctx, "format", "--write") | ||
cmd.Dir = sg.FromGitRoot("examples", "proto") | ||
return cmd.Run() | ||
} | ||
|
||
func (Proto) BufGenerate(ctx context.Context) error { | ||
sg.Logger(ctx).Println("generating from proto files...") | ||
cmd := sgbuf.Command( | ||
ctx, | ||
"generate", | ||
"--template", | ||
"buf.gen.yaml", | ||
"--path", | ||
"einride", | ||
) | ||
cmd.Dir = sg.FromGitRoot("examples", "proto") | ||
return cmd.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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
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, | ||
}, | ||
sg.Makefile{ | ||
Namespace: Proto{}, | ||
DefaultTarget: Proto.All, | ||
Path: sg.FromGitRoot("examples", "proto", "Makefile"), | ||
}, | ||
) | ||
} | ||
|
||
func All(ctx context.Context) error { | ||
sg.Deps(ctx, ConvcoCheck, GoLint, GoReview, GoTest, FormatMarkdown, FormatYAML) | ||
sg.SerialDeps(ctx, Proto.All, TypescriptLint) | ||
sg.SerialDeps(ctx, 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 TypescriptLint(ctx context.Context) error { | ||
sg.Logger(ctx).Println("linting typescript files...") | ||
return eslintCommand( | ||
ctx, | ||
"--config", | ||
sg.FromGitRoot(".eslintrc.js"), | ||
"--quiet", | ||
"examples/proto/gen/typescript/**/*.ts", | ||
).Run() | ||
} |
Oops, something went wrong.