From 5752100352b6f58d4b1f400faaf7fe925222acf2 Mon Sep 17 00:00:00 2001 From: web3-bot Date: Tue, 17 Aug 2021 13:32:38 +0000 Subject: [PATCH 1/8] disable Travis --- .travis.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3d81468d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -os: - - linux - -language: go - -go: - - 1.14.2 - -env: - global: - - GOTFLAGS="-race" - matrix: - - BUILD_DEPTYPE=gomod - - -# disable travis install -install: - - true - -script: - - bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh) - - -cache: - directories: - - $GOPATH/pkg/mod - - $HOME/.cache/go-build - -notifications: - email: false From 245d007069a95b75fceeff2a1b25d931c8084504 Mon Sep 17 00:00:00 2001 From: web3-bot Date: Tue, 17 Aug 2021 13:32:39 +0000 Subject: [PATCH 2/8] bump go.mod to Go 1.16 and run go fix --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 484d0e4c..075bc419 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ipfs/go-ipfs-cmds -go 1.14 +go 1.16 require ( github.com/Kubuxu/go-os-helper v0.0.1 From 15e8f797c0199ab64e837cff201228f289f16341 Mon Sep 17 00:00:00 2001 From: web3-bot Date: Tue, 17 Aug 2021 13:32:40 +0000 Subject: [PATCH 3/8] run go mod tidy --- go.sum | 3 --- 1 file changed, 3 deletions(-) diff --git a/go.sum b/go.sum index 606ab5e5..9d2390bd 100644 --- a/go.sum +++ b/go.sum @@ -18,10 +18,8 @@ github.com/ipfs/go-log/v2 v2.0.5 h1:fL4YI+1g5V/b1Yxr1qAiXTMg1H8z9vx/VmJxBuQMHvU= github.com/ipfs/go-log/v2 v2.0.5/go.mod h1:eZs4Xt4ZUJQFM3DlanGhy7TkwwawCZcSByscwkWG+dw= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -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/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -70,7 +68,6 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64 golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/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/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= From a964f18522e32d14c0e55f1393dd3297ba0929cf Mon Sep 17 00:00:00 2001 From: web3-bot Date: Tue, 17 Aug 2021 13:32:40 +0000 Subject: [PATCH 4/8] run gofmt -s --- cli/error_posix.go | 3 ++- cli/error_windows.go | 3 ++- cli/parse_test.go | 12 ++++++------ cli/responseemitter_test.go | 4 ++-- cli/run_test.go | 2 +- command_test.go | 6 +++--- examples/adder/cmd.go | 8 ++++---- executor_test.go | 4 ++-- http/handler_test.go | 22 +++++++++++----------- http/parse_test.go | 4 ++-- maybeerror_test.go | 32 ++++++++++++++++---------------- opts.go | 2 -- response.go | 2 -- 13 files changed, 51 insertions(+), 53 deletions(-) diff --git a/cli/error_posix.go b/cli/error_posix.go index 7ab44166..03773212 100644 --- a/cli/error_posix.go +++ b/cli/error_posix.go @@ -1,4 +1,5 @@ -//+build !windows,!plan9 +//go:build !windows && !plan9 +// +build !windows,!plan9 package cli diff --git a/cli/error_windows.go b/cli/error_windows.go index 0a2d9a31..e86f3b84 100644 --- a/cli/error_windows.go +++ b/cli/error_windows.go @@ -1,4 +1,5 @@ -//+build windows +//go:build windows +// +build windows package cli diff --git a/cli/parse_test.go b/cli/parse_test.go index 5fd52198..10bd97a0 100644 --- a/cli/parse_test.go +++ b/cli/parse_test.go @@ -105,8 +105,8 @@ func TestOptionParsing(t *testing.T) { cmds.DelimitedStringsOption(",", "delimstrings", "d", "comma delimited string array"), }, Subcommands: map[string]*cmds.Command{ - "test": &cmds.Command{}, - "defaults": &cmds.Command{ + "test": {}, + "defaults": { Options: []cmds.Option{ cmds.StringOption("opt", "o", "an option").WithDefault("def"), }, @@ -265,7 +265,7 @@ func TestDefaultOptionParsing(t *testing.T) { cmd := &cmds.Command{ Subcommands: map[string]*cmds.Command{ - "defaults": &cmds.Command{ + "defaults": { Options: []cmds.Option{ cmds.StringOption("string", "s", "a string").WithDefault("foo"), cmds.StringsOption("strings1", "a", "a string array").WithDefault([]string{"foo"}), @@ -435,18 +435,18 @@ func TestBodyArgs(t *testing.T) { cmds.StringArg("a", true, true, "some arg").EnableStdin(), }, }, - "stdinenabled2args": &cmds.Command{ + "stdinenabled2args": { Arguments: []cmds.Argument{ cmds.StringArg("a", true, false, "some arg"), cmds.StringArg("b", true, true, "another arg").EnableStdin(), }, }, - "stdinenablednotvariadic": &cmds.Command{ + "stdinenablednotvariadic": { Arguments: []cmds.Argument{ cmds.StringArg("a", true, false, "some arg").EnableStdin(), }, }, - "stdinenablednotvariadic2args": &cmds.Command{ + "stdinenablednotvariadic2args": { Arguments: []cmds.Argument{ cmds.StringArg("a", true, false, "some arg"), cmds.StringArg("b", true, false, "another arg").EnableStdin(), diff --git a/cli/responseemitter_test.go b/cli/responseemitter_test.go index ab7e0f59..69c011e1 100644 --- a/cli/responseemitter_test.go +++ b/cli/responseemitter_test.go @@ -42,7 +42,7 @@ func (tc tcCloseWithError) Run(t *testing.T) { func TestCloseWithError(t *testing.T) { tcs := []tcCloseWithError{ - tcCloseWithError{ + { stdout: bytes.NewBuffer(nil), stderr: bytes.NewBuffer(nil), exStdout: "a\n", @@ -54,7 +54,7 @@ func TestCloseWithError(t *testing.T) { re.Emit("b") }, }, - tcCloseWithError{ + { stdout: bytes.NewBuffer(nil), stderr: bytes.NewBuffer(nil), exStdout: "a\n", diff --git a/cli/run_test.go b/cli/run_test.go index a843e015..d318bc11 100644 --- a/cli/run_test.go +++ b/cli/run_test.go @@ -11,7 +11,7 @@ import ( var root = &cmds.Command{ Subcommands: map[string]*cmds.Command{ - "test": &cmds.Command{ + "test": { Run: func(req *cmds.Request, re cmds.ResponseEmitter, e cmds.Environment) error { err := cmds.EmitOnce(re, 42) diff --git a/command_test.go b/command_test.go index fdfc0c9c..4e57bb00 100644 --- a/command_test.go +++ b/command_test.go @@ -130,8 +130,8 @@ func TestResolving(t *testing.T) { func TestWalking(t *testing.T) { cmdA := &Command{ Subcommands: map[string]*Command{ - "b": &Command{}, - "B": &Command{}, + "b": {}, + "B": {}, }, } i := 0 @@ -181,7 +181,7 @@ func TestPostRun(t *testing.T) { defer cancel() var testcases = []postRunTestCase{ - postRunTestCase{ + { length: 3, err: nil, emit: []interface{}{7}, diff --git a/examples/adder/cmd.go b/examples/adder/cmd.go index 2c859211..58af9577 100644 --- a/examples/adder/cmd.go +++ b/examples/adder/cmd.go @@ -24,7 +24,7 @@ type AddStatus struct { var RootCmd = &cmds.Command{ Subcommands: map[string]*cmds.Command{ // the simplest way to make an adder - "simpleAdd": &cmds.Command{ + "simpleAdd": { Arguments: []cmds.Argument{ cmds.StringArg("summands", true, true, "values that are supposed to be summed"), }, @@ -48,7 +48,7 @@ var RootCmd = &cmds.Command{ }, }, // a bit more sophisticated - "encodeAdd": &cmds.Command{ + "encodeAdd": { Arguments: []cmds.Argument{ cmds.StringArg("summands", true, true, "values that are supposed to be summed"), }, @@ -94,7 +94,7 @@ var RootCmd = &cmds.Command{ }, }, // the best UX - "postRunAdd": &cmds.Command{ + "postRunAdd": { Arguments: []cmds.Argument{ cmds.StringArg("summands", true, true, "values that are supposed to be summed"), }, @@ -152,7 +152,7 @@ var RootCmd = &cmds.Command{ }, }, // how to set program's return value - "exitAdd": &cmds.Command{ + "exitAdd": { Arguments: []cmds.Argument{ cmds.StringArg("summands", true, true, "values that are supposed to be summed"), }, diff --git a/executor_test.go b/executor_test.go index 71605ab2..d7f04efd 100644 --- a/executor_test.go +++ b/executor_test.go @@ -12,13 +12,13 @@ var errGeneric = errors.New("an error occurred") var root = &Command{ Subcommands: map[string]*Command{ - "test": &Command{ + "test": { Run: func(req *Request, re ResponseEmitter, env Environment) error { re.Emit(env) return nil }, }, - "testError": &Command{ + "testError": { Run: func(req *Request, re ResponseEmitter, env Environment) error { err := errGeneric if err != nil { diff --git a/http/handler_test.go b/http/handler_test.go index ba8dd147..3c5cfc71 100644 --- a/http/handler_test.go +++ b/http/handler_test.go @@ -65,19 +65,19 @@ var ( }, Subcommands: map[string]*cmds.Command{ - "error": &cmds.Command{ + "error": { Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { return errors.New("an error occurred") }, }, - "lateerror": &cmds.Command{ + "lateerror": { Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { re.Emit("some value") return errors.New("an error occurred") }, Type: "", }, - "encode": &cmds.Command{ + "encode": { Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { return errors.New("an error occurred") }, @@ -89,7 +89,7 @@ var ( }), }, }, - "lateencode": &cmds.Command{ + "lateencode": { Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { re.Emit("hello") return errors.New("an error occurred") @@ -105,7 +105,7 @@ var ( }), }, }, - "protoencode": &cmds.Command{ + "protoencode": { Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { return errors.New("an error occurred") }, @@ -117,7 +117,7 @@ var ( }), }, }, - "protolateencode": &cmds.Command{ + "protolateencode": { Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { re.Emit("hello") return errors.New("an error occurred") @@ -130,7 +130,7 @@ var ( }), }, }, - "doubleclose": &cmds.Command{ + "doubleclose": { Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { t, ok := getTestingT(env) if !ok { @@ -154,7 +154,7 @@ var ( Type: "", }, - "single": &cmds.Command{ + "single": { Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { t, ok := getTestingT(env) if !ok { @@ -188,14 +188,14 @@ var ( Type: "", }, - "reader": &cmds.Command{ + "reader": { Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { buf := bytes.NewBufferString("the reader call returns a reader.") return re.Emit(buf) }, }, - "echo": &cmds.Command{ + "echo": { Arguments: []cmds.Argument{ cmds.FileArg("file", true, false, "a file"), }, @@ -220,7 +220,7 @@ var ( }, }, - "version": &cmds.Command{ + "version": { Helptext: cmds.HelpText{ Tagline: "Show ipfs version information.", ShortDescription: "Returns the current version of ipfs and exits.", diff --git a/http/parse_test.go b/http/parse_test.go index 1d903c3d..fe9e8b48 100644 --- a/http/parse_test.go +++ b/http/parse_test.go @@ -15,9 +15,9 @@ import ( func TestParse(t *testing.T) { root := &cmds.Command{ Subcommands: map[string]*cmds.Command{ - "block": &cmds.Command{ + "block": { Subcommands: map[string]*cmds.Command{ - "put": &cmds.Command{ + "put": { Run: func(req *cmds.Request, resp cmds.ResponseEmitter, env cmds.Environment) error { defer resp.Close() resp.Emit("done") diff --git a/maybeerror_test.go b/maybeerror_test.go index 95352192..821c7506 100644 --- a/maybeerror_test.go +++ b/maybeerror_test.go @@ -59,9 +59,9 @@ func TestMaybeError(t *testing.T) { Value: &Foo{}, JSON: `{"Bar":23}{"Bar":42}{"Message":"some error", "Type": "error"}`, Decoded: []ValueError{ - ValueError{Value: &Foo{23}}, - ValueError{Value: &Foo{42}}, - ValueError{Error: &Error{Message: "some error", Code: 0}}, + {Value: &Foo{23}}, + {Value: &Foo{42}}, + {Error: &Error{Message: "some error", Code: 0}}, }, }, { @@ -69,9 +69,9 @@ func TestMaybeError(t *testing.T) { Value: Foo{}, JSON: `{"Bar":23}{"Bar":42}{"Message":"some error", "Type": "error"}`, Decoded: []ValueError{ - ValueError{Value: &Foo{23}}, - ValueError{Value: &Foo{42}}, - ValueError{Error: &Error{Message: "some error", Code: 0}}, + {Value: &Foo{23}}, + {Value: &Foo{42}}, + {Error: &Error{Message: "some error", Code: 0}}, }, }, { @@ -79,9 +79,9 @@ func TestMaybeError(t *testing.T) { Value: &Bar{}, JSON: `{"Foo":""}{"Foo":"Qmabc"}{"Message":"some error", "Type": "error"}`, Decoded: []ValueError{ - ValueError{Value: &Bar{""}}, - ValueError{Value: &Bar{"Qmabc"}}, - ValueError{Error: &Error{Message: "some error", Code: 0}}, + {Value: &Bar{""}}, + {Value: &Bar{"Qmabc"}}, + {Error: &Error{Message: "some error", Code: 0}}, }, }, { @@ -89,19 +89,19 @@ func TestMaybeError(t *testing.T) { Value: Bar{}, JSON: `{"Foo":""}{"Foo":"Qmabc"}{"Message":"some error", "Type": "error"}`, Decoded: []ValueError{ - ValueError{Value: &Bar{""}}, - ValueError{Value: &Bar{"Qmabc"}}, - ValueError{Error: &Error{Message: "some error", Code: 0}}, + {Value: &Bar{""}}, + {Value: &Bar{"Qmabc"}}, + {Error: &Error{Message: "some error", Code: 0}}, }, }, { Name: "untyped", JSON: `{"Foo":"bar", "i": 4}"some string"5{"Message":"some error", "Type": "error"}`, Decoded: []ValueError{ - ValueError{Value: map[string]interface{}{"Foo": "bar", "i": 4.0}}, - ValueError{Value: "some string"}, - ValueError{Value: 5.0}, - ValueError{Error: &Error{Message: "some error", Code: 0}}, + {Value: map[string]interface{}{"Foo": "bar", "i": 4.0}}, + {Value: "some string"}, + {Value: 5.0}, + {Error: &Error{Message: "some error", Code: 0}}, }, }, } diff --git a/opts.go b/opts.go index f06cb6e2..11c6b2f6 100644 --- a/opts.go +++ b/opts.go @@ -1,7 +1,5 @@ package cmds -import () - // Flag names const ( EncShort = "enc" diff --git a/response.go b/response.go index 3c59d668..9c5b980a 100644 --- a/response.go +++ b/response.go @@ -1,7 +1,5 @@ package cmds -import () - // Response is the result of a command request. Response is returned to the client. type Response interface { Request() *Request From b8bf553d6fe00cd46daae37e32372c9565008624 Mon Sep 17 00:00:00 2001 From: web3-bot Date: Tue, 17 Aug 2021 13:32:40 +0000 Subject: [PATCH 5/8] add .github/workflows/automerge.yml --- .github/workflows/automerge.yml | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/automerge.yml diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..44fad65f --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,53 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + +# Automatically merge pull requests opened by web3-bot, as soon as (and only if) all tests pass. +# This reduces the friction associated with updating with our workflows. + +on: [ pull_request ] +name: Automerge + +jobs: + automerge-check: + if: github.event.pull_request.user.login == 'web3-bot' + runs-on: ubuntu-latest + outputs: + status: ${{ steps.should-automerge.outputs.status }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Check if we should automerge + id: should-automerge + run: | + for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do + committer=$(git show --format=$'%ce' -s $commit) + echo "Committer: $committer" + if [[ "$committer" != "web3-bot@users.noreply.github.com" ]]; then + echo "Commit $commit wasn't committed by web3-bot, but by $committer." + echo "::set-output name=status::false" + exit + fi + done + echo "::set-output name=status::true" + automerge: + needs: automerge-check + runs-on: ubuntu-latest + # The check for the user is redundant here, as this job depends on the automerge-check job, + # but it prevents this job from spinning up, just to be skipped shortly after. + if: github.event.pull_request.user.login == 'web3-bot' && needs.automerge-check.outputs.status == 'true' + steps: + - name: Wait on tests + uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2 + with: + ref: ${{ github.event.pull_request.head.sha }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 + running-workflow-name: 'automerge' # the name of this job + - name: Merge PR + uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1 + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + MERGE_LABELS: "" + MERGE_METHOD: "squash" + MERGE_DELETE_BRANCH: true From 0c32a1b1261e9dfdd61640f5f220956b5a3099ea Mon Sep 17 00:00:00 2001 From: web3-bot Date: Tue, 17 Aug 2021 13:32:40 +0000 Subject: [PATCH 6/8] add .github/workflows/go-test.yml --- .github/workflows/go-test.yml | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/go-test.yml diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml new file mode 100644 index 00000000..7010dcce --- /dev/null +++ b/.github/workflows/go-test.yml @@ -0,0 +1,55 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + +on: [push, pull_request] +name: Go Test + +jobs: + unit: + strategy: + fail-fast: false + matrix: + os: [ "ubuntu", "windows", "macos" ] + go: [ "1.16.x", "1.17.x" ] + env: + COVERAGES: "" + runs-on: ${{ matrix.os }}-latest + name: ${{ matrix.os}} (go ${{ matrix.go }}) + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + - name: Go information + run: | + go version + go env + - name: Run repo-specific setup + uses: ./.github/actions/go-test-setup + if: hashFiles('./.github/actions/go-test-setup') != '' + - name: Run tests + uses: protocol/multiple-go-modules@v1.2 + with: + run: go test -v -coverprofile module-coverage.txt ./... + - name: Run tests (32 bit) + if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX. + uses: protocol/multiple-go-modules@v1.2 + env: + GOARCH: 386 + with: + run: go test -v ./... + - name: Run tests with race detector + if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow + uses: protocol/multiple-go-modules@v1.2 + with: + run: go test -v -race ./... + - name: Collect coverage files + shell: bash + run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV + - name: Upload coverage to Codecov + uses: codecov/codecov-action@51d810878be5422784e86451c0e7c14e5860ec47 # v2.0.2 + with: + files: '${{ env.COVERAGES }}' + env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }} From 40e92d766e055fa3f31882139040908f4aafb37d Mon Sep 17 00:00:00 2001 From: web3-bot Date: Tue, 17 Aug 2021 13:32:40 +0000 Subject: [PATCH 7/8] add .github/workflows/go-check.yml --- .github/workflows/go-check.yml | 74 ++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/go-check.yml diff --git a/.github/workflows/go-check.yml b/.github/workflows/go-check.yml new file mode 100644 index 00000000..6acdd48f --- /dev/null +++ b/.github/workflows/go-check.yml @@ -0,0 +1,74 @@ +# File managed by web3-bot. DO NOT EDIT. +# See https://github.com/protocol/.github/ for details. + +on: [push, pull_request] +name: Go Checks + +jobs: + unit: + runs-on: ubuntu-latest + name: All + env: + RUNGOGENERATE: false + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - uses: actions/setup-go@v2 + with: + go-version: "1.17.x" + - name: Run repo-specific setup + uses: ./.github/actions/go-check-setup + if: hashFiles('./.github/actions/go-check-setup') != '' + - name: Read config + if: hashFiles('./.github/workflows/go-check-config.json') != '' + run: | + if jq -re .gogenerate ./.github/workflows/go-check-config.json; then + echo "RUNGOGENERATE=true" >> $GITHUB_ENV + fi + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@df71e5d0e0ed317ebf43e6e59cf919430fa4b8f2 # 2021.1.1 (v0.2.1) + - name: Check that go.mod is tidy + uses: protocol/multiple-go-modules@v1.2 + with: + run: | + go mod tidy + if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then + echo "go.sum was added by go mod tidy" + exit 1 + fi + git diff --exit-code -- go.sum go.mod + - name: gofmt + if: ${{ success() || failure() }} # run this step even if the previous one failed + run: | + out=$(gofmt -s -l .) + if [[ -n "$out" ]]; then + echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}' + exit 1 + fi + - name: go vet + if: ${{ success() || failure() }} # run this step even if the previous one failed + uses: protocol/multiple-go-modules@v1.2 + with: + run: go vet ./... + - name: staticcheck + if: ${{ success() || failure() }} # run this step even if the previous one failed + uses: protocol/multiple-go-modules@v1.2 + with: + run: | + set -o pipefail + staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g' + - name: go generate + uses: protocol/multiple-go-modules@v1.2 + if: (success() || failure()) && env.RUNGOGENERATE == 'true' + with: + run: | + git clean -fd # make sure there aren't untracked files / directories + go generate ./... + # check if go generate modified or added any files + if ! $(git add . && git diff-index HEAD --exit-code --quiet); then + echo "go generated caused changes to the repository:" + git status --short + exit 1 + fi + From cf96ebfecdd10b2db41f05f991ccc0cc464054c8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 25 Aug 2021 10:25:29 -0700 Subject: [PATCH 8/8] test: fix filepath checks on windows --- cli/parse_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cli/parse_test.go b/cli/parse_test.go index 10bd97a0..45bd8c48 100644 --- a/cli/parse_test.go +++ b/cli/parse_test.go @@ -7,7 +7,7 @@ import ( "io/ioutil" "net/url" "os" - "path" + "path/filepath" "strings" "testing" @@ -763,7 +763,7 @@ func TestFileArgs(t *testing.T) { tmpFile1 := mkTempFile(t, "", "", "test1") tmpFile2 := mkTempFile(t, tmpDir1, "", "toBeIgnored") tmpFile3 := mkTempFile(t, tmpDir1, "", "test3") - ignoreFile := mkTempFile(t, tmpDir2, "", path.Base(tmpFile2.Name())) + ignoreFile := mkTempFile(t, tmpDir2, "", filepath.Base(tmpFile2.Name())) tmpHiddenFile := mkTempFile(t, tmpDir1, ".test_hidden_file_*", "test") defer func() { for _, f := range []string{ @@ -790,27 +790,27 @@ func TestFileArgs(t *testing.T) { parseErr: fmt.Errorf("argument %q is required", "path"), }, { - cmd: words{"fileOp", "--ignore", path.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil, + cmd: words{"fileOp", "--ignore", filepath.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil, args: words{tmpDir1, tmpFile1.Name(), tmpFile3.Name()}, parseErr: fmt.Errorf(notRecursiveFmtStr, tmpDir1, "r"), }, { - cmd: words{"fileOp", tmpFile1.Name(), "--ignore", path.Base(tmpFile2.Name()), "--ignore"}, f: nil, + cmd: words{"fileOp", tmpFile1.Name(), "--ignore", filepath.Base(tmpFile2.Name()), "--ignore"}, f: nil, args: words{tmpDir1, tmpFile1.Name(), tmpFile3.Name()}, parseErr: fmt.Errorf("missing argument for option %q", "ignore"), }, { - cmd: words{"fileOp", "-r", "--ignore", path.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil, + cmd: words{"fileOp", "-r", "--ignore", filepath.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil, args: words{tmpDir1, tmpFile1.Name(), tmpFile3.Name()}, parseErr: nil, }, { - cmd: words{"fileOp", "--hidden", "-r", "--ignore", path.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil, + cmd: words{"fileOp", "--hidden", "-r", "--ignore", filepath.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil, args: words{tmpDir1, tmpFile1.Name(), tmpFile3.Name(), tmpHiddenFile.Name()}, parseErr: nil, }, { - cmd: words{"fileOp", "-r", "--ignore", path.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name(), "--ignore", "anotherRule"}, f: nil, + cmd: words{"fileOp", "-r", "--ignore", filepath.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name(), "--ignore", "anotherRule"}, f: nil, args: words{tmpDir1, tmpFile1.Name(), tmpFile3.Name()}, parseErr: nil, }, @@ -838,7 +838,7 @@ func TestFileArgs(t *testing.T) { } expectedFileMap := make(map[string]bool) for _, arg := range tc.args { - expectedFileMap[path.Base(arg)] = false + expectedFileMap[filepath.Base(arg)] = false } it := req.Files.Entries() for it.Next() {