dist: xenial language: go services: - docker branches: only: - master - travis install: true matrix: fast_finish: true allow_failures: - os: windows include: - name: Unit Tests | Linux, go:stable, gomod=on os: linux go: stable env: GO111MODULE=on TEST_SUITE=unit script: - go mod verify - go build -v ./... - make lint - gotestsum --format=short-verbose --junitfile=/tmp/unit-junit.xml -- -coverprofile=/tmp/unit.cov -tags='unit' -timeout=1h -v ./... after_script: - test -f /tmp/unit.cov && bash <(curl -s https://codecov.io/bash) -f /tmp/unit.cov - name: Unit Tests | Linux, go:stable, gomod=off os: linux go: stable env: GO111MODULE=off TEST_SUITE=unit before_install: - go get -u golang.org/x/lint/golint - go get -u gotest.tools/gotestsum install: - go get -v ./... script: - go build -v ./... - make lint - gotestsum --format=short-verbose --junitfile=/tmp/unit-junit.xml -- -tags='unit' -timeout=1h -v ./... - name: Unit Tests | OS X, go:stable, gomod=on os: osx go: stable env: GO111MODULE=on TEST_SUITE=unit script: - go mod verify - go build -v ./... - gotestsum --format=short-verbose --junitfile=/tmp/unit-junit.xml -- --tags='unit' --timeout=1h -v ./... - name: Unit Tests | Windows, go:stable, gomod=on os: windows go: stable env: GO111MODULE=on TEST_SUITE=unit script: - go mod verify - go build -v ./... - gotestsum --format=short-verbose --junitfile=/tmp/unit-junit.xml -- -tags='unit' -timeout=1h -v ./... - name: Unit Tests | Linux, go:master, gomod=on os: linux go: master env: GO111MODULE=on TEST_SUITE=unit script: - go mod verify - go build -v ./... - make lint - gotestsum --format=short-verbose --junitfile=/tmp/unit-junit.xml -- -tags='unit' -timeout=1h -v ./... - name: Unit Tests | Docker/Linux, golang:1-alpine os: linux env: TEST_SUITE=unit before_install: true script: - grep 'FROM' Dockerfile - docker build --file Dockerfile --tag elastic/go-elasticsearch . - echo $(($(docker image inspect -f '{{.Size}}' elastic/go-elasticsearch)/(1000*1000)))MB - docker run -ti elastic/go-elasticsearch make lint - docker run -ti elastic/go-elasticsearch make test - name: Integration Tests | Linux, go:stable os: linux go: stable env: GO111MODULE=on TEST_SUITE=integration-client before_script: - docker pull docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.0-SNAPSHOT - docker network inspect elasticsearch > /dev/null || docker network create elasticsearch; - | docker run \ --name es-integration-client \ --network elasticsearch \ --env "cluster.name=es-integration-client" \ --env "discovery.type=single-node" \ --env "bootstrap.memory_lock=true" \ --env "cluster.routing.allocation.disk.threshold_enabled=false" \ --env ES_JAVA_OPTS="-Xms1g -Xmx1g" \ --volume es-integration-client-data:/usr/share/elasticsearch/data \ --publish 9200:9200 \ --ulimit nofile=65536:65536 \ --ulimit memlock=-1:-1 \ --detach \ --rm \ docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.0-SNAPSHOT - docker run --network elasticsearch --rm appropriate/curl --max-time 120 --retry 120 --retry-delay 1 --retry-connrefused --show-error --silent http://es-integration-client:9200 script: - gotestsum --format=short-verbose --junitfile=/tmp/integration-report.xml -- -race -cover -coverprofile=/tmp/integration-client.cov -tags='integration' -timeout=1h github.com/elastic/go-elasticsearch after_script: - test -f /tmp/integration-client.cov && bash <(curl -s https://codecov.io/bash) -f /tmp/integration-client.cov - name: Integration Tests, API | Linux, go:stable os: linux go: stable env: GO111MODULE=on TEST_SUITE=integration-api before_script: - docker pull docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.0-SNAPSHOT - docker network inspect elasticsearch > /dev/null || docker network create elasticsearch; - | docker run \ --name es-integration-api \ --network elasticsearch \ --env "cluster.name=es-integration-api" \ --env "discovery.type=single-node" \ --env "bootstrap.memory_lock=true" \ --env "cluster.routing.allocation.disk.threshold_enabled=false" \ --env "node.attr.testattr=test" \ --env "path.repo=/tmp" \ --env "repositories.url.allowed_urls=http://snapshot.test*" \ --env ES_JAVA_OPTS="-Xms1g -Xmx1g" \ --volume es-integration-api-data:/usr/share/elasticsearch/data \ --publish 9200:9200 \ --ulimit nofile=65536:65536 \ --ulimit memlock=-1:-1 \ --detach \ --rm \ docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.0-SNAPSHOT - docker run --network elasticsearch --rm appropriate/curl --max-time 120 --retry 120 --retry-delay 1 --retry-connrefused --show-error --silent http://es-integration-api:9200 script: - curl -s http://localhost:9200 | jq -r '.version.build_hash' > .elasticsearch_build_hash && cat .elasticsearch_build_hash # ------ Download Elasticsearch ----------------------------------------------------------- - echo -e "\e[33;1mDownload Elasticsearch Git source @ $(cat .elasticsearch_build_hash)\e[0m" && echo -en 'travis_fold:start:script.dl_es_src\\r' - echo https://github.com/elastic/elasticsearch/archive/$(cat .elasticsearch_build_hash).zip - | curl -sSL --retry 3 -o elasticsearch-$(cat .elasticsearch_build_hash).zip https://github.com/elastic/elasticsearch/archive/$(cat .elasticsearch_build_hash).zip && \ unzip -q -o elasticsearch-$(cat .elasticsearch_build_hash).zip '*.properties' '*.json' '*.yml' -d /tmp && \ mv /tmp/elasticsearch-$(cat .elasticsearch_build_hash)* /tmp/elasticsearch - echo -en 'travis_fold:end:script.dl_es_src' # ------ Generate API registry ------------------------------------------------------------ - echo -e "\e[33;1mGenerate API registry\e[0m" && echo -en 'travis_fold:start:script.gen_api_reg\\r\n' - cd ${TRAVIS_HOME}/gopath/src/github.com/elastic/go-elasticsearch/internal/cmd/generate && ELASTICSEARCH_BUILD_HASH=$(cat ../../../.elasticsearch_build_hash) PACKAGE_PATH=${TRAVIS_HOME}/gopath/src/github.com/elastic/go-elasticsearch/esapi go generate -v ./... - echo -en 'travis_fold:end:script.gen_api_reg' # ------ Generate Go test files ----------------------------------------------------------- - echo -e "\e[33;1mGenerate Go test files\e[0m" && echo -en 'travis_fold:start:script.gen_test_files\\r' - cd ${TRAVIS_HOME}/gopath/src/github.com/elastic/go-elasticsearch/internal/cmd/generate && ELASTICSEARCH_BUILD_HASH=$(cat ../../../.elasticsearch_build_hash) go run main.go apitests --input '/tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test/**/*.yml' --output=../../../esapi/test - echo -en 'travis_fold:end:script.gen_test_files' # ------ Run tests ----------------------------------------------------------------------- - cd ${TRAVIS_HOME}/gopath/src/github.com/elastic/go-elasticsearch/esapi/test && time gotestsum --format=short-verbose --junitfile=/tmp/integration-api-report.xml -- -coverpkg=github.com/elastic/go-elasticsearch/esapi -coverprofile=/tmp/integration-api.cov -tags='integration' -timeout=1h ./... after_script: - test -f /tmp/integration-api.cov && bash <(curl -s https://codecov.io/bash) -f /tmp/integration-api.cov before_install: - GO111MODULE=off go get -u golang.org/x/lint/golint - GO111MODULE=off go get -u gotest.tools/gotestsum script: echo "TODO > test $TEST_SUITE ($TRAVIS_OS_NAME)" notifications: email: true