.gitlab-ci.yml 4.24 KB
Newer Older
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
1
2
3
4
5
6
7
8
9
10
11
stages:
- test
- publish

variables:
    DOCKER_TLS_CERTDIR: ""

default:
    image: golang:1.14

.test_setup: &test_setup
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
12
    - mkdir -p /go/src/gitlab.switch.ch/${CI_PROJECT_NAMESPACE}
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
13
14
15
    - ln -s $CI_PROJECT_DIR /go/src/gitlab.switch.ch/memoriav/memobase-2020/services/histogram
    - cd /go/src/gitlab.switch.ch/memoriav/memobase-2020/services/histogram

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
16
.test:lint:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
17
18
19
20
21
22
    stage: test
    tags: [mbr]
    before_script:
        - *test_setup
        - go get -u golang.org/x/lint/golint
    script:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
23
        - golint -set_exit_status $BIN_PATH
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
24
25
    allow_failure: true

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
26
.test:unit:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
27
28
29
30
    stage: test
    tags: [mbr]
    before_script: [*test_setup]
    script:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
31
        - go test -short $BIN_PATH
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
32
33
    allow_failure: true

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
34
.test:race:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
35
36
37
38
    stage: test
    tags: [mbr]
    before_script: [*test_setup]
    script:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
39
        - go test -race -short $BIN_PATH
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
40
41
    allow_failure: true

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
42
#test:msan:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
43
44
45
46
#    stage: test
#    tags: [mbr]
#    before_script: [*test_setup]
#    script:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
47
#        - go test -msan -short $BIN_PATH
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
48
49
#    allow_failure: true

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
50
.test:build:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
51
52
53
54
    stage: test
    tags: [mbr]
    before_script: [*test_setup]
    script:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
55
56
57
58
59
60
61
        - go build $BIN_PATH

histogram:test:lint:
    extends: .test:lint
    variables:
        BIN_PATH: gitlab.switch.ch/memoriav/memobase-2020/services/histogram/cmd/histogram

62
63
64
65
# histogram:test:unit:
#    extends: .test:unit
#    variables:
#        BIN_PATH: gitlab.switch.ch/memoriav/memobase-2020/services/histogram/cmd/histogram
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
66
67
68
69
70
71
72
73
74
75
76
77
78
79

histogram:test:race:
    extends: .test:race
    variables:
        BIN_PATH: gitlab.switch.ch/memoriav/memobase-2020/services/histogram/cmd/histogram

histogram:test:build:
    extends: .test:build
    variables:
        BIN_PATH: gitlab.switch.ch/memoriav/memobase-2020/services/histogram/cmd/histogram

webservice:test:lint:
    extends: .test:lint
    variables:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
80
        BIN_PATH: gitlab.switch.ch/memoriav/memobase-2020/services/histogram/cmd/webservice
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
81

82
83
84
85
# webservice:test:unit:
#    extends: .test:unit
#    variables:
#        BIN_PATH: gitlab.switch.ch/memoriav/memobase-2020/services/histogram/cmd/webservice
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
86
87
88
89

webservice:test:race:
    extends: .test:race
    variables:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
90
        BIN_PATH: gitlab.switch.ch/memoriav/memobase-2020/services/histogram/cmd/webservice
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
91
92
93
94

webservice:test:build:
    extends: .test:build
    variables:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
95
        BIN_PATH: gitlab.switch.ch/memoriav/memobase-2020/services/histogram/cmd/webservice
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
96
97
98
99
100
101

.build-image:
    stage: publish
    image: docker:stable
    services:
        - docker:dind
102
103
    # before_script:
    #     - apk update && apk add curl
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
104
    script:
105
106
107
        # - 'curl --location --output ffprobe --header "PRIVATE-TOKEN: $API_ACCESS_TOKEN" "https://gitlab.switch.ch/api/v4/projects/937/jobs/artifacts/master/raw/ffmpeg_build/bin/ffprobe?job=snapshot"'
        # - 'curl --location --output convert --header "PRIVATE-TOKEN: $API_ACCESS_TOKEN" "https://gitlab.switch.ch/api/v4/projects/939/jobs/artifacts/master/raw/im_build/bin/convert?job=v6_9_11"'
        # - 'curl --location --output identify --header "PRIVATE-TOKEN: $API_ACCESS_TOKEN" "https://gitlab.switch.ch/api/v4/projects/939/jobs/artifacts/master/raw/im_build/bin/identify?job=v6_9_11"'
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
108
109
110
111
112
        - docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASSWORD" "$REGISTRY"
        - docker build --pull -t "$IMAGE_TAG" -f "$DOCKERFILE" .
        - docker push "$IMAGE_TAG"
        - docker logout

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
113
indexerhelper:build-tagged-image:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
114
115
116
117
118
119
120
121
122
123
    extends: .build-image
    variables:
        IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
        REGISTRY_PASSWORD: "$CI_REGISTRY_PASSWORD"
        REGISTRY_USER: "$CI_REGISTRY_USER"
        REGISTRY: "$CI_REGISTRY"
        DOCKERFILE: "Dockerfile"
    only:
        - tags

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
124
indexerhelper:build-latest-image:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
125
126
127
128
129
130
131
132
133
134
    extends: .build-image
    variables:
        IMAGE_TAG: "$CI_REGISTRY_IMAGE:latest"
        REGISTRY_PASSWORD: "$CI_REGISTRY_PASSWORD"
        REGISTRY_USER: "$CI_REGISTRY_USER"
        REGISTRY: "$CI_REGISTRY"
        DOCKERFILE: "Dockerfile"
    only:
        - master

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
135
indexerhelper:build-feature-branch-image:
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
136
137
138
139
140
141
142
143
144
145
    extends: .build-image
    variables:
        IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
        REGISTRY_PASSWORD: "$CI_REGISTRY_PASSWORD"
        REGISTRY_USER: "$CI_REGISTRY_USER"
        REGISTRY: "$CI_REGISTRY"
        DOCKERFILE: "Dockerfile.small"
    except:
        - master
        - tags