This repository has been archived by the owner on Jan 5, 2021. It is now read-only.
forked from FDio/vpp
-
Notifications
You must be signed in to change notification settings - Fork 20
/
.gitlab-ci.yml
173 lines (164 loc) · 5.19 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
168
169
170
171
172
173
stages:
- prepare
- build
- test
variables:
REGISTRY: "quay.io"
CONTAINER_IMAGE: travelping/upf
# This is needed to disable TLS in recent docker:...dind images.
# TLS there is not really needed as docker client connects
# to localhost, and all of the docker certs only cause problems
# here
DOCKER_TLS_CERTDIR: ""
# prepare build image
prepare:
stage: prepare
image: docker:git
services:
- docker:19.03.8-dind
script:
- export DOCKER_HOST="tcp://localhost:2375"
- echo "quay.io login..."
- docker login -u ${QUAY_USER_ID} -p ${QUAY_TOKEN} ${REGISTRY}
- echo "Ensuring that proper build image exists ..."
- PUSH_BUILD_IMAGE=1 sh extras/docker/ensure-build-image.sh
only:
changes:
- Makefile
- extras/docker/Dockerfile.build
- build/external/**/*
# build container image
.build:
stage: build
#tags:
# - docker
image: docker:git
services:
- docker:19.03.8-dind
script:
- export CI_COMMIT_DESCRIBE=$(git describe --always --tags --dirty --first-parent)
- export CONTAINER_VARIANT=${CI_BUILD_NAME##*:}
- export CONTAINER_BASE_NAME=${REGISTRY}/${CONTAINER_IMAGE}:${CI_COMMIT_REF_SLUG}
- export CONTAINER_COMMIT_SHA=${CONTAINER_BASE_NAME}_${CI_COMMIT_SHA}_${CONTAINER_VARIANT}
- export CONTAINER_GIT_DESCRIBE=${CONTAINER_BASE_NAME}_${CI_COMMIT_DESCRIBE}_${CONTAINER_VARIANT}
- export DOCKER_HOST="tcp://localhost:2375"
- |
case "$CI_COMMIT_REF_NAME" in
stable/* | feature/20* ) export LABELS="";;
*) export LABELS="--label quay.expires-after=7d";;
esac
- echo "quay.io login..."
- docker login -u ${QUAY_USER_ID} -p ${QUAY_TOKEN} ${REGISTRY}
- echo "Building the image from $DOCKER_FILE ..."
- >
DOCKER_BUILDKIT=1 docker build
--target=build-stage
-t artifacts:${CI_COMMIT_SHA}_${CONTAINER_VARIANT}
-f ${DOCKER_FILE} .
- >
DOCKER_BUILDKIT=1 docker build
--progress=plain
${LABELS}
-t ${CONTAINER_COMMIT_SHA}
-t ${CONTAINER_GIT_DESCRIBE}
-f ${DOCKER_FILE} .
- docker push ${CONTAINER_COMMIT_SHA}
- docker push ${CONTAINER_GIT_DESCRIBE}
- echo "Extracting *.deb files from the image ..."
- mkdir debs
- >
DOCKER_BUILDKIT=1 docker run
--rm artifacts:${CI_COMMIT_SHA}_${CONTAINER_VARIANT} | tar -C "debs" -xf -
- |
echo "CI_JOB_NAME: ${CI_JOB_NAME}"
mkdir tst-install
if [[ ${CI_JOB_NAME} = "build:debug" ]]; then
docker run --rm --entrypoint /bin/tar \
artifacts:${CI_COMMIT_SHA}_${CONTAINER_VARIANT} \
-C /src/vpp \
-cz build-root/install-vpp_debug-native \
> tst-install/install.tar.gz
fi
dependencies:
- prepare
artifacts:
when: always
untracked: true
paths:
- debs
- tst-install
# build container image
build:release:
extends: .build
variables:
DOCKER_FILE: extras/docker/Dockerfile
build:debug:
extends: .build
variables:
DOCKER_FILE: extras/docker/Dockerfile.devel
test:debug:
stage: test
image: quay.io/travelping/upf-build
# FIXME: try not to use docker:dind. This may cause problems with shm_size
services:
- docker:19.03.8-dind
dependencies:
- build:debug
script:
- tar -xvzf tst-install/install.tar.gz
# temporary workaround for the hugepages issue
- sysctl vm.nr_hugepages=0
- |
mkdir test-out
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
if ! make -j8 retest-debug TEST=test_upf V=1; then
tar -C /tmp -cvzf /src/vpp/test-out/vpp-test.tar.gz . || true
tar -C /src/vpp/build-root/install-vpp_debug-native/ \
-cvzf /src/vpp/test-out/vpp.tar.gz vpp
ls -l test-out/
exit 1
fi
artifacts:
when: on_failure
paths:
- test-out
.test-ext:
stage: test
image: quay.io/travelping/upf-test:v0.0.6
services:
- docker:19.03.8-dind
script:
# https://github.com/docker/compose/issues/5696#issuecomment-377906769
- export COMPOSE_INTERACTIVE_NO_CLI=1
- CI_COMMIT_DESCRIBE=$(git describe --always --tags --dirty --first-parent)
- CONTAINER_VARIANT=debug
- CONTAINER_BASE_NAME=${REGISTRY}/${CONTAINER_IMAGE}:${CI_COMMIT_REF_SLUG}
- CONTAINER_GIT_DESCRIBE=${CONTAINER_BASE_NAME}_${CI_COMMIT_DESCRIBE}_${CONTAINER_VARIANT}
- SRC_DIR="${PWD}"
- cd /test
# temporary workaround for the hugepages issue
- sysctl vm.nr_hugepages=0
- docker-compose -f "${DOCKER_COMPOSE_FILE}" build --build-arg UNODE_BASE="${CONTAINER_GIT_DESCRIBE}"
- docker-compose -f "${DOCKER_COMPOSE_FILE}" run -e SESSION_MODIFICATION_COUNT=10 --rm cnodestub
- mkdir "${SRC_DIR}/pcaps"
- |
if ! scripts/vpp-report.sh | gzip >& "${SRC_DIR}/pcaps/report.txt.gz"; then
gunzip -c "${SRC_DIR}/pcaps/report.txt.gz"
fi
# FIXME: the following fails with "invalid tar magic"
# - docker-compose -f "${DOCKER_COMPOSE_FILE}" run --rm -T grabpcaps | tar -xv
- docker run --rm -v test_pcaps:/pcaps busybox:1.31.1 tar -C / -c pcaps | tar -C "${SRC_DIR}" -xv
dependencies:
- build:debug
artifacts:
paths:
- pcaps
test:external-ipv4:
extends: .test-ext
variables:
DOCKER_COMPOSE_FILE: docker-compose.yaml
test:external-ipv6:
extends: .test-ext
variables:
DOCKER_COMPOSE_FILE: docker-compose-v6.yaml