-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
64 lines (57 loc) · 1.66 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
stages:
- tests_and_lints
- build_image
variables:
DOCKER_REGISTRY: registry.cn-hangzhou.aliyuncs.com/leosocy
IMAGE: ${DOCKER_REGISTRY}/ppic
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_CONNECTION_URL: ${MYSQL_CONNECTION_URL}
before_script:
- IMAGE_TAG=${IMAGE}:${CI_COMMIT_SHA:0:8}
# -------------------- Tests --------------------
build_test_coverage:
stage: tests_and_lints
image:
name: ${IMAGE}:ci
services:
- name: mysql:8.0
alias: mysql
coverage: '/lines[\.]+\: (\d+\.\d+)\%/'
script:
- mkdir -p test_build; cd test_build
- cmake ../tests; make -j
- ./ppic_test
- lcov -b . -d . -c -o cov.info
- lcov -r cov.info "/usr/*" "*/thirdparty/*" "*/tests/*" "*/test_build/*" -o cov.info -q
- lcov -l cov.info
- bash <(curl -s https://codecov.io/bash) -t ${CODECOV_TOKEN}
- genhtml -o cov_result cov.info
- mv cov_result ..
artifacts:
name: coverage
paths:
- cov_result
# -------------------- Lints --------------------
cppcheck:
stage: tests_and_lints
image:
name: ${DOCKER_REGISTRY}/cppcheck:1.83
script:
- cppcheck -j 4 --enable=warning,performance --error-exitcode=1 app
# -------------------- Build onbuild image --------------------
build_image:
stage: build_image
image: docker:latest
tags:
- docker
only:
- master
when: manual
services:
- docker:dind
script:
- docker login --username ${ALIYUN_DOCKER_REGISTRY_USERNAME} --password-stdin ${ALIYUN_DOCKER_REGISTRY_PASSWD} ${DOCKER_REGISTRY}
- docker build -t ${IMAGE_TAG} -f Dockerfile .
- docker tag ${IMAGE_TAG} ${IMAGE}:latest
- docker push ${IMAGE}