forked from philippgille/gokv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
115 lines (106 loc) · 5.59 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
# Sudo is required for running Docker
sudo: required
services:
# Docker is required for running some services that aren't provided by Travis CI, e.g. Consul
- docker
- redis-server
- mongodb
- memcached
- mysql
git:
depth: 1
language: go
go:
- "1.10"
before_install:
- go version
- go env
env:
# For encrypted environment variables, use:
# travis encrypt 'PASSWORD="SECRET"' -r philippgille/gokv
global:
# "DynamoDB local" accepts any credentials
- AWS_ACCESS_KEY_ID=user
- AWS_SECRET_ACCESS_KEY=secret
# Don't start Docker containers all at once. The Travis CI VM doesn't have enough memory for that.
# TODO: Implement a proper wait (e.g. with container health check) instead of sleeping for 10s
script:
# Build
- go build -v ./...
# Linter
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.15.0
- golangci-lint run
# Test all packages that don't require a service
- go test -v -race -coverprofile=coverage1.txt -covermode=atomic ./badgerdb ./bbolt ./bigcache ./file ./freecache ./gomap ./leveldb ./syncmap
# Test all packages that don't require a Docker container
- go test -v -race -coverprofile=coverage2.txt -covermode=atomic ./memcached ./mongodb ./mysql ./redis
# Test Consul
- docker run -d --rm --name consul -p 8500:8500 bitnami/consul
- sleep 10s
- go test -v -race -coverprofile=coverage3.txt -covermode=atomic ./consul
- docker stop consul
# Test etcd
- docker run -d --rm --name etcd -p 2379:2379 --env ALLOW_NONE_AUTHENTICATION=yes bitnami/etcd
- sleep 10s
- go test -v -race -coverprofile=coverage4.txt -covermode=atomic ./etcd
- docker stop etcd
# Test DynamoDB via "DynamoDB local"
- docker run -d --rm --name dynamodb-local -p 8000:8000 amazon/dynamodb-local
- sleep 10s
- go test -v -race -coverprofile=coverage5.txt -covermode=atomic ./dynamodb
- docker stop dynamodb-local
# Test Cosmos DB via Azurite
# There are problems with Azurite, see: https://github.com/Azure/Azurite/issues/121
#- docker run -d --rm --name azurite -e executable=table -p 10002:10002 arafato/azurite
#
# Test Google Cloud Datastore via "Cloud Datastore Emulator"
# Using the ":slim" or ":alpine" tag would require the emulator to be installed manually.
# Both ways seem to be okay for setting the project: `-e CLOUDSDK_CORE_PROJECT=gokv` and CLI parameter `--project=gokv`
# `--host-port` is required because otherwise the server only listens on localhost IN the container.
- docker run -d --rm --name datastore -p 8081:8081 google/cloud-sdk gcloud beta emulators datastore start --no-store-on-disk --project=gokv --host-port=0.0.0.0:8081
- sleep 10s
- go test -v -race -coverprofile=coverage6.txt -covermode=atomic ./datastore
- docker stop datastore
# Test Amazon S3 via Minio
- docker run -d --rm --name s3 -e "MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE" -e "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" -p 9000:9000 minio/minio server /data
- sleep 10s
- go test -v -race -coverprofile=coverage7.txt -covermode=atomic ./s3
- docker stop s3
# Test PostgreSQL
# It's available as Travis CI service, but let's try to be as independent as possible from any CI service,
# starting with PostgreSQL and change the others later as well. (TODO: Turn services into Docker containers!)
# Expose port 5433 instead of 5432 because Travis CI already has a service running on 5432.
- docker run -d --rm --name postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=gokv -p 5433:5432 postgres:alpine
- sleep 10s
- go test -v -race -coverprofile=coverage8.txt -covermode=atomic ./postgresql
- docker stop postgres
# Test CockroachDB
- docker run -d --rm --name cockroachdb -p 26257:26257 cockroachdb/cockroach start --insecure
- sleep 10s
- docker exec cockroachdb bash -c './cockroach sql --insecure --execute="create database gokv;"'
- go test -v -race -coverprofile=coverage9.txt -covermode=atomic ./cockroachdb
- docker stop cockroachdb
# Test Apache Ignite
- docker run -d --rm --name ignite -e "CONFIG_URI=https://raw.githubusercontent.com/apache/ignite/master/examples/config/example-cache.xml" -p 10800:10800 apacheignite/ignite
- sleep 10s
- go test -v -race -coverprofile=coverage10.txt -covermode=atomic ./ignite
- docker stop ignite
# Test Apache ZooKeeper
- docker run -d --rm --name zookeeper -p 2181:2181 zookeeper
- sleep 10s
- go test -v -race -coverprofile=coverage11.txt -covermode=atomic ./zookeeper
- docker stop zookeeper
# Test Alibaba Cloud Table Store
# TODO: Currently no emulator exists for Alibaba Cloud Table Store.
#
# Test Hazelcast
- docker run -d --rm --name hazelcast -p 5701:5701 hazelcast/hazelcast
- sleep 10s
- go test -v -race -coverprofile=coverage12.txt -covermode=atomic ./hazelcast
- docker stop hazelcast
after_success:
# Combine coverage reports.
# (Using grep to skip the first line of each coverage report (there's probably a more elegant way to do this).)
- cat coverage1.txt > coverage.txt && cat coverage2.txt | grep gokv >> coverage.txt && cat coverage3.txt | grep gokv >> coverage.txt && cat coverage4.txt | grep gokv >> coverage.txt && cat coverage5.txt | grep gokv >> coverage.txt && cat coverage6.txt | grep gokv >> coverage.txt && cat coverage7.txt | grep gokv >> coverage.txt && cat coverage8.txt | grep gokv >> coverage.txt && cat coverage9.txt | grep gokv >> coverage.txt && cat coverage10.txt | grep gokv >> coverage.txt && cat coverage11.txt | grep gokv >> coverage.txt && cat coverage12.txt | grep gokv >> coverage.txt
# Upload coverage data to codecov.io
- bash <(curl -s https://codecov.io/bash)