forked from elastic/go-elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
170 lines (154 loc) · 8.16 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
dist: xenial
language: go
services:
- docker
branches:
only:
- master
- travis
install: true
matrix:
fast_finish: true
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:8.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:8.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:8.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:8.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