Skip to content

Commit

Permalink
Merge pull request #224 from x-motemen/fix-misc-20230926
Browse files Browse the repository at this point in the history
Update dependencies and create release with built artifacts
  • Loading branch information
itchyny authored Sep 26, 2023
2 parents 49bec63 + ec181de commit cb09b0b
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 38 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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/*'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/gore
/goxz
/CREDITS
*.exe
*.test
*.out
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,7 +51,7 @@ $(GOBIN)/staticcheck:

.PHONY: clean
clean:
rm -f $(BIN)
rm -f $(BIN) goxz CREDITS
go clean

.PHONY: bump
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
30 changes: 15 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
12 changes: 3 additions & 9 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"os/exec"
"path/filepath"
"strings"
"syscall"
"unicode"

"golang.org/x/tools/go/packages"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down

0 comments on commit cb09b0b

Please sign in to comment.