Skip to content

Commit a6eabdc

Browse files
authored
Merge pull request #207 from ipfs/web3-bot/sync
sync: update CI config files
2 parents 35a667a + cf96ebf commit a6eabdc

19 files changed

+242
-95
lines changed

.github/workflows/automerge.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# File managed by web3-bot. DO NOT EDIT.
2+
# See https://github.com/protocol/.github/ for details.
3+
4+
# Automatically merge pull requests opened by web3-bot, as soon as (and only if) all tests pass.
5+
# This reduces the friction associated with updating with our workflows.
6+
7+
on: [ pull_request ]
8+
name: Automerge
9+
10+
jobs:
11+
automerge-check:
12+
if: github.event.pull_request.user.login == 'web3-bot'
13+
runs-on: ubuntu-latest
14+
outputs:
15+
status: ${{ steps.should-automerge.outputs.status }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- name: Check if we should automerge
21+
id: should-automerge
22+
run: |
23+
for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do
24+
committer=$(git show --format=$'%ce' -s $commit)
25+
echo "Committer: $committer"
26+
if [[ "$committer" != "[email protected]" ]]; then
27+
echo "Commit $commit wasn't committed by web3-bot, but by $committer."
28+
echo "::set-output name=status::false"
29+
exit
30+
fi
31+
done
32+
echo "::set-output name=status::true"
33+
automerge:
34+
needs: automerge-check
35+
runs-on: ubuntu-latest
36+
# The check for the user is redundant here, as this job depends on the automerge-check job,
37+
# but it prevents this job from spinning up, just to be skipped shortly after.
38+
if: github.event.pull_request.user.login == 'web3-bot' && needs.automerge-check.outputs.status == 'true'
39+
steps:
40+
- name: Wait on tests
41+
uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2
42+
with:
43+
ref: ${{ github.event.pull_request.head.sha }}
44+
repo-token: ${{ secrets.GITHUB_TOKEN }}
45+
wait-interval: 10
46+
running-workflow-name: 'automerge' # the name of this job
47+
- name: Merge PR
48+
uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1
49+
env:
50+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
51+
MERGE_LABELS: ""
52+
MERGE_METHOD: "squash"
53+
MERGE_DELETE_BRANCH: true

.github/workflows/go-check.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# File managed by web3-bot. DO NOT EDIT.
2+
# See https://github.com/protocol/.github/ for details.
3+
4+
on: [push, pull_request]
5+
name: Go Checks
6+
7+
jobs:
8+
unit:
9+
runs-on: ubuntu-latest
10+
name: All
11+
env:
12+
RUNGOGENERATE: false
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
submodules: recursive
17+
- uses: actions/setup-go@v2
18+
with:
19+
go-version: "1.17.x"
20+
- name: Run repo-specific setup
21+
uses: ./.github/actions/go-check-setup
22+
if: hashFiles('./.github/actions/go-check-setup') != ''
23+
- name: Read config
24+
if: hashFiles('./.github/workflows/go-check-config.json') != ''
25+
run: |
26+
if jq -re .gogenerate ./.github/workflows/go-check-config.json; then
27+
echo "RUNGOGENERATE=true" >> $GITHUB_ENV
28+
fi
29+
- name: Install staticcheck
30+
run: go install honnef.co/go/tools/cmd/staticcheck@df71e5d0e0ed317ebf43e6e59cf919430fa4b8f2 # 2021.1.1 (v0.2.1)
31+
- name: Check that go.mod is tidy
32+
uses: protocol/[email protected]
33+
with:
34+
run: |
35+
go mod tidy
36+
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
37+
echo "go.sum was added by go mod tidy"
38+
exit 1
39+
fi
40+
git diff --exit-code -- go.sum go.mod
41+
- name: gofmt
42+
if: ${{ success() || failure() }} # run this step even if the previous one failed
43+
run: |
44+
out=$(gofmt -s -l .)
45+
if [[ -n "$out" ]]; then
46+
echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
47+
exit 1
48+
fi
49+
- name: go vet
50+
if: ${{ success() || failure() }} # run this step even if the previous one failed
51+
uses: protocol/[email protected]
52+
with:
53+
run: go vet ./...
54+
- name: staticcheck
55+
if: ${{ success() || failure() }} # run this step even if the previous one failed
56+
uses: protocol/[email protected]
57+
with:
58+
run: |
59+
set -o pipefail
60+
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
61+
- name: go generate
62+
uses: protocol/[email protected]
63+
if: (success() || failure()) && env.RUNGOGENERATE == 'true'
64+
with:
65+
run: |
66+
git clean -fd # make sure there aren't untracked files / directories
67+
go generate ./...
68+
# check if go generate modified or added any files
69+
if ! $(git add . && git diff-index HEAD --exit-code --quiet); then
70+
echo "go generated caused changes to the repository:"
71+
git status --short
72+
exit 1
73+
fi
74+

.github/workflows/go-test.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# File managed by web3-bot. DO NOT EDIT.
2+
# See https://github.com/protocol/.github/ for details.
3+
4+
on: [push, pull_request]
5+
name: Go Test
6+
7+
jobs:
8+
unit:
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
os: [ "ubuntu", "windows", "macos" ]
13+
go: [ "1.16.x", "1.17.x" ]
14+
env:
15+
COVERAGES: ""
16+
runs-on: ${{ matrix.os }}-latest
17+
name: ${{ matrix.os}} (go ${{ matrix.go }})
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
submodules: recursive
22+
- uses: actions/setup-go@v2
23+
with:
24+
go-version: ${{ matrix.go }}
25+
- name: Go information
26+
run: |
27+
go version
28+
go env
29+
- name: Run repo-specific setup
30+
uses: ./.github/actions/go-test-setup
31+
if: hashFiles('./.github/actions/go-test-setup') != ''
32+
- name: Run tests
33+
uses: protocol/[email protected]
34+
with:
35+
run: go test -v -coverprofile module-coverage.txt ./...
36+
- name: Run tests (32 bit)
37+
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
38+
uses: protocol/[email protected]
39+
env:
40+
GOARCH: 386
41+
with:
42+
run: go test -v ./...
43+
- name: Run tests with race detector
44+
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
45+
uses: protocol/[email protected]
46+
with:
47+
run: go test -v -race ./...
48+
- name: Collect coverage files
49+
shell: bash
50+
run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
51+
- name: Upload coverage to Codecov
52+
uses: codecov/codecov-action@51d810878be5422784e86451c0e7c14e5860ec47 # v2.0.2
53+
with:
54+
files: '${{ env.COVERAGES }}'
55+
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}

.travis.yml

-30
This file was deleted.

cli/error_posix.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//+build !windows,!plan9
1+
//go:build !windows && !plan9
2+
// +build !windows,!plan9
23

34
package cli
45

cli/error_windows.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//+build windows
1+
//go:build windows
2+
// +build windows
23

34
package cli
45

cli/parse_test.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"io/ioutil"
88
"net/url"
99
"os"
10-
"path"
10+
"path/filepath"
1111
"strings"
1212
"testing"
1313

@@ -105,8 +105,8 @@ func TestOptionParsing(t *testing.T) {
105105
cmds.DelimitedStringsOption(",", "delimstrings", "d", "comma delimited string array"),
106106
},
107107
Subcommands: map[string]*cmds.Command{
108-
"test": &cmds.Command{},
109-
"defaults": &cmds.Command{
108+
"test": {},
109+
"defaults": {
110110
Options: []cmds.Option{
111111
cmds.StringOption("opt", "o", "an option").WithDefault("def"),
112112
},
@@ -265,7 +265,7 @@ func TestDefaultOptionParsing(t *testing.T) {
265265

266266
cmd := &cmds.Command{
267267
Subcommands: map[string]*cmds.Command{
268-
"defaults": &cmds.Command{
268+
"defaults": {
269269
Options: []cmds.Option{
270270
cmds.StringOption("string", "s", "a string").WithDefault("foo"),
271271
cmds.StringsOption("strings1", "a", "a string array").WithDefault([]string{"foo"}),
@@ -435,18 +435,18 @@ func TestBodyArgs(t *testing.T) {
435435
cmds.StringArg("a", true, true, "some arg").EnableStdin(),
436436
},
437437
},
438-
"stdinenabled2args": &cmds.Command{
438+
"stdinenabled2args": {
439439
Arguments: []cmds.Argument{
440440
cmds.StringArg("a", true, false, "some arg"),
441441
cmds.StringArg("b", true, true, "another arg").EnableStdin(),
442442
},
443443
},
444-
"stdinenablednotvariadic": &cmds.Command{
444+
"stdinenablednotvariadic": {
445445
Arguments: []cmds.Argument{
446446
cmds.StringArg("a", true, false, "some arg").EnableStdin(),
447447
},
448448
},
449-
"stdinenablednotvariadic2args": &cmds.Command{
449+
"stdinenablednotvariadic2args": {
450450
Arguments: []cmds.Argument{
451451
cmds.StringArg("a", true, false, "some arg"),
452452
cmds.StringArg("b", true, false, "another arg").EnableStdin(),
@@ -763,7 +763,7 @@ func TestFileArgs(t *testing.T) {
763763
tmpFile1 := mkTempFile(t, "", "", "test1")
764764
tmpFile2 := mkTempFile(t, tmpDir1, "", "toBeIgnored")
765765
tmpFile3 := mkTempFile(t, tmpDir1, "", "test3")
766-
ignoreFile := mkTempFile(t, tmpDir2, "", path.Base(tmpFile2.Name()))
766+
ignoreFile := mkTempFile(t, tmpDir2, "", filepath.Base(tmpFile2.Name()))
767767
tmpHiddenFile := mkTempFile(t, tmpDir1, ".test_hidden_file_*", "test")
768768
defer func() {
769769
for _, f := range []string{
@@ -790,27 +790,27 @@ func TestFileArgs(t *testing.T) {
790790
parseErr: fmt.Errorf("argument %q is required", "path"),
791791
},
792792
{
793-
cmd: words{"fileOp", "--ignore", path.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil,
793+
cmd: words{"fileOp", "--ignore", filepath.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil,
794794
args: words{tmpDir1, tmpFile1.Name(), tmpFile3.Name()},
795795
parseErr: fmt.Errorf(notRecursiveFmtStr, tmpDir1, "r"),
796796
},
797797
{
798-
cmd: words{"fileOp", tmpFile1.Name(), "--ignore", path.Base(tmpFile2.Name()), "--ignore"}, f: nil,
798+
cmd: words{"fileOp", tmpFile1.Name(), "--ignore", filepath.Base(tmpFile2.Name()), "--ignore"}, f: nil,
799799
args: words{tmpDir1, tmpFile1.Name(), tmpFile3.Name()},
800800
parseErr: fmt.Errorf("missing argument for option %q", "ignore"),
801801
},
802802
{
803-
cmd: words{"fileOp", "-r", "--ignore", path.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil,
803+
cmd: words{"fileOp", "-r", "--ignore", filepath.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil,
804804
args: words{tmpDir1, tmpFile1.Name(), tmpFile3.Name()},
805805
parseErr: nil,
806806
},
807807
{
808-
cmd: words{"fileOp", "--hidden", "-r", "--ignore", path.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil,
808+
cmd: words{"fileOp", "--hidden", "-r", "--ignore", filepath.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name()}, f: nil,
809809
args: words{tmpDir1, tmpFile1.Name(), tmpFile3.Name(), tmpHiddenFile.Name()},
810810
parseErr: nil,
811811
},
812812
{
813-
cmd: words{"fileOp", "-r", "--ignore", path.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name(), "--ignore", "anotherRule"}, f: nil,
813+
cmd: words{"fileOp", "-r", "--ignore", filepath.Base(tmpFile2.Name()), tmpDir1, tmpFile1.Name(), "--ignore", "anotherRule"}, f: nil,
814814
args: words{tmpDir1, tmpFile1.Name(), tmpFile3.Name()},
815815
parseErr: nil,
816816
},
@@ -838,7 +838,7 @@ func TestFileArgs(t *testing.T) {
838838
}
839839
expectedFileMap := make(map[string]bool)
840840
for _, arg := range tc.args {
841-
expectedFileMap[path.Base(arg)] = false
841+
expectedFileMap[filepath.Base(arg)] = false
842842
}
843843
it := req.Files.Entries()
844844
for it.Next() {

cli/responseemitter_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (tc tcCloseWithError) Run(t *testing.T) {
4242

4343
func TestCloseWithError(t *testing.T) {
4444
tcs := []tcCloseWithError{
45-
tcCloseWithError{
45+
{
4646
stdout: bytes.NewBuffer(nil),
4747
stderr: bytes.NewBuffer(nil),
4848
exStdout: "a\n",
@@ -54,7 +54,7 @@ func TestCloseWithError(t *testing.T) {
5454
re.Emit("b")
5555
},
5656
},
57-
tcCloseWithError{
57+
{
5858
stdout: bytes.NewBuffer(nil),
5959
stderr: bytes.NewBuffer(nil),
6060
exStdout: "a\n",

cli/run_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
var root = &cmds.Command{
1313
Subcommands: map[string]*cmds.Command{
14-
"test": &cmds.Command{
14+
"test": {
1515
Run: func(req *cmds.Request, re cmds.ResponseEmitter, e cmds.Environment) error {
1616
err := cmds.EmitOnce(re, 42)
1717

command_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ func TestResolving(t *testing.T) {
130130
func TestWalking(t *testing.T) {
131131
cmdA := &Command{
132132
Subcommands: map[string]*Command{
133-
"b": &Command{},
134-
"B": &Command{},
133+
"b": {},
134+
"B": {},
135135
},
136136
}
137137
i := 0
@@ -181,7 +181,7 @@ func TestPostRun(t *testing.T) {
181181
defer cancel()
182182

183183
var testcases = []postRunTestCase{
184-
postRunTestCase{
184+
{
185185
length: 3,
186186
err: nil,
187187
emit: []interface{}{7},

0 commit comments

Comments
 (0)