Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d9731d68a | ||
|
|
acf2a5a75d | ||
|
|
cd6dfd8a2a | ||
|
|
f68a946f96 | ||
|
|
dc6453417d | ||
|
|
3d70aa6bb8 | ||
|
|
cc3bce129e | ||
|
|
6cecc0d6d8 | ||
|
|
b0ac6089f4 | ||
|
|
e0145c0688 | ||
|
|
d4e425a251 | ||
|
|
f8aa553d5c | ||
|
|
956e7af11f | ||
|
|
fc47a98a74 | ||
|
|
7455c2ad4a | ||
|
|
bb5460fccc |
No files matched your search
@@ -1,43 +1,49 @@
|
||||
---
|
||||
name: "Build & Test"
|
||||
on:
|
||||
on: # yamllint disable-line rule:truthy
|
||||
push:
|
||||
branches:
|
||||
- "!dependabot/*"
|
||||
- "main"
|
||||
- "*"
|
||||
pull_request:
|
||||
branches: ["*"]
|
||||
branches:
|
||||
- "*"
|
||||
jobs:
|
||||
build:
|
||||
name: "Go Build"
|
||||
name: "Build Binary"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "actions/setup-go@v2"
|
||||
- uses: "actions/checkout@v3"
|
||||
- uses: "actions/setup-go@v3"
|
||||
with:
|
||||
go-version: "^1.17"
|
||||
- name: "Build"
|
||||
run: "go build ./cmd/..."
|
||||
- uses: "authzed/actions/go-build@main"
|
||||
|
||||
image-build:
|
||||
name: "Build Container Image"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: "actions/checkout@v3"
|
||||
- uses: "authzed/actions/docker-build@main"
|
||||
|
||||
unit:
|
||||
name: "Run Unit Tests"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "actions/setup-go@v2"
|
||||
- uses: "actions/checkout@v3"
|
||||
- uses: "actions/setup-go@v3"
|
||||
with:
|
||||
go-version: "^1.17"
|
||||
- name: "Run `go test`"
|
||||
run: "go test -race ./..."
|
||||
go-version: "^1.18"
|
||||
- uses: "authzed/actions/go-test@main"
|
||||
|
||||
e2e-mem:
|
||||
name: "E2E Memory Tests"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "actions/setup-go@v2"
|
||||
- uses: "actions/checkout@v3"
|
||||
- uses: "actions/setup-go@v3"
|
||||
with:
|
||||
go-version: "^1.17"
|
||||
go-version: "^1.18"
|
||||
- name: "Install and configure chihaya"
|
||||
run: |
|
||||
go install ./cmd/chihaya
|
||||
@@ -59,10 +65,10 @@ jobs:
|
||||
ports: ["6379:6379"]
|
||||
options: "--entrypoint redis-server"
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "actions/setup-go@v2"
|
||||
- uses: "actions/checkout@v3"
|
||||
- uses: "actions/setup-go@v3"
|
||||
with:
|
||||
go-version: "^1.17"
|
||||
go-version: "^1.18"
|
||||
- name: "Install and configure chihaya"
|
||||
run: |
|
||||
go install ./cmd/chihaya
|
||||
@@ -78,25 +84,11 @@ jobs:
|
||||
chihaya e2e --debug
|
||||
kill $pid
|
||||
|
||||
image-build:
|
||||
name: "Docker Build"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "docker/setup-qemu-action@v1"
|
||||
- uses: "docker/setup-buildx-action@v1"
|
||||
with:
|
||||
driver-opts: "image=moby/buildkit:master"
|
||||
- uses: "docker/build-push-action@v1"
|
||||
with:
|
||||
push: false
|
||||
tags: "latest"
|
||||
|
||||
helm:
|
||||
name: "Helm Template"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "actions/checkout@v3"
|
||||
- name: "Install Helm"
|
||||
uses: "engineerd/configurator@v0.0.5"
|
||||
with:
|
||||
+13
-54
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "Lint"
|
||||
on:
|
||||
on: # yamllint disable-line rule:truthy
|
||||
push:
|
||||
branches:
|
||||
- "!dependabot/*"
|
||||
@@ -8,63 +8,26 @@ on:
|
||||
pull_request:
|
||||
branches: ["*"]
|
||||
jobs:
|
||||
go-mod-tidy:
|
||||
name: "Lint Go Modules"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "actions/setup-go@v2"
|
||||
with:
|
||||
go-version: "^1.17"
|
||||
- name: "Run `go mod tidy`"
|
||||
run: "go mod tidy && bash -c '[ $(git status --porcelain | tee /dev/fd/2 | wc -c) -eq 0 ]'"
|
||||
|
||||
go-fmt:
|
||||
name: "Format Go"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "actions/setup-go@v2"
|
||||
with:
|
||||
go-version: "^1.17"
|
||||
- name: "Install gofumpt"
|
||||
run: "go install mvdan.cc/gofumpt@latest"
|
||||
- name: "Run `gofumpt`"
|
||||
run: |
|
||||
GOFUMPT_OUTPUT="$(find . -iname '*.go' -type f | xargs gofumpt -d)"
|
||||
if [ -n "$GOFUMPT_OUTPUT" ]; then
|
||||
echo "The following files are not correctly formatted:"
|
||||
echo "${GOFUMPT_OUTPUT}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
go-lint:
|
||||
name: "Lint Go"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "actions/setup-go@v2"
|
||||
- uses: "actions/checkout@v3"
|
||||
- uses: "actions/setup-go@v3"
|
||||
with:
|
||||
go-version: "^1.17"
|
||||
- uses: "golangci/golangci-lint-action@v2"
|
||||
with:
|
||||
version: "v1.43"
|
||||
skip-go-installation: true
|
||||
skip-pkg-cache: true
|
||||
skip-build-cache: false
|
||||
go-version: "^1.18"
|
||||
- uses: "authzed/actions/gofumpt@main"
|
||||
- uses: "authzed/actions/go-mod-tidy@main"
|
||||
- uses: "authzed/actions/go-generate@main"
|
||||
- uses: "authzed/actions/golangci-lint@main"
|
||||
|
||||
extra-lint:
|
||||
name: "Lint YAML & Markdown"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "bewuethr/yamllint-action@v1.1.1"
|
||||
with:
|
||||
config-file: ".yamllint"
|
||||
- uses: "nosborn/github-action-markdown-cli@v3.0.1"
|
||||
with:
|
||||
files: "."
|
||||
config_file: ".markdownlint.yaml"
|
||||
- uses: "actions/checkout@v3"
|
||||
- uses: "authzed/actions/yaml-lint@main"
|
||||
- uses: "authzed/actions/markdown-lint@main"
|
||||
|
||||
codeql:
|
||||
name: "Analyze with CodeQL"
|
||||
@@ -78,9 +41,5 @@ jobs:
|
||||
matrix:
|
||||
language: ["go"]
|
||||
steps:
|
||||
- uses: "actions/checkout@v2"
|
||||
- uses: "github/codeql-action/init@v1"
|
||||
with:
|
||||
languages: "${{ matrix.language }}"
|
||||
- uses: "github/codeql-action/autobuild@v1"
|
||||
- uses: "github/codeql-action/analyze@v1"
|
||||
- uses: "actions/checkout@v3"
|
||||
- uses: "authzed/actions/codeql@main"
|
||||
@@ -6,6 +6,10 @@ output:
|
||||
linters-settings:
|
||||
goimports:
|
||||
local-prefixes: "github.com/chihaya/chihaya"
|
||||
staticcheck:
|
||||
checks:
|
||||
- "all"
|
||||
- "-SA1019" # Allow netErr.Temporary
|
||||
gosec:
|
||||
excludes:
|
||||
- "G404" # Allow the usage of math/rand
|
||||
|
||||
@@ -5,7 +5,6 @@ package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ func TestStartStopRaceIssue437(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
errC := fe.Stop()
|
||||
errs := <-errC
|
||||
if len(errs) != 0 {
|
||||
if errs := <-errC; len(errs) != 0 {
|
||||
t.Fatal(errs[0])
|
||||
}
|
||||
}
|
||||
@@ -6,17 +6,20 @@ require (
|
||||
github.com/SermoDigital/jose v0.9.2-0.20180104203859-803625baeddc
|
||||
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6 // indirect
|
||||
github.com/alicebob/miniredis v2.5.0+incompatible
|
||||
github.com/anacrolix/torrent v1.28.0
|
||||
github.com/go-redsync/redsync v1.4.2
|
||||
github.com/gomodule/redigo v2.0.0+incompatible
|
||||
github.com/anacrolix/dht/v2 v2.15.1 // indirect
|
||||
github.com/anacrolix/missinggo/v2 v2.5.3 // indirect
|
||||
github.com/anacrolix/torrent v1.40.0
|
||||
github.com/go-redsync/redsync/v4 v4.5.0
|
||||
github.com/gomodule/redigo v1.8.8
|
||||
github.com/julienschmidt/httprouter v1.3.0
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
||||
github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103
|
||||
github.com/minio/sha256-simd v0.1.1
|
||||
github.com/minio/sha256-simd v1.0.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.11.0
|
||||
github.com/prometheus/client_golang v1.12.2
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/spf13/cobra v1.2.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/spf13/cobra v1.5.0
|
||||
github.com/stretchr/testify v1.8.0
|
||||
github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
+2
-2
@@ -124,9 +124,9 @@ func (h *responseHook) appendPeers(req *bittorrent.AnnounceRequest, resp *bittor
|
||||
|
||||
switch req.IP.AddressFamily {
|
||||
case bittorrent.IPv4:
|
||||
resp.IPv4Peers = peers
|
||||
resp.IPv4Peers = append(resp.IPv4Peers, peers...)
|
||||
case bittorrent.IPv6:
|
||||
resp.IPv6Peers = peers
|
||||
resp.IPv6Peers = append(resp.IPv6Peers, peers...)
|
||||
default:
|
||||
panic("attempted to append peer that is neither IPv4 nor IPv6")
|
||||
}
|
||||
|
||||
+19
-18
@@ -7,13 +7,14 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-redsync/redsync"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/go-redsync/redsync/v4"
|
||||
"github.com/go-redsync/redsync/v4/redis/redigo"
|
||||
redigolib "github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
// redisBackend represents a redis handler.
|
||||
type redisBackend struct {
|
||||
pool *redis.Pool
|
||||
pool *redigolib.Pool
|
||||
redsync *redsync.Redsync
|
||||
}
|
||||
|
||||
@@ -27,7 +28,7 @@ func newRedisBackend(cfg *Config, u *redisURL, socketPath string) *redisBackend
|
||||
ConnectTimeout: cfg.RedisConnectTimeout,
|
||||
}
|
||||
pool := rc.NewPool()
|
||||
redsync := redsync.New([]redsync.Pool{pool})
|
||||
redsync := redsync.New(redigo.NewPool(pool))
|
||||
return &redisBackend{
|
||||
pool: pool,
|
||||
redsync: redsync,
|
||||
@@ -35,7 +36,7 @@ func newRedisBackend(cfg *Config, u *redisURL, socketPath string) *redisBackend
|
||||
}
|
||||
|
||||
// open returns or creates instance of Redis connection.
|
||||
func (rb *redisBackend) open() redis.Conn {
|
||||
func (rb *redisBackend) open() redigolib.Conn {
|
||||
return rb.pool.Get()
|
||||
}
|
||||
|
||||
@@ -48,11 +49,11 @@ type redisConnector struct {
|
||||
}
|
||||
|
||||
// NewPool returns a new pool of Redis connections
|
||||
func (rc *redisConnector) NewPool() *redis.Pool {
|
||||
return &redis.Pool{
|
||||
func (rc *redisConnector) NewPool() *redigolib.Pool {
|
||||
return &redigolib.Pool{
|
||||
MaxIdle: 3,
|
||||
IdleTimeout: 240 * time.Second,
|
||||
Dial: func() (redis.Conn, error) {
|
||||
Dial: func() (redigolib.Conn, error) {
|
||||
c, err := rc.open()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -68,7 +69,7 @@ func (rc *redisConnector) NewPool() *redis.Pool {
|
||||
return c, err
|
||||
},
|
||||
// PINGs connections that have been idle more than 10 seconds
|
||||
TestOnBorrow: func(c redis.Conn, t time.Time) error {
|
||||
TestOnBorrow: func(c redigolib.Conn, t time.Time) error {
|
||||
if time.Since(t) < 10*time.Second {
|
||||
return nil
|
||||
}
|
||||
@@ -79,23 +80,23 @@ func (rc *redisConnector) NewPool() *redis.Pool {
|
||||
}
|
||||
|
||||
// Open a new Redis connection
|
||||
func (rc *redisConnector) open() (redis.Conn, error) {
|
||||
opts := []redis.DialOption{
|
||||
redis.DialDatabase(rc.URL.DB),
|
||||
redis.DialReadTimeout(rc.ReadTimeout),
|
||||
redis.DialWriteTimeout(rc.WriteTimeout),
|
||||
redis.DialConnectTimeout(rc.ConnectTimeout),
|
||||
func (rc *redisConnector) open() (redigolib.Conn, error) {
|
||||
opts := []redigolib.DialOption{
|
||||
redigolib.DialDatabase(rc.URL.DB),
|
||||
redigolib.DialReadTimeout(rc.ReadTimeout),
|
||||
redigolib.DialWriteTimeout(rc.WriteTimeout),
|
||||
redigolib.DialConnectTimeout(rc.ConnectTimeout),
|
||||
}
|
||||
|
||||
if rc.URL.Password != "" {
|
||||
opts = append(opts, redis.DialPassword(rc.URL.Password))
|
||||
opts = append(opts, redigolib.DialPassword(rc.URL.Password))
|
||||
}
|
||||
|
||||
if rc.SocketPath != "" {
|
||||
return redis.Dial("unix", rc.SocketPath, opts...)
|
||||
return redigolib.Dial("unix", rc.SocketPath, opts...)
|
||||
}
|
||||
|
||||
return redis.Dial("tcp", rc.URL.Host, opts...)
|
||||
return redigolib.Dial("tcp", rc.URL.Host, opts...)
|
||||
}
|
||||
|
||||
// A redisURL represents a parsed redisURL
|
||||
|
||||
Reference in new issue
Block a user