2020-01-16 04:43:42 +00:00
|
|
|
image: golang:alpine
|
|
|
|
|
|
|
|
variables:
|
|
|
|
GO111MODULE: "on"
|
2020-01-20 19:50:21 +00:00
|
|
|
CGO_ENABLED: "0"
|
2020-01-31 17:32:51 +00:00
|
|
|
COV: "/tmp/cov_results"
|
2020-01-16 04:43:42 +00:00
|
|
|
|
|
|
|
before_script:
|
|
|
|
- apk add git
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- test
|
|
|
|
|
2020-04-20 18:03:15 +00:00
|
|
|
build_test:
|
|
|
|
stage: test
|
|
|
|
script:
|
|
|
|
- go build ./...
|
|
|
|
|
2020-01-16 04:43:42 +00:00
|
|
|
unit_test:
|
|
|
|
stage: test
|
|
|
|
script:
|
2020-04-19 23:35:37 +00:00
|
|
|
- go test -v -coverprofile $COV ./...
|
2020-01-31 17:32:51 +00:00
|
|
|
- go tool cover -func $COV
|
2020-01-16 04:43:42 +00:00
|
|
|
|
|
|
|
integration_test:
|
|
|
|
stage: test
|
|
|
|
script:
|
2020-05-03 19:02:13 +00:00
|
|
|
# Don't run if these variables aren't provided.
|
|
|
|
- '[ ! "$BOT_TOKEN" ] && exit'
|
2020-01-20 19:37:39 +00:00
|
|
|
# go get first, so it doesn't count towards the timeout.
|
2020-01-20 19:50:21 +00:00
|
|
|
- go get ./...
|
2020-05-30 21:32:23 +00:00
|
|
|
|
2020-01-20 11:15:41 +00:00
|
|
|
# Timeout test after 120 seconds (2 minutes)
|
2020-05-30 21:32:23 +00:00
|
|
|
- timeout 120 go test
|
|
|
|
# Known packages that are important to do integration tests on.
|
|
|
|
-coverpkg "./api,./gateway,./bot,./discord"
|
|
|
|
-coverprofile $COV
|
|
|
|
-tags integration
|
|
|
|
-v
|
|
|
|
# Test both the current package and the external API mocking package.
|
|
|
|
./...
|
|
|
|
github.com/mavolin/dismock/pkg/dismock
|
|
|
|
|
2020-04-27 01:21:25 +00:00
|
|
|
- go tool cover -func $COV
|
2020-01-16 04:43:42 +00:00
|
|
|
|