.gitlab-ci.yml 2.37 KB
Newer Older
1
image: golang:1.13
Christian Pointner's avatar
Christian Pointner committed
2

Christian Pointner's avatar
Christian Pointner committed
3
4
variables:
  GOPATH: "$CI_PROJECT_DIR/.gopath"
5

6
7
cache:
  paths:
Christian Pointner's avatar
Christian Pointner committed
8
    - .gopath/
9
    - ui/assets_vfsdata.go
Christian Pointner's avatar
Christian Pointner committed
10
11
  key: default
  policy: pull
12

Christian Pointner's avatar
Christian Pointner committed
13
stages:
Christian Pointner's avatar
Christian Pointner committed
14
  - prepare
15
16
  - test
  - build
Christian Pointner's avatar
Christian Pointner committed
17

18

Christian Pointner's avatar
Christian Pointner committed
19
20
21
22
prepare:
  stage: prepare
  cache:
    policy: pull-push
23
  script:
Christian Pointner's avatar
Christian Pointner committed
24
25
26
    - mkdir -p .gopath
    - export GOPATH="$CI_PROJECT_DIR/.gopath"
    - go generate ./ui
27
28
    - go vet ./...

Christian Pointner's avatar
Christian Pointner committed
29

Christian Pointner's avatar
Christian Pointner committed
30
test-all-but-store:
31
32
33
  stage: test
  script:
    - go test -v -cover $(go list ./... | grep -v tank/store)
34
35

test-store-mysql:
36
37
38
39
40
41
42
  stage: test
  services:
    - mysql:5.7
  variables:
    MYSQL_DATABASE: "tank"
    MYSQL_USER: "tank"
    MYSQL_PASSWORD: "aura"
43
    MYSQL_RANDOM_ROOT_PASSWORD: "yes"
44
    MYSQL_INITDB_SKIP_TZINFO: "1"
45
46
47
    AURA_TANK_TEST_DB_TYPE: "mysql"
    AURA_TANK_TEST_DB_HOST: "mysql"
  script:
48
    - go run contrib/waitfor-tcp.go mysql:3306 30
49
    - go test -v -cover ./store
50

Christian Pointner's avatar
Christian Pointner committed
51
52
53
54
55
56
57
58
test-store-mariadb:
  stage: test
  services:
    - mariadb:10.1
  variables:
    MYSQL_DATABASE: "tank"
    MYSQL_USER: "tank"
    MYSQL_PASSWORD: "aura"
59
    MYSQL_RANDOM_ROOT_PASSWORD: "yes"
Christian Pointner's avatar
Christian Pointner committed
60
    MYSQL_INITDB_SKIP_TZINFO: "1"
Christian Pointner's avatar
Christian Pointner committed
61
62
63
    AURA_TANK_TEST_DB_TYPE: "mysql"
    AURA_TANK_TEST_DB_HOST: "mariadb"
  script:
64
    - go run contrib/waitfor-tcp.go mariadb:3306 30
Christian Pointner's avatar
Christian Pointner committed
65
66
    - go test -v -cover ./store

67
test-store-postgres:
68
69
70
71
72
73
74
75
76
77
  stage: test
  services:
    - postgres:9.6
  variables:
    POSTGRES_DB: "tank"
    POSTGRES_USER: "tank"
    POSTGRES_PASSWORD: "aura"
    AURA_TANK_TEST_DB_TYPE: "postgres"
    AURA_TANK_TEST_DB_HOST: "postgres"
  script:
78
    - go run contrib/waitfor-tcp.go postgres:5432 30
79
80
    - go test -v -cover ./store

Christian Pointner's avatar
Christian Pointner committed
81

Christian Pointner's avatar
Christian Pointner committed
82
build:
83
84
85
86
87
  stage: build
  script:
    - go build -ldflags "-extldflags '-static'" -tags netgo -o $CI_PROJECT_DIR/tank ./cmd/tank
    ## sqlite needs cgo... :(
    ##- go build -o $CI_PROJECT_DIR/tank ./cmd/tank
88
89
  only:
    - master
90
91
92
  artifacts:
    paths:
      - tank
93
94
95
96
97
98

docker:
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
Christian Pointner's avatar
Christian Pointner committed
99
100
101
102
103
  cache:
    paths:
      - .docker/cache
    key: default
    policy: pull-push
104
  script:
Christian Pointner's avatar
Christian Pointner committed
105
    - mkdir -p $CI_PROJECT_DIR/.docker/cache
Christian Pointner's avatar
Christian Pointner committed
106
    - echo "{\"auths\":{\"index.docker.io\":{\"auth\":\"$DOCKER_HUB_AUTH\"}}}" > /kaniko/.docker/config.json
Christian Pointner's avatar
Christian Pointner committed
107
    - /kaniko/executor --cache=true --cache-dir $CI_PROJECT_DIR/.docker/cache --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination autoradio/tank:$CI_COMMIT_REF_NAME
108
109
  only:
    - master