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

Cache go dependencies

parent 4900ac50
Pipeline #2311 failed with stage
in 6 minutes and 44 seconds
...@@ -7,15 +7,14 @@ variables: ...@@ -7,15 +7,14 @@ variables:
MYSQL_PASSWORD: tester MYSQL_PASSWORD: tester
MYSQL_DATABASE: akamu MYSQL_DATABASE: akamu
# The problem is that to be able to use go get, one needs to put .go-cache:
# the repository in the $GOPATH. So for example if your gitlab domain variables:
# is gitlab.com, and that your repository is namespace/project, and GOPATH: $CI_PROJECT_DIR/.go
# the default GOPATH being /go, then you'd need to have your before_script:
# repository in /go/src/gitlab.com/namespace/project - mkdir -p .go
# Thus, making a symbolic link corrects this. cache:
before_script: paths:
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME) - .go/pkg/mod/
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
stages: stages:
- test - test
...@@ -24,21 +23,19 @@ stages: ...@@ -24,21 +23,19 @@ stages:
precheck: precheck:
stage: test stage: test
extends: .go-cache
script: 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/" - 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 fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/) - go vet $(go list ./... | grep -v /vendor/)
unittest: unittest:
stage: test stage: test
extends: .go-cache
script: 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/" - 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 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: artifacts:
reports: reports:
junit: report-unit.xml junit: report-unit.xml
...@@ -47,8 +44,8 @@ e2etest: ...@@ -47,8 +44,8 @@ e2etest:
stage: test stage: test
services: services:
- mariadb:latest - mariadb:latest
extends: .go-cache
script: 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/" - 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 - 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 - 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: ...@@ -57,19 +54,17 @@ e2etest:
- TEST_CONFIGFILE=$CI_PROJECT_DIR/test/e2e/testconfig.json - TEST_CONFIGFILE=$CI_PROJECT_DIR/test/e2e/testconfig.json
- TEST_DATAFILE=$CI_PROJECT_DIR/resources/data/testdata.sql - 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 - 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 - 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: artifacts:
reports: reports:
junit: report-e2e.xml junit: report-e2e.xml
compile: compile:
stage: build stage: build
extends: .go-cache
script: 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/" - 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 - 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: artifacts:
paths: 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