.gitlab-ci.yml 1.07 KB
Newer Older
Lukas Böhm's avatar
Lukas Böhm committed
1
2
image: golang:latest

Lukas Böhm's avatar
Lukas Böhm committed
3
4
5
6
7
8
9
10
cache:
  paths:
    - /apt-cache
    - /go/src/github.com
    - /go/src/golang.org
    - /go/src/google.golang.org
    - /go/src/gopkge

Lukas Böhm's avatar
Lukas Böhm committed
11
variables:
Lukas Böhm's avatar
Lukas Böhm committed
12
  REPO_NAME: gitlab.cs.fau.de/chiefs/chiefsend2
Lukas Böhm's avatar
Lukas Böhm committed
13
14
15
16
17
18
19
20

# 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:
Lukas Böhm's avatar
Lukas Böhm committed
21
  - cd $CI_PROJECT_DIR/builds/chiefs/chiefsend2/api
Lukas Böhm's avatar
Lukas Böhm committed
22
23
24
25
26
  - mkdir -p ./test/data
  - mkdir -p ./test/temp
  - export DATABASE_URI=sqlite:test.db
  - export MEDIA_DIR=./media/test

Lukas Böhm's avatar
Lukas Böhm committed
27
28
29
30
31
32
33

stages:
  - test
  - build

test:
  script:
Lukas Böhm's avatar
Lukas Böhm committed
34
    - go mod init
Lukas Böhm's avatar
Lukas Böhm committed
35
36
    - go fmt $(go list ./... | grep -v /vendor/)
    - go vet $(go list ./... | grep -v /vendor/)
Lukas Böhm's avatar
Lukas Böhm committed
37
    - go test $(go list ./... | grep -v /vendor/) -v -cover
Lukas Böhm's avatar
Lukas Böhm committed
38
39
40

build:
  script:
Lukas Böhm's avatar
Lukas Böhm committed
41
    - go build -o $CI_PROJECT_DIR/mybinary .
Lukas Böhm's avatar
Lukas Böhm committed
42
43
44
  artifacts:
    paths:
      - mybinary