forked from cyberark/secretless-broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
167 lines (146 loc) · 3.16 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
image: docker:stable-git
variables:
IMAGE_TAGS: |
secretless-broker
secretless-dev
secretless-broker-quickstart
stages:
- build
- test
- website
build:
stage: build
services:
- docker:stable-dind
variables:
DOCKER_DRIVER: overlay2
script:
- setup_docker
- ./bin/build
- save_images
only:
- branches
check_style:
stage: test
services:
- docker:stable-dind
variables:
DOCKER_DRIVER: overlay2
script:
- setup_docker
- get_images
- ./bin/check_style
only:
- branches
artifacts:
paths:
- test/golint.xml
test_unit:
stage: test
services:
- docker:stable-dind
variables:
DOCKER_DRIVER: overlay2
script:
- setup_docker
- get_images
- ./bin/test_unit
only:
- branches
artifacts:
reports:
junit: test/junit.xml
test_integration:
stage: test
services:
- docker:stable-dind
variables:
DOCKER_DRIVER: overlay2
script:
- setup_docker
- get_images
- ./bin/test_integration
only:
- branches
artifacts:
reports:
junit: test/junit.xml
test_demo:
stage: test
services:
- docker:stable-dind
variables:
DOCKER_DRIVER: overlay2
script:
- setup_docker
- get_images
- ./bin/test_demo
only:
- branches
website:
stage: website
services:
- docker:stable-dind
variables:
DOCKER_DRIVER: overlay2
script:
- setup_docker
- get_images
- ./bin/build_website
- ./bin/check_website_links
only:
- branches
.utils: &utils |
# variables and functions
[[ "$TRACE" ]] && set -x
export CI_APPLICATION_REPOSITORY=$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG
export CI_APPLICATION_TAG=$CI_COMMIT_SHA
export CI_CONTAINER_NAME=ci_job_build_${CI_JOB_ID}
export ALL_TAGS="";
VERSION=$(cat VERSION);
ALL_TAGS=$(echo "$IMAGE_TAGS" | sed '/^$/d' | while read -r line; do
echo "$line:latest"
done
)
function login_ci_registry() {
if [[ -n "$CI_REGISTRY_USER" ]]; then
echo "Logging to GitLab Container Registry with CI credentials..."
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
echo ""
fi
}
function setup_docker() {
login_ci_registry
}
function save_image() {
tag=$(echo $1 | sed -e 's/\:/-/' -e 's/\//-/')
docker tag $1 "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG-$tag"
docker push "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG-$tag"
}
function get_image() {
tag=$(echo $1 | sed -e 's/\:/-/' -e 's/\//-/')
docker pull "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG-$tag"
docker tag "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG-$tag" $1
}
function save_images() {
echo "$ALL_TAGS" | while read -r line; do
save_image "$line";
done
}
function optional_get_images() {
echo "$ALL_TAGS" | while read -r line; do
get_image "$line" 2> /dev/null || true;
done
}
function get_images() {
echo "$ALL_TAGS" | while read -r line; do
get_image "$line";
done
}
echo "loaded utils"
before_script:
- apk add --no-cache bash
- apk add --no-cache openssl
- apk add --no-cache py-pip
- pip install docker-compose
- *utils