From ae431e1361bb5e13a3af455d3cd73d02eaf92b17 Mon Sep 17 00:00:00 2001 From: Leo Balduf Date: Thu, 17 Oct 2019 14:58:24 +0900 Subject: [PATCH] travis: refactor into scripts&configs, move to dist/travis --- .travis.yml | 97 +++-------------------------- dist/travis/check.sh | 22 +++++++ dist/travis/config_memory.yaml | 42 +++++++++++++ dist/travis/config_redis.yaml | 45 +++++++++++++ dist/travis/install_reproducible.sh | 8 +++ dist/travis/install_tip.sh | 8 +++ 6 files changed, 134 insertions(+), 88 deletions(-) create mode 100644 dist/travis/check.sh create mode 100644 dist/travis/config_memory.yaml create mode 100644 dist/travis/config_redis.yaml create mode 100644 dist/travis/install_reproducible.sh create mode 100644 dist/travis/install_tip.sh diff --git a/.travis.yml b/.travis.yml index 4f31d43..b272332 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/dist/travis/check.sh b/dist/travis/check.sh new file mode 100644 index 0000000..7b51f73 --- /dev/null +++ b/dist/travis/check.sh @@ -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 \ No newline at end of file diff --git a/dist/travis/config_memory.yaml b/dist/travis/config_memory.yaml new file mode 100644 index 0000000..96e7d1a --- /dev/null +++ b/dist/travis/config_memory.yaml @@ -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 diff --git a/dist/travis/config_redis.yaml b/dist/travis/config_redis.yaml new file mode 100644 index 0000000..3e55643 --- /dev/null +++ b/dist/travis/config_redis.yaml @@ -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 \ No newline at end of file diff --git a/dist/travis/install_reproducible.sh b/dist/travis/install_reproducible.sh new file mode 100644 index 0000000..fe0fc62 --- /dev/null +++ b/dist/travis/install_reproducible.sh @@ -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 \ No newline at end of file diff --git a/dist/travis/install_tip.sh b/dist/travis/install_tip.sh new file mode 100644 index 0000000..1619966 --- /dev/null +++ b/dist/travis/install_tip.sh @@ -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 ./... \ No newline at end of file