travis: refactor into scripts&configs, move to dist/travis

This commit is contained in:
Leo Balduf 2019-10-17 14:58:24 +09:00
parent ddeb44b527
commit ae431e1361
6 changed files with 134 additions and 88 deletions

View file

@ -8,101 +8,22 @@ matrix:
include:
# Using vendored dependencies
- install:
- go get -u golang.org/x/lint/golint
- go get -u golang.org/x/tools/cmd/...
- go get gopkg.in/mikefarah/yq.v2
- ./dist/travis/install_reproducible.sh
script:
- go mod download
- go test -v -race $(go list ./...)
- go vet $(go list ./...)
- diff <(goimports -local github.com/chihaya/chihaya -d $(find . -type f -name '*.go' -not -path "./vendor/*")) <(printf "")
- (for d in $(go list ./...); do diff <(golint $d) <(printf "") || exit 1; done)
- go install github.com/chihaya/chihaya/cmd/chihaya
# Run e2e test with example config.
- chihaya --config=example_config.yaml --debug&
- pid=$!
- sleep 2 # wait for chihaya to start up (gross)
- chihaya e2e --debug
- kill $pid
# Run e2e test with redis.
- |
cat << EOF | yq.v2 w -s - example_config.yaml | yq.v2 d - chihaya.storage.config.shard_count >> redis_config.yaml
chihaya.storage.name: redis
chihaya.storage.config.redis_broker: "redis://localhost:6379/0"
chihaya.storage.config.redis_read_timeout: 15s
chihaya.storage.config.redis_write_timeout: 15s
chihaya.storage.config.redis_connect_timeout: 15s
EOF
- chihaya --config=redis_config.yaml --debug&
- pid=$!
- sleep 2 # wait for chihaya to start up (gross)
- chihaya e2e --debug
- kill $pid
# Using HEAD of dependencies
- ./dist/travis/check.sh
# Using HEAD of dependencies
- install:
- go get -t -u ./...
- go get -u golang.org/x/lint/golint
- go get -u golang.org/x/tools/cmd/...
- go get gopkg.in/mikefarah/yq.v2
- ./dist/travis/install_tip.sh
script:
- go test -v -race $(go list ./...)
- go vet $(go list ./...)
- diff <(goimports -local github.com/chihaya/chihaya -d $(find . -type f -name '*.go' -not -path "./vendor/*")) <(printf "")
- (for d in $(go list ./...); do diff <(golint $d) <(printf "") || exit 1; done)
- go install github.com/chihaya/chihaya/cmd/chihaya
# Run e2e test with example config.
- chihaya --config=example_config.yaml --debug&
- pid=$!
- sleep 2 # wait for chihaya to start up (gross)
- chihaya e2e --debug
- kill $pid
# Run e2e test with redis.
- |
cat << EOF | yq.v2 w -s - example_config.yaml | yq.v2 d - chihaya.storage.config.shard_count >> redis_config.yaml
chihaya.storage.name: redis
chihaya.storage.config.redis_broker: "redis://localhost:6379/0"
chihaya.storage.config.redis_read_timeout: 15s
chihaya.storage.config.redis_write_timeout: 15s
chihaya.storage.config.redis_connect_timeout: 15s
EOF
- chihaya --config=redis_config.yaml --debug&
- pid=$!
- sleep 2 # wait for chihaya to start up (gross)
- chihaya e2e --debug
- kill $pid
- ./dist/travis/check.sh
allow_failures:
# Using HEAD of dependencies
- install:
- go get -t -u ./...
- go get -u golang.org/x/lint/golint
- go get -u golang.org/x/tools/cmd/...
- go get gopkg.in/mikefarah/yq.v2
- ./dist/travis/install_tip.sh
script:
- go test -v -race $(go list ./...)
- go vet $(go list ./...)
- diff <(goimports -local github.com/chihaya/chihaya -d $(find . -type f -name '*.go' -not -path "./vendor/*")) <(printf "")
- (for d in $(go list ./...); do diff <(golint $d) <(printf "") || exit 1; done)
- go install github.com/chihaya/chihaya/cmd/chihaya
# Run e2e test with example config.
- chihaya --config=example_config.yaml --debug&
- pid=$!
- sleep 2 # wait for chihaya to start up (gross)
- chihaya e2e --debug
- kill $pid
# Run e2e test with redis.
- |
cat << EOF | yq.v2 w -s - example_config.yaml | yq.v2 d - chihaya.storage.config.shard_count >> redis_config.yaml
chihaya.storage.name: redis
chihaya.storage.config.redis_broker: "redis://localhost:6379/0"
chihaya.storage.config.redis_read_timeout: 15s
chihaya.storage.config.redis_write_timeout: 15s
chihaya.storage.config.redis_connect_timeout: 15s
EOF
- chihaya --config=redis_config.yaml --debug&
- pid=$!
- sleep 2 # wait for chihaya to start up (gross)
- chihaya e2e --debug
- kill $pid
- ./dist/travis/check.sh
notifications:
irc:
channels:

22
dist/travis/check.sh vendored Normal file
View file

@ -0,0 +1,22 @@
#!/bin/bash
set -e
go test -v -race $(go list ./...)
go vet $(go list ./...)
diff <(goimports -local github.com/chihaya/chihaya -d $(find . -type f -name '*.go' -not -path "./vendor/*")) <(printf "")
(for d in $(go list ./...); do diff <(golint $d) <(printf "") || exit 1; done)
go install github.com/chihaya/chihaya/cmd/chihaya
# Run e2e test with example config.
chihaya --config=./dist/travis/config_memory.yaml --debug&
pid=$!
sleep 2 # wait for Chihaya to start up (gross)
chihaya e2e --debug
kill $pid
# Run e2e test with redis.
chihaya --config=./dist/travis/config_redis.yaml --debug&
pid=$!
sleep 2 # wait for Chihaya to start up (gross)
chihaya e2e --debug
kill $pid

42
dist/travis/config_memory.yaml vendored Normal file
View file

@ -0,0 +1,42 @@
# This config file is used by travis for end-to-end testing.
# See example_config.yaml for a commented, more complete configuration!
chihaya:
announce_interval: 30m
min_announce_interval: 15m
prometheus_addr: "0.0.0.0:6880"
http:
addr: "0.0.0.0:6969"
https_addr: ""
tls_cert_path: ""
tls_key_path: ""
read_timeout: 5s
write_timeout: 5s
enable_keepalive: false
idle_timeout: 30s
enable_request_timing: false
enable_legacy_php_urls: false
allow_ip_spoofing: false
real_ip_header: "x-real-ip"
max_numwant: 100
default_numwant: 50
max_scrape_infohashes: 50
udp:
addr: "0.0.0.0:6969"
max_clock_skew: 10s
private_key: "paste a random string here that will be used to hmac connection IDs"
enable_request_timing: false
allow_ip_spoofing: false
max_numwant: 100
default_numwant: 50
max_scrape_infohashes: 50
storage:
name: memory
config:
gc_interval: 3m
peer_lifetime: 31m
shard_count: 1024
prometheus_reporting_interval: 1s

45
dist/travis/config_redis.yaml vendored Normal file
View file

@ -0,0 +1,45 @@
# This config file is used by travis for end-to-end testing.
# See example_config.yaml for a commented, more complete configuration!
chihaya:
announce_interval: 30m
min_announce_interval: 15m
prometheus_addr: "0.0.0.0:6880"
http:
addr: "0.0.0.0:6969"
https_addr: ""
tls_cert_path: ""
tls_key_path: ""
read_timeout: 5s
write_timeout: 5s
enable_keepalive: false
idle_timeout: 30s
enable_request_timing: false
enable_legacy_php_urls: false
allow_ip_spoofing: false
real_ip_header: "x-real-ip"
max_numwant: 100
default_numwant: 50
max_scrape_infohashes: 50
udp:
addr: "0.0.0.0:6969"
max_clock_skew: 10s
private_key: "paste a random string here that will be used to hmac connection IDs"
enable_request_timing: false
allow_ip_spoofing: false
max_numwant: 100
default_numwant: 50
max_scrape_infohashes: 50
storage:
name: redis
config:
gc_interval: 3m
peer_lifetime: 31m
prometheus_reporting_interval: 1s
redis_broker: "redis://pwd@127.0.0.1:6379/0"
redis_read_timeout: 15s
redis_write_timeout: 15s
redis_connect_timeout: 15s

8
dist/travis/install_reproducible.sh vendored Normal file
View file

@ -0,0 +1,8 @@
#!/bin/bash
set -e
# Install golint and go vet.
go get -u golang.org/x/lint/golint
go get -u golang.org/x/tools/cmd/...
go mod download

8
dist/travis/install_tip.sh vendored Normal file
View file

@ -0,0 +1,8 @@
#!/bin/bash
set -e
# Install golint and go vet.
go get -u golang.org/x/lint/golint
go get -u golang.org/x/tools/cmd/...
go get -t -u ./...