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",
|
2020-11-22 23:04:36 +00:00
|
|
|
"dismock": "github.com/mavolin/dismock/v2/pkg/dismock",
|
2020-11-30 21:13:55 +00:00
|
|
|
"dismock_v": "5c8df6ab93b919264ab156416c5803fb44491661",
|
2020-05-30 22:15:32 +00:00
|
|
|
# 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-12-01 01:49:18 +00:00
|
|
|
"go test -coverprofile $COV -tags unitonly -race ./...",
|
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-11-22 23:04:36 +00:00
|
|
|
"go get $dismock@$dismock_v",
|
2020-12-01 01:49:18 +00:00
|
|
|
"go test -coverpkg $tested -coverprofile $COV -race ./... $dismock",
|
2020-11-22 23:04:36 +00:00
|
|
|
"go mod tidy",
|
2020-05-30 21:45:22 +00:00
|
|
|
"go tool cover -func $COV"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|