From db05f6525c9311e1510f482c79b7d415e4a19af5 Mon Sep 17 00:00:00 2001 From: itchyny Date: Tue, 26 Sep 2023 13:20:36 +0900 Subject: [PATCH 1/3] Update dependencies --- .github/workflows/ci.yaml | 10 +++++++--- go.mod | 16 ++++++++-------- go.sum | 30 +++++++++++++++--------------- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d2e16b5..dde48ca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,18 +6,22 @@ on: - main pull_request: +permissions: + contents: read + jobs: test: name: Test runs-on: ubuntu-latest strategy: matrix: - go: [1.19.x, 1.18.x] + go: [1.21.x, 1.20.x, 1.19.x] + fail-fast: false steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.go }} - name: Install gocode diff --git a/go.mod b/go.mod index e4cb7f9..4e4127c 100644 --- a/go.mod +++ b/go.mod @@ -1,20 +1,20 @@ module github.com/x-motemen/gore -go 1.18 +go 1.19 require ( - github.com/motemen/go-quickfix v0.0.0-20221231055916-ee806ba52f07 + github.com/motemen/go-quickfix v0.0.0-20230925231438-5cf0001766ff github.com/peterh/liner v1.2.2 github.com/stretchr/testify v1.3.0 - golang.org/x/text v0.5.0 - golang.org/x/tools v0.4.0 + golang.org/x/text v0.13.0 + golang.org/x/tools v0.13.0 ) require ( github.com/davecgh/go-spew v1.1.0 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rivo/uniseg v0.4.3 // indirect - golang.org/x/mod v0.7.0 // indirect - golang.org/x/sys v0.3.0 // indirect + github.com/rivo/uniseg v0.4.4 // indirect + golang.org/x/mod v0.12.0 // indirect + golang.org/x/sys v0.12.0 // indirect ) diff --git a/go.sum b/go.sum index ce564ca..3710234 100644 --- a/go.sum +++ b/go.sum @@ -1,27 +1,27 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/motemen/go-quickfix v0.0.0-20221231055916-ee806ba52f07 h1:ZjYMxV6v8ZaxhueQP0C8dOKWmk5gkm/s0Qi/8P3Tsjk= -github.com/motemen/go-quickfix v0.0.0-20221231055916-ee806ba52f07/go.mod h1:gxZO8gNyIYih9ZEggZ1JvI1qMWCdp9OQrrbwEVdMUwY= +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/motemen/go-quickfix v0.0.0-20230925231438-5cf0001766ff h1:GxE6FXAMf6277RwdspqECes+okYHGnv8H5XMz2SK9/s= +github.com/motemen/go-quickfix v0.0.0-20230925231438-5cf0001766ff/go.mod h1:bqir/ik5G0acBrQTQMnv5mvIq6GC5q66tyNY2yI4lJM= github.com/peterh/liner v1.2.2 h1:aJ4AOodmL+JxOZZEL2u9iJf8omNRpqHc/EbrK+3mAXw= github.com/peterh/liner v1.2.2/go.mod h1:xFwJyiKIXJZUKItq5dGHZSTBRAuG/CpeNpWLyiNRNwI= 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.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= -github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= +github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.4.0 h1:7mTAgkunk3fr4GAloyyCasadO6h9zSsQZbwvcaIciV4= -golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= From f4d714ba2945de39e16cf81a778118c7f5cb0471 Mon Sep 17 00:00:00 2001 From: itchyny Date: Tue, 26 Sep 2023 13:21:47 +0900 Subject: [PATCH 2/3] Catch any exit error and fix tests for new error messages --- session.go | 12 +++--------- session_test.go | 4 ++-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/session.go b/session.go index 5f00b34..54d72ce 100644 --- a/session.go +++ b/session.go @@ -16,7 +16,6 @@ import ( "os/exec" "path/filepath" "strings" - "syscall" "unicode" "golang.org/x/tools/go/packages" @@ -432,14 +431,9 @@ func (s *Session) Eval(in string) error { err := s.Run() if err != nil { - if exitErr, ok := err.(*exec.ExitError); ok { - // if failed with status 2, remove the last statement - if st, ok := exitErr.ProcessState.Sys().(syscall.WaitStatus); ok { - if st.ExitStatus() == 2 { - debugf("got exit status 2, popping out last input") - s.restoreCode() - } - } + if _, ok := err.(*exec.ExitError); ok { + debugf("got exit error, popping out last input") + s.restoreCode() } debugf("%s", err) err = ErrCmdRun diff --git a/session_test.go b/session_test.go index d1ede63..5c614f4 100644 --- a/session_test.go +++ b/session_test.go @@ -379,10 +379,10 @@ func TestSessionEval_Func(t *testing.T) { } assert.Equal(t, "112\n2400\n204\n", stdout.String()) - assert.Regexp(t, `cannot use s \((?:variable of )?type string\) as type int in return (?:argument|statement) + assert.Regexp(t, `cannot use s \((?:variable of )?type string\) as (?:type int|int value) in return (?:argument|statement) invalid operation: f\(\) \+ len\(g\(\)\) \(mismatched types string and int\) invalid operation: f\(\) \* len\(g\(\)\) \(mismatched types string and int\) -cannot use i \((?:variable of )?type int\) as type string in return (?:argument|statement) +cannot use i \((?:variable of )?type int\) as (?:type string|string value) in return (?:argument|statement) `, stderr.String()) } From ec181de25519ddf2a9c505faf9590306bb076d95 Mon Sep 17 00:00:00 2001 From: itchyny Date: Tue, 26 Sep 2023 19:22:41 +0900 Subject: [PATCH 3/3] Setup release flow in GitHub Actions --- .github/workflows/release.yaml | 28 ++++++++++++++++++++++++++++ .gitignore | 2 ++ Makefile | 16 +++++++++++++++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..f31eba4 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,28 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: 1.x + - name: Cross build + run: make cross + - name: Create Release + uses: ncipollo/release-action@v1 + with: + name: Release ${{ github.ref_name }} + artifacts: 'goxz/*' diff --git a/.gitignore b/.gitignore index 822f6d7..1f79482 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ /gore +/goxz +/CREDITS *.exe *.test *.out diff --git a/Makefile b/Makefile index 0f537b9..1555e9a 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,20 @@ show-version: $(GOBIN)/gobump $(GOBIN)/gobump: @go install github.com/x-motemen/gobump/cmd/gobump@latest +.PHONY: cross +cross: $(GOBIN)/goxz CREDITS + goxz -n $(BIN) -pv=v$(VERSION) -build-ldflags=$(BUILD_LDFLAGS) ./cmd/$(BIN) + +$(GOBIN)/goxz: + go install github.com/Songmu/goxz/cmd/goxz@latest + +CREDITS: $(GOBIN)/gocredits go.sum + go mod tidy + gocredits -w . + +$(GOBIN)/gocredits: + go install github.com/Songmu/gocredits/cmd/gocredits@latest + .PHONY: test test: build go test -v ./... # we don't use -race which increases much duration @@ -37,7 +51,7 @@ $(GOBIN)/staticcheck: .PHONY: clean clean: - rm -f $(BIN) + rm -f $(BIN) goxz CREDITS go clean .PHONY: bump