Unverified Commit 6a03abfb authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #55 from libp2p/web3-bot/sync

sync: update CI config files
parents 82173f29 9b47c884
# 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 ]
jobs:
automerge:
if: github.event.pull_request.user.login == 'web3-bot'
runs-on: ubuntu-latest
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
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.
on: [push, pull_request]
jobs:
unit:
runs-on: ubuntu-latest
name: Go checks
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.16.x"
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@be534f007836a777104a15f2456cd1fffd3ddee8 # v2020.2.2
- name: Check that go.mod is tidy
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
run: go vet ./...
- name: staticcheck
if: ${{ success() || failure() }} # run this step even if the previous one failed
run: |
set -o pipefail
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.
on: [push, pull_request]
jobs:
unit:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu", "windows", "macos" ]
go: [ "1.15.x", "1.16.x" ]
runs-on: ${{ matrix.os }}-latest
name: Unit tests (${{ matrix.os}}, Go ${{ matrix.go }})
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Go information
run: |
go version
go env
- name: Run tests
run: go test -v -coverprofile coverage.txt ./...
- name: Run tests (32 bit)
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
env:
GOARCH: 386
run: go test -v ./...
- name: Run tests with race detector
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
run: go test -v -race ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@967e2b38a85a62bd61be5529ada27ebc109948c2 # v1.4.1
with:
file: coverage.txt
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}
os:
- linux
language: go
go:
- 1.14.x
env:
global:
- BUILD_DEPTYPE=gomod
matrix:
- GOTFLAGS="-race"
- GOTFLAGS="-count 5"
# 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
...@@ -14,6 +14,8 @@ import ( ...@@ -14,6 +14,8 @@ import (
"sync/atomic" "sync/atomic"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/require"
) )
type logCapture struct{ bytes.Buffer } type logCapture struct{ bytes.Buffer }
...@@ -235,6 +237,13 @@ func TestPing(t *testing.T) { ...@@ -235,6 +237,13 @@ func TestPing(t *testing.T) {
defer client.Close() defer client.Close()
defer server.Close() defer server.Close()
clientConn := client.conn.(*pipeConn)
clientConn.BlockWrites()
go func() {
time.Sleep(time.Millisecond)
clientConn.UnblockWrites()
}()
rtt, err := client.Ping() rtt, err := client.Ping()
if err != nil { if err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
...@@ -243,6 +252,12 @@ func TestPing(t *testing.T) { ...@@ -243,6 +252,12 @@ func TestPing(t *testing.T) {
t.Fatalf("bad: %v", rtt) t.Fatalf("bad: %v", rtt)
} }
clientConn.BlockWrites()
go func() {
time.Sleep(time.Millisecond)
clientConn.UnblockWrites()
}()
rtt, err = server.Ping() rtt, err = server.Ping()
if err != nil { if err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
...@@ -992,20 +1007,18 @@ func TestKeepAlive(t *testing.T) { ...@@ -992,20 +1007,18 @@ func TestKeepAlive(t *testing.T) {
defer client.Close() defer client.Close()
defer server.Close() defer server.Close()
time.Sleep(200 * time.Millisecond)
// Ping value should increase // Ping value should increase
client.pingLock.Lock() require.Eventually(t, func() bool {
defer client.pingLock.Unlock() client.pingLock.Lock()
if client.pingID == 0 { defer client.pingLock.Unlock()
t.Fatalf("should ping") return client.pingID > 0
} }, time.Second, 50*time.Millisecond, "should ping")
server.pingLock.Lock() require.Eventually(t, func() bool {
defer server.pingLock.Unlock() server.pingLock.Lock()
if server.pingID == 0 { defer server.pingLock.Unlock()
t.Fatalf("should ping") return server.pingID > 0
} }, time.Second, 50*time.Millisecond, "should ping")
} }
func TestKeepAlive_Timeout(t *testing.T) { func TestKeepAlive_Timeout(t *testing.T) {
...@@ -1660,7 +1673,7 @@ func TestReadDeadlineInterrupt(t *testing.T) { ...@@ -1660,7 +1673,7 @@ func TestReadDeadlineInterrupt(t *testing.T) {
select { select {
case <-done: case <-done:
case <-time.After(10 * time.Millisecond): case <-time.After(100 * time.Millisecond):
t.Fatal("read should have finished") t.Fatal("read should have finished")
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment