-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
110 lines (97 loc) · 2.84 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
before_script:
- export DISTRO_CODENAME=`lsb_release -cs` && echo Using distro $DISTRO_CODENAME
- export DEBIAN_FRONTEND=noninteractive
- apt-get update -yq && apt-get install -y lintian git libgrpc++-dev protobuf-compiler-grpc libpng-dev
variables:
GET_SOURCES_ATTEMPTS: "3"
GIT_DEPTH: "0"
stages:
- test
- deploy
- image
#########################
# Templates using anchors
#########################
.amd64_focal_t: &amd64_focal_job
image: registry.roboception.de/tools/docker_images:focal-buildimage
tags:
- amd64
- docker
#############
# Templates
#############
.test:
stage: test
script:
- mkdir build && cd build
- cmake ..
- make -j 4
#- CTEST_OUTPUT_ON_FAILURE=1 make test
# Debian packaging
.package:
stage: deploy
script:
- mkdir build && cd build
- cmake ..
- make -j 4
- make package
- if [ -z "$APT_REPO" ]; then export APT_REPO=testing; fi
- upload_deb.sh $DISTRO_CODENAME-$APT_REPO *.deb
.package_testing:
extends: .package
only:
- master
except:
- tags
variables:
TESTING_DEBS: "true"
APT_REPO: "testing"
.package_stable:
extends: .package
only:
- /^v[0-9]+\.[0-9]+\.[0-9]+/
except:
- branches
variables:
APT_REPO: "stable"
.docker_build:
image: docker:latest
stage: image
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- if [ -z "$IMAGE" ]; then export IMAGE=$CI_REGISTRY_IMAGE ; fi
- if [ -n "$CI_COMMIT_TAG" ]; then export IMAGE_TAG=$CI_COMMIT_TAG ; else export IMAGE_TAG=$CI_COMMIT_REF_SLUG ; fi
- if [ "$CI_COMMIT_REF_NAME" = "master" ]; then export IMAGE_TAG=testing ; fi
- if [ -z "$DOCKER_BUILD_FLAGS" ]; then export DOCKER_BUILD_FLAGS="--pull --no-cache --build-arg RC_REPO=$RC_REPO"; fi
- if [ -z "$DOCKERFILE_DIR" ]; then export DOCKERFILE_DIR=.; fi
script:
- echo "building docker image $IMAGE:$IMAGE_TAG with flags $DOCKER_BUILD_FLAGS"
- docker build $DOCKER_BUILD_FLAGS -t $IMAGE:$IMAGE_TAG $DOCKERFILE_DIR
- docker push $IMAGE:$IMAGE_TAG
- if [ -n "$CI_COMMIT_TAG" ]; then docker tag $IMAGE:$IMAGE_TAG $IMAGE:latest; docker push $IMAGE:latest; docker rmi $IMAGE:latest; fi
- docker rmi $IMAGE:$IMAGE_TAG || true
tags:
- docker-build
##############
#### Jobs ####
##############
# Test against (on every commit)
################################
test:focal:amd64:
<<: *amd64_focal_job
extends: .test
# Deploy testing (only on master)
#################################
package_testing:focal:amd64:
<<: *amd64_focal_job
extends: .package_testing
# Deploy stable (only for releases, version tags)
#################################################
package_stable:focal:amd64:
<<: *amd64_focal_job
extends: .package_stable
# Build and push as docker image
################################
docker_image:
extends: .docker_build