-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy path.gitlab-ci.yml
100 lines (100 loc) · 4.27 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
before_script:
- |
reporter_token=9xyfSydF7bDYsUQbrnPv && \
request_url="http://open.inspur.com/api/v4/projects/$CI_PROJECT_ID/repository/commits/$CI_COMMIT_SHA/comments" && \
passed=':heavy_check_mark: <a href=\"'"$CI_PROJECT_URL"'/commit/'"$CI_COMMIT_SHA"'\">Test Passed</a>'
failed=':x: <a href=\"'"$CI_PROJECT_URL"'/commit/'"$CI_COMMIT_SHA"'\">Test Failed</a>'
variables:
golang_version: "1.14.0"
jenkins_version: "2.127"
last_version: "latest"
mysql_version: "5.7.31"
openldap_version: "1.1.11"
registry_ip: "10.110.27.103:6000"
stages:
- pre-merge-requests
- ui-test
- api-test
- report
pre-merge-requests:
stage: pre-merge-requests
script:
- echo ${CI_MERGE_REQUEST_PROJECT_URL}
- bare_url=`echo ${CI_MERGE_REQUEST_PROJECT_URL}|cut -d ":" -f 2-|sed 's/^..//g'`
- BASE_URL=$bare_url
- echo ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}
- git remote -v
- git remote add upstream http://gitlab-ci-token:$CI_TOKEN@$BASE_URL
- git remote -v
- git fetch upstream
- git config --local user.email $GITLAB_USER_EMAIL
- git config --local user.name $GITLAB_USER_NAME
- git merge upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
only:
- triggers
tags:
- board-runner-wangkun_lc-vm
job_ui_test:
before_script:
- echo "before script"
- docker pull $registry_ip/board/dev_uibuilder:7.4
- docker tag $registry_ip/board/dev_uibuilder:7.4 10.111.25.119/board/dev_uibuilder:7.4
script:
- pwd
- docker images
- docker-compose -f tests/docker-compose.uibuilder.test.yml up
- code=$(docker inspect tests_uibuilder7.4_1 -f "{{.State.ExitCode}}"), exit $code
stage: ui-test
tags:
- board-runner-wangkun_lc-vm
job_api_test:
before_script:
- source /etc/profile
- echo "before script"
- docker pull $registry_ip/library/golang:$golang_version
- docker tag $registry_ip/library/golang:$golang_version golang:$golang_version
- docker pull $registry_ip/library/registry:2.6.2
- docker tag $registry_ip/library/registry:2.6.2 registry:latest
- docker pull $registry_ip/library/mysql:$mysql_version
- docker tag $registry_ip/library/mysql:$mysql_version mysql:$mysql_version
- docker pull $registry_ip/library/openldap:$openldap_version
- docker tag $registry_ip/library/openldap:$openldap_version osixia/openldap:$openldap_version
- docker pull $registry_ip/board/board-gogits:$last_version
- docker tag $registry_ip/board/board-gogits:$last_version board-gogits:$last_version
- docker pull $registry_ip/board/dev_jenkins:dev
- docker tag $registry_ip/board/dev_jenkins:dev dev_jenkins:dev
- docker pull $registry_ip/board/dev_gomail:dev
- docker tag $registry_ip/board/dev_gomail:dev 10.111.25.119/board/dev_gomail:dev
- docker pull $registry_ip/library/python:tavern2
- docker tag $registry_ip/library/python:tavern2 python:tavern2
- docker run --rm -v `pwd`:/data -v /etc/board/cert:/etc/board/cert python:tavern2 /data/make/prepare
script:
- pwd
- docker images
- source tests/env.cfg
- cp tests/docker-compose.test.yml make/dev
- cp tests/ldap_test.ldif make/dev
- docker-compose -f make/dev/docker-compose.test.yml up -d
- sh tests/hosts.gitlab.sh
- docker run --rm -v $CI_PROJECT_DIR:/data/workspace/board/src/git/inspursoft/board -v /tmp:/tmp -w /data/workspace/board/src/git/inspursoft/board/tests --network host -e GOPATH=/data/workspace/board golang:$golang_version bash -c "source env.cfg && source run.sh"
- echo "test adminserver"
- docker run --rm -v $CI_PROJECT_DIR/src:/go/src/git/inspursoft/board/src -v $CI_PROJECT_DIR/VERSION:/go/bin/VERSION -w /go/src/git/inspursoft/board/src/adminserver -e GO111MODULE=off golang:$golang_version go build -v -o /go/bin/adminserver
stage: api-test
tags:
- board-runner-wangkun_lc-vm
report-on-success:
stage: report
script:
- |
curl -X POST $request_url -H "PRIVATE-TOKEN: $reporter_token" -H "Content-Type: application/json" -d '{ "note": "'"$passed"'" }'
when: on_success
tags:
- board-runner-wangkun_lc-vm
report-on-failure:
stage: report
script:
- |
curl -X POST $request_url -H "PRIVATE-TOKEN: $reporter_token" -H "Content-Type: application/json" -d '{ "note": "'"$failed"'" }'
when: on_failure
tags:
- board-runner-wangkun_lc-vm