2020-05-30 21:45:22 +00:00
|
|
|
{
|
|
|
|
"image": "golang:alpine",
|
|
|
|
"variables": {
|
|
|
|
"GO111MODULE": "on",
|
2020-10-29 20:06:27 +00:00
|
|
|
"CGO_ENABLED": "1", # for the race detector
|
2020-05-30 22:15:32 +00:00
|
|
|
"COV": "/tmp/cov_results",
|
|
|
|
"dismock": "github.com/mavolin/dismock/pkg/dismock",
|
|
|
|
# used only in integration_test
|
|
|
|
"tested": "./api,./gateway,./bot,./discord"
|
2020-05-30 21:45:22 +00:00
|
|
|
},
|
|
|
|
"before_script": [
|
2020-10-29 20:09:49 +00:00
|
|
|
"apk add git build-base"
|
2020-05-30 21:45:22 +00:00
|
|
|
],
|
|
|
|
"stages": [
|
2020-05-30 22:15:32 +00:00
|
|
|
"build",
|
2020-05-30 21:45:22 +00:00
|
|
|
"test"
|
|
|
|
],
|
|
|
|
"build_test": {
|
2020-05-30 22:15:32 +00:00
|
|
|
"stage": "build",
|
2020-05-30 21:45:22 +00:00
|
|
|
"script": [
|
|
|
|
"go build ./..."
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"unit_test": {
|
|
|
|
"stage": "test",
|
2020-05-30 22:15:32 +00:00
|
|
|
"timeout": "2m", # 2 minutes
|
2020-05-30 22:19:51 +00:00
|
|
|
# Don't run the test if we have a $BOT_TOKEN, because
|
|
|
|
# integration_test will run instead.
|
2020-05-30 22:22:13 +00:00
|
|
|
"except": {
|
2020-05-30 22:19:51 +00:00
|
|
|
"variables": [ "$BOT_TOKEN" ]
|
|
|
|
},
|
2020-05-30 21:45:22 +00:00
|
|
|
"script": [
|
2020-10-31 19:04:55 +00:00
|
|
|
"go test -coverprofile #COV -race -v ./...",
|
2020-05-30 21:45:22 +00:00
|
|
|
"go tool cover -func $COV"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"integration_test": {
|
|
|
|
"stage": "test",
|
2020-07-11 07:06:31 +00:00
|
|
|
"timeout": "5m", # 5 minutes
|
2020-05-30 22:19:51 +00:00
|
|
|
# Run the test only if we have $BOT_TOKEN, else fallback to unit
|
|
|
|
# tests.
|
|
|
|
"only": {
|
|
|
|
"variables": [ "$BOT_TOKEN" ]
|
|
|
|
},
|
2020-05-30 21:45:22 +00:00
|
|
|
"script": [
|
|
|
|
"go get ./...",
|
2020-05-30 22:15:32 +00:00
|
|
|
# Test this package along with dismock.
|
2020-10-29 18:38:54 +00:00
|
|
|
"go test -coverpkg $tested -coverprofile $COV -tags integration -race -v ./... $dismock",
|
2020-05-30 21:45:22 +00:00
|
|
|
"go tool cover -func $COV"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|