-
Notifications
You must be signed in to change notification settings - Fork 21
/
.gitlab-ci.yml
128 lines (116 loc) · 3.29 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
image: registry.gitlab.com/yakshaving.art/dockerfiles/go-builder:latest
stages:
- build
- image
- release
variables:
CGO_ENABLED: 0
GOCACHE: ${CI_PROJECT_DIR}/.cache/go-build
test_mysql:
stage: build
cache:
key: build-cache
paths:
- ${CI_PROJECT_DIR}/.cache/go-build
services:
- mysql:5.7
variables:
MYSQL_DATABASE: alertsnitch
MYSQL_ROOT_PASSWORD: mysql
ALERTSNITCH_DSN: "root:${MYSQL_ROOT_PASSWORD}@tcp(mysql)/${MYSQL_DATABASE}"
ALERTSNITCH_BACKEND: mysql
coverage: '/^total:\s+\(statements\)\s+(\d+.\d+)%$/'
script:
- apk --no-cache add mysql-client bash
- bash script.d/bootstrap_mysql.sh
- bash script.d/test.sh
test_postgres:
stage: build
services:
- name: postgres:11
alias: postgres
variables:
POSTGRES_DB: alertsnitch
POSTGRES_USER: runner
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
ALERTSNITCH_DSN: "sslmode=disable user=${POSTGRES_USER} password='' host=postgres database=${POSTGRES_DB}"
ALERTSNITCH_BACKEND: postgres
coverage: '/^total:\s+\(statements\)\s+(\d+.\d+)%$/'
script:
- apk --no-cache add postgresql-client bash
- bash script.d/bootstrap_postgres.sh
- bash script.d/test.sh
build:
stage: build
artifacts:
paths:
- alertsnitch-*
script:
- make build
- GOARCH=arm64 make build
- GOARCH=arm GOARM=6 make build
.docker: &docker
image: docker:stable
services:
- docker:dind
variables:
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
before_script:
- echo ${CI_JOB_TOKEN} | docker login -u gitlab-ci-token --password-stdin ${CI_REGISTRY}
after_script:
- docker logout
.build_image: &build_image
<<: *docker
stage: image
script:
- echo Building ${ARCH} image
- cp Dockerfile.${ARCH} Dockerfile
- docker build --pull -t ${CI_REGISTRY_IMAGE}:${ARCH}-latest .
- docker push ${CI_REGISTRY_IMAGE}:${ARCH}-latest
- rm Dockerfile
build_arm64:
<<: *build_image
variables:
ARCH: arm64
build_amd64:
<<: *build_image
variables:
ARCH: amd64
build_armhf:
<<: *build_image
variables:
ARCH: armhf
release_latest:
<<: *docker
stage: release
script:
- docker manifest create ${CI_REGISTRY_IMAGE}:latest
${CI_REGISTRY_IMAGE}:amd64-latest
${CI_REGISTRY_IMAGE}:arm64-latest
${CI_REGISTRY_IMAGE}:armhf-latest
- docker manifest annotate ${CI_REGISTRY_IMAGE}
${CI_REGISTRY_IMAGE}:arm64-latest --os linux --arch arm64
- docker manifest annotate ${CI_REGISTRY_IMAGE}
${CI_REGISTRY_IMAGE}:armhf-latest --os linux --arch arm --variant 6
- docker manifest push ${CI_REGISTRY_IMAGE}:latest
only:
- master
release_tag:
<<: *docker
stage: release
script:
- docker manifest create ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
${CI_REGISTRY_IMAGE}:amd64-latest
${CI_REGISTRY_IMAGE}:arm64-latest
${CI_REGISTRY_IMAGE}:armhf-latest
- docker manifest annotate ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
${CI_REGISTRY_IMAGE}:arm64-latest --os linux --arch arm64
- docker manifest annotate ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
${CI_REGISTRY_IMAGE}:armhf-latest --os linux --arch arm --variant 6
- docker manifest push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
only:
- tags