I finally got GitLab CI up and running for the SnailLife Go port. The CI just runs the bash scripts I already had to test and build client and server. I had to make some changes for the tests to be able to run without the auth config files (which I obviously don’t want to submit to a public repo). Now, if an auth config file is not available I look for environment variables to get the Auth0 client ID and secret. Gitlab lets you set secret environment variables for the CI to use. I did something similar to get the name of the environment - if an env file with the environment name is not found, we check environment variables for the name (and then load relevant configs from there).
image: golang:1.9.1
variables:
REPO_NAME: gitlab.com/drakonka/gosnaillife
MYSQL_ROOT_PASSWORD: root
envname: gitlab
before_script:
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME
- go version
- go get ./...
stages:
- format
- build
format:
stage: format
script:
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)
buildandtest:
stage: build
services:
- mysql:latest
script:
- cd $GOPATH/src/$REPO_NAME/setup/deploy
- "bash deployServer.sh"
- "bash deployClient.sh"
artifacts:
paths:
- allcoverage.out
expire_in: 1 week