Skip to content

Commit

Permalink
Migrate from mage to goyek (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga authored May 2, 2024
1 parent 6fe8bd2 commit 234c42f
Show file tree
Hide file tree
Showing 16 changed files with 138 additions and 74 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
fail-fast: false
matrix:
os:
- macos-12
- macos-13
- macos-14
- ubuntu-22.04
- windows-2022
steps:
Expand All @@ -26,9 +27,11 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: "**/go.sum"

- name: run checks
run: go run mage check
run: go run build check

- name: build snapshot
run: go run mage snapshot
if: startsWith(matrix.os, 'ubuntu-')
run: go run build snapshot
3 changes: 2 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: "**/go.sum"

- run: go run mage release
- run: go run build release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.idea
.vscode
build
out
dist
go.work.sum

32 changes: 32 additions & 0 deletions build/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module build

go 1.22

require (
github.com/goyek/x v0.1.7
github.com/wasilibs/tools v0.0.0-20240501081123-9453b4e4849b
)

require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/cli/go-gh/v2 v2.9.0 // indirect
github.com/cli/safeexec v1.0.0 // indirect
github.com/cli/shurcooL-graphql v0.0.4 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/goyek/goyek/v2 v2.1.0 // indirect
github.com/henvic/httpretty v0.0.6 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-shellwords v1.0.12 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/thlib/go-timezone-local v0.0.0-20210907160436-ef149e42d28e // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
69 changes: 69 additions & 0 deletions build/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/cli/go-gh/v2 v2.9.0 h1:D3lTjEneMYl54M+WjZ+kRPrR5CEJ5BHS05isBPOV3LI=
github.com/cli/go-gh/v2 v2.9.0/go.mod h1:MeRoKzXff3ygHu7zP+NVTT+imcHW6p3tpuxHAzRM2xE=
github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI=
github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
github.com/cli/shurcooL-graphql v0.0.4 h1:6MogPnQJLjKkaXPyGqPRXOI2qCsQdqNfUY1QSJu2GuY=
github.com/cli/shurcooL-graphql v0.0.4/go.mod h1:3waN4u02FiZivIV+p1y4d0Jo1jc6BViMA73C+sZo2fk=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/goyek/goyek/v2 v2.1.0 h1:As5r5j6XxfcJMADfgMYJdxsp1vy9IinT6AKPbCt6fi4=
github.com/goyek/goyek/v2 v2.1.0/go.mod h1:qtHlK7t/dYs1Dw7mLXjEVmgE3nccNa7mQW/RmasOoYg=
github.com/goyek/x v0.1.7 h1:nh0gplLi491oommklcR2Kd2f92EP3cugOfPjpUwtRes=
github.com/goyek/x v0.1.7/go.mod h1:z4MsI/oYknI36ubaSfVomDYz6i4MjsQ1bk69PY3HtIo=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
github.com/henvic/httpretty v0.0.6 h1:JdzGzKZBajBfnvlMALXXMVQWxWMF/ofTy8C3/OSUTxs=
github.com/henvic/httpretty v0.0.6/go.mod h1:X38wLjWXHkXT7r2+uK8LjCMne9rsuNaBLJ+5cU2/Pmo=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/thlib/go-timezone-local v0.0.0-20210907160436-ef149e42d28e h1:BuzhfgfWQbX0dWzYzT1zsORLnHRv3bcRcsaUk0VmXA8=
github.com/thlib/go-timezone-local v0.0.0-20210907160436-ef149e42d28e/go.mod h1:/Tnicc6m/lsJE0irFMA0LfIwTBo4QP7A8IfyIv4zZKI=
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY=
gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
15 changes: 15 additions & 0 deletions build/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import (
"github.com/goyek/x/boot"
"github.com/wasilibs/tools/tasks"
)

func main() {
tasks.Define(tasks.Params{
LibraryName: "protoc",
LibraryRepo: "protocolbuffers/protobuf",
GoReleaser: true,
})
boot.Main()
}
5 changes: 2 additions & 3 deletions go.work
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
go 1.21
go 1.22

use (
.
./mage
./magefiles
./build
)
5 changes: 0 additions & 5 deletions mage/go.mod

This file was deleted.

2 changes: 0 additions & 2 deletions mage/go.sum

This file was deleted.

13 changes: 0 additions & 13 deletions mage/main.go

This file was deleted.

7 changes: 0 additions & 7 deletions magefiles/go.mod

This file was deleted.

4 changes: 0 additions & 4 deletions magefiles/go.sum

This file was deleted.

21 changes: 0 additions & 21 deletions magefiles/magefile.go

This file was deleted.

3 changes: 0 additions & 3 deletions magefiles/versions.go

This file was deleted.

16 changes: 8 additions & 8 deletions protoc_gen_ts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
)

func TestBuf(t *testing.T) {
if err := os.RemoveAll(filepath.Join("build", "buf")); err != nil {
if err := os.RemoveAll(filepath.Join("out", "buf")); err != nil {
t.Fatalf("failed to remove build directory: %v", err)
}

output := bytes.Buffer{}
cmd := exec.Command("go", "run", "github.com/bufbuild/buf/cmd/buf@v1.28.1", "generate")
cmd := exec.Command("go", "run", "github.com/bufbuild/buf/cmd/buf@v1.31.0", "generate")
cmd.Stderr = &output
cmd.Stdout = &output
cmd.Dir = "testdata"
Expand All @@ -24,7 +24,7 @@ func TestBuf(t *testing.T) {
}

for _, path := range []string{
filepath.Join("build", "buf", "ts", "helloworld.ts"),
filepath.Join("out", "buf", "ts", "helloworld.ts"),
} {
if _, err := os.Stat(path); err != nil {
t.Errorf("failed to stat %v: %v", path, err)
Expand All @@ -37,17 +37,17 @@ func TestProtoc(t *testing.T) {
t.Skip("protoc not found")
}

outDir := filepath.Join("build", "protoc")
outDir := filepath.Join("out", "protoc")
if err := os.RemoveAll(outDir); err != nil {
t.Fatalf("failed to remove build directory: %v", err)
}
if err := os.RemoveAll(filepath.Join("build", "plugins")); err != nil {
if err := os.RemoveAll(filepath.Join("out", "plugins")); err != nil {
t.Fatalf("failed to remove build directory: %v", err)
}

plugin := "ts"
output := bytes.Buffer{}
cmd := exec.Command("go", "build", "-o", filepath.Join("build", "plugins", "protoc-gen-"+plugin), "./cmd/protoc-gen-"+plugin)
cmd := exec.Command("go", "build", "-o", filepath.Join("out", "plugins", "protoc-gen-"+plugin), "./cmd/protoc-gen-"+plugin)
cmd.Stderr = &output
cmd.Stdout = &output
if err := cmd.Run(); err != nil {
Expand All @@ -61,7 +61,7 @@ func TestProtoc(t *testing.T) {
env := os.Environ()
for i, val := range env {
if strings.HasPrefix(val, "PATH=") {
env[i] = "PATH=" + filepath.Join("build", "plugins") + string(os.PathListSeparator) + val[len("PATH="):]
env[i] = "PATH=" + filepath.Join("out", "plugins") + string(os.PathListSeparator) + val[len("PATH="):]
}
}
cmd = exec.Command(
Expand All @@ -78,7 +78,7 @@ func TestProtoc(t *testing.T) {
}

for _, path := range []string{
filepath.Join("build", "protoc", "ts", "helloworld.ts"),
filepath.Join("out", "protoc", "ts", "helloworld.ts"),
} {
if _, err := os.Stat(path); err != nil {
t.Errorf("failed to stat %v: %v", path, err)
Expand Down
6 changes: 3 additions & 3 deletions testdata/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
plugins:
- plugin: ts
out: ../build/buf/ts
path: ["go", "run", "../cmd/protoc-gen-ts"]
- plugin: ts
out: ../out/buf/ts
path: ["go", "run", "../cmd/protoc-gen-ts"]

0 comments on commit 234c42f

Please sign in to comment.