Commit 630e1931 authored by Julien Schröter's avatar Julien Schröter

Cache go dependencies

parent 4900ac50
Pipeline #2127 passed with stage
in 3 minutes and 44 seconds
......@@ -7,15 +7,14 @@ variables:
MYSQL_PASSWORD: tester
MYSQL_DATABASE: akamu
# The problem is that to be able to use go get, one needs to put
# the repository in the $GOPATH. So for example if your gitlab domain
# is gitlab.com, and that your repository is namespace/project, and
# the default GOPATH being /go, then you'd need to have your
# repository in /go/src/gitlab.com/namespace/project
# Thus, making a symbolic link corrects this.
before_script:
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
.go-cache:
variables:
GOPATH: $CI_PROJECT_DIR/.go
before_script:
- mkdir -p .go
cache:
paths:
- .go/pkg/mod/
stages:
- test
......@@ -24,21 +23,19 @@ stages:
precheck:
stage: test
extends: .go-cache
script:
- cd $GOPATH/src/$REPO_NAME
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.akamu.de/".insteadOf "https://gitlab.akamu.de/"
- go get ./...
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)
unittest:
stage: test
extends: .go-cache
script:
- cd $GOPATH/src/$REPO_NAME
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.akamu.de/".insteadOf "https://gitlab.akamu.de/"
- go get ./...
- go get -u github.com/jstemmer/go-junit-report
- go test ./test -v 2>&1 | go-junit-report > report-unit.xml
- go test ./test -v 2>&1 | $GOPATH/bin/go-junit-report > report-unit.xml
artifacts:
reports:
junit: report-unit.xml
......@@ -47,8 +44,8 @@ e2etest:
stage: test
services:
- mariadb:latest
extends: .go-cache
script:
- cd $GOPATH/src/$REPO_NAME
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.akamu.de/".insteadOf "https://gitlab.akamu.de/"
- apt-get update && apt-get -y install mariadb-client
- git clone --depth 1 --single-branch -b development https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.akamu.de/akamu/data-schemas $HOME/data-schemas
......@@ -57,19 +54,17 @@ e2etest:
- TEST_CONFIGFILE=$CI_PROJECT_DIR/test/e2e/testconfig.json
- TEST_DATAFILE=$CI_PROJECT_DIR/resources/data/testdata.sql
- echo "{\"jwt-secret\":\"akamu\",\"database\":{\"name\":\"$MYSQL_DATABASE\",\"user\":\"$MYSQL_USER\",\"host\":\"mariadb\",\"password\":\"$MYSQL_PASSWORD\"}}" > $TEST_CONFIGFILE
- go get ./...
- go get -u github.com/jstemmer/go-junit-report
- TEST_DATAFILE=$TEST_DATAFILE TEST_CONFIGFILE=$TEST_CONFIGFILE go test ./test/e2e -v 2>&1 | go-junit-report > report-e2e.xml
- TEST_DATAFILE=$TEST_DATAFILE TEST_CONFIGFILE=$TEST_CONFIGFILE go test ./test/e2e -v 2>&1 | $GOPATH/bin/go-junit-report > report-e2e.xml
artifacts:
reports:
junit: report-e2e.xml
compile:
stage: build
extends: .go-cache
script:
- cd $GOPATH/src/$REPO_NAME
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.akamu.de/".insteadOf "https://gitlab.akamu.de/"
- go get ./...
- GOOS=linux GOARCH=amd64 go build -tags netgo -a -ldflags "-extldflags '-static' -X 'gitlab.akamu.de/akamu/game-server-go/version.Identifier=$(< MILESTONE)' -X 'gitlab.akamu.de/akamu/game-server-go/version.Commit=$CI_COMMIT_SHORT_SHA' -X 'gitlab.akamu.de/akamu/game-server-go/version.Environment=$CI_COMMIT_REF_NAME' -X 'gitlab.akamu.de/akamu/game-server-go/version.Pipeline=$CI_PIPELINE_ID' -X 'gitlab.akamu.de/akamu/game-server-go/version.Job=$CI_JOB_ID' -X 'gitlab.akamu.de/akamu/game-server-go/version.BuiltOn=$(date)'" -o $CI_PROJECT_DIR/linux
artifacts:
paths:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment