-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
79 lines (73 loc) · 2.77 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
variables:
GIT_DEPTH: 1
UPSTREAM_REF:
value: master
description: "Name of upstream (cdrouter) branch. Variable used by test job."
stages:
- build
workflow:
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
- if: '$CI_PIPELINE_SOURCE == "schedule"'
- if: '$CI_PIPELINE_SOURCE == "web"'
# jobs starting with a period (.) are ignored
# default:
# before_script:
# - |
# if [ -n "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]; then
# git checkout -B $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME;
# elif [ -n "$CI_COMMIT_BRANCH" ]; then
# git checkout -B $CI_COMMIT_BRANCH;
# fi
docker:
image: docker:19.03.12-git
services:
- docker:19.03.12-dind
stage: build
script:
- |
CDR_DOCKER_VER=$(echo $CI_COMMIT_TAG | tr -d v)
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
docker build -t cdrouter.py/cdrouter.py:$CDR_DOCKER_VER .
docker tag cdrouter.py/cdrouter.py:$CDR_DOCKER_VER $CI_REGISTRY/qacafe/cdrouter/cdrouter.py/cdrouter.py:$CDR_DOCKER_VER
docker tag cdrouter.py/cdrouter.py:$CDR_DOCKER_VER $CI_REGISTRY/qacafe/cdrouter/cdrouter.py/cdrouter.py:latest
docker push $CI_REGISTRY/qacafe/cdrouter/cdrouter.py/cdrouter.py:$CDR_DOCKER_VER
docker push $CI_REGISTRY/qacafe/cdrouter/cdrouter.py/cdrouter.py:latest
interruptible: true
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
test:
image: docker:19.03.12-git
stage: build
needs:
- project: qacafe/cdrouter/cdrouter
job: releases
ref: $UPSTREAM_REF
artifacts: true
script:
- apk add curl
- |
export CDR_DOCKER_LICENSE=$(curl -Ls -H "Authorization: Bearer $LOUNGE_API_TOKEN" 'https://admin-lounge.corp.qacafe.com/api/licenses/1864?format=download&ci=true' | base64 - | tr -d '\n')
- |
if [ "$UPSTREAM_REF" = "master" ]; then
CDR_DOCKER_VER=latest
else
CDR_RELEASE=$(find out/releases -type f -regex .\*/cdrouter-[0-9].\* -print)
CDR_DOCKER_VER=$(basename $CDR_RELEASE | sed -e 's/cdrouter-\(.*\)\.qacafe\.x86_64.rpm/\1/')
fi
export CDR_DOCKER_IMAGE=$CI_REGISTRY/qacafe/cdrouter/cdrouter/cdrouter:$CDR_DOCKER_VER
- echo $CDR_DOCKER_IMAGE
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- apk add python3 curl gcc python3-dev musl-dev linux-headers
- curl -s https://bootstrap.pypa.io/pip/get-pip.py | python3
- pip3 install tox
- tox -p --parallel-no-spinner
interruptible: true
artifacts:
name: "cdrouter.py-coverage-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}"
paths:
- .coverage*
- htmlcov/*