-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
76 lines (71 loc) · 2.42 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
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml
# Build a Docker image with CI/CD and push to the GitLab registry.
# Docker-in-Docker documentation: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
---
stages: ["build", "test"]
build-auto_disc:
stage: "build"
tags:
- ci.inria.fr
- medium
image: docker:stable
script:
# login to docker registry
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "${CI_REGISTRY}"
# build image
- export BUILD_CONTEXT=services/base/AutoDiscServer
- docker build -f "${BUILD_CONTEXT}/Dockerfile" --target library -t "${CI_REGISTRY_IMAGE}/auto_disc" ${BUILD_CONTEXT}
# push image
- docker push "${CI_REGISTRY_IMAGE}/auto_disc"
test-auto_disc:
stage: "test"
tags:
- ci.inria.fr
- medium
image: "$CI_REGISTRY_IMAGE/auto_disc"
script:
- cd /usr/src/libs/auto_disc
- pip install -e ".[test]"
- coverage run -m pytest
build-autodisc-server:
stage: "build"
tags:
- ci.inria.fr
- medium
image: docker:23.0-git
script:
# load environment variables
- cp .gitlab-ci/sample.env services/prod/.env
# login to docker registry
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "${CI_REGISTRY}"
# build and push image
- export BUILD_CONTEXT=services/prod
- cd ${BUILD_CONTEXT}
- export DOCKER_REGISTRY=${CI_REGISTRY_IMAGE}
- export RELEASE_TAG=${CI_COMMIT_SHORT_SHA}
- docker-compose build autodisc-server
- docker tag ${DOCKER_REGISTRY}/prod-autodisc-server:${RELEASE_TAG} latest
- docker compose push ${DOCKER_REGISTRY}/prod-autodisc-server:${RELEASE_TAG}
test-autodisc-server:
stage: "test"
tags:
- ci.inria.fr
- small
image: docker:23.0-git
script:
# load environment variables
- cp .gitlab-ci/sample.env services/dev/.env
# run the server
- cd services/dev
- docker-compose up -d autodisc-server
# FIXME: need to implement healthcheck to see if server is up
- sleep 30
# run REST endpoint test
- apk add npm
- npm install -g newman
- cd services/base/AutoDiscServer/tests/newman
- newman run test_AutoDiscServer.json