arikawa/.gitlab-ci.yml

54 lines
1.3 KiB
YAML

{
"image": "golang:alpine",
"variables": {
"GO111MODULE": "on",
"CGO_ENABLED": "1", # for the race detector
"COV": "/tmp/cov_results",
"dismock": "github.com/mavolin/dismock/v3/pkg/dismock",
"dismock_v": "259685b84e4b6ab364b0fd858aac2aa2dfa42502",
# used only in integration_test
"tested": "./api,./gateway,./bot,./discord"
},
"before_script": [
"apk add git build-base"
"go get ./...",
"go get $dismock@$dismock_v",
],
"stages": [
"build",
"test"
],
"build_test": {
"stage": "build",
"script": [
"go build ./..."
]
},
"unit_test": {
"stage": "test",
"timeout": "4m", # 4 minutes
# Don't run the test if we have a $BOT_TOKEN, because
# integration_test will run instead.
"except": {
"variables": [ "$BOT_TOKEN" ]
},
"script": [
"go test -coverpkg $tested -coverprofile $COV -tags unitonly -v -race ./... $dismock",
"go tool cover -func $COV"
]
},
"integration_test": {
"stage": "test",
"timeout": "8m", # 8 minutes
# Run the test only if we have $BOT_TOKEN, else fallback to unit
# tests.
"only": {
"variables": [ "$BOT_TOKEN", "$CHANNEL_ID", "$VOICE_ID" ]
},
"script": [
"go test -coverpkg $tested -coverprofile $COV -v -race ./... $dismock",
"go tool cover -func $COV"
]
}
}