-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
86 lines (75 loc) · 2.21 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
image: golang:1.14
variables:
DOCKER_IMAGE: registry.gitlab.com/${CI_PROJECT_PATH}
GOFLAGS: -mod=readonly
stages:
- test
- build
- packaging
test:
stage: test
script: make test
artifacts:
reports:
junit: build/test_results/main/results.xml
test-integration:
stage: test
script: make test-integration
artifacts:
reports:
junit: build/test_results/integration/results.xml
# Disabled for now because the linter times out on Gitlab
#lint:
# stage: test
# script: make lint
.build: &build_definition
stage: build
script:
- export CI_BUILD_DATE=$(date +%FT%T%z)
- make build-release VERSION=${CI_COMMIT_REF_NAME} COMMIT_HASH=${CI_COMMIT_SHA} BUILD_DATE=${CI_BUILD_DATE}
- make build-debug VERSION=${CI_COMMIT_REF_NAME} COMMIT_HASH=${CI_COMMIT_SHA} BUILD_DATE=${CI_BUILD_DATE}
snapshot:
<<: *build_definition
only:
- master
artifacts:
paths:
- build/
expire_in: 2 days
release:
<<: *build_definition
only:
- tags
artifacts:
paths:
- build/
.docker: &docker_definition
stage: packaging
image: docker:stable
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
services:
- docker:dind
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- apk add --update --no-cache ca-certificates make
script:
- docker build -t ${DOCKER_IMAGE}:${CI_COMMIT_REF_NAME} .
- if [[ "${CI_COMMIT_REF_NAME}" == "${CI_COMMIT_TAG}" ]]; then docker tag ${DOCKER_IMAGE}:${CI_COMMIT_REF_NAME} ${DOCKER_IMAGE}:latest; fi
- docker build -t ${DOCKER_IMAGE}:${CI_COMMIT_REF_NAME}-debug --build-arg BUILD_TARGET=debug .
- if [[ "${CI_COMMIT_REF_NAME}" == "${CI_COMMIT_TAG}" ]]; then docker tag ${DOCKER_IMAGE}:${CI_COMMIT_REF_NAME}-debug ${DOCKER_IMAGE}:latest-debug; fi
- docker push ${DOCKER_IMAGE}
docker:snapshot:
<<: *docker_definition
dependencies:
- snapshot
only:
- master
docker:release:
<<: *docker_definition
dependencies:
- release
only:
- tags