-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
78 lines (71 loc) · 2.18 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
variables:
GIT_SUBMODULE_STRATEGY: recursive
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
RELEASE_TAG: $CI_REGISTRY_IMAGE:latest
stages:
- build
- test
- release
default:
image: docker/compose
before_script:
- docker info
retry:
max: 2
when: runner_system_failure
build-image:
stage: build
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
test-docker-compose-config:
stage: build
script:
- touch .env
- docker-compose config
test-image:
stage: test
needs: ["build-image"]
services:
- docker:dind
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker pull $IMAGE_TAG
- docker run -d --name bitnp-accounts -e acct_client_id="bitnp-accounts" -e acct_client_secret="client_secret" -e acct_session_secret="session_secret" -e acct_invitation_secret="invitation_secret" $IMAGE_TAG
- sleep 10
- 'if docker ps -a | grep bitnp-accounts | grep "Stop\|Restart\|Exit"; then docker logs bitnp-accounts;exit 1; fi'
- 'if ! wget "http://`docker inspect -f ''{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'' bitnp-accounts`/" -O - -q | grep "网协通行证"; then docker logs bitnp-accounts;exit 1; fi'
- docker ps
after_script:
- docker rm -f bitnp-accounts
test-mypy:
stage: test
needs: ["build-image"]
allow_failure: true
services:
- docker:dind
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker pull $IMAGE_TAG
- docker run --rm -e acct_client_id="bitnp-accounts" -e acct_client_secret="client_secret" -e acct_session_secret="session_secret" -e acct_invitation_secret="invitation_secret" $IMAGE_TAG mypy -p accountsvc
release-image:
stage: release
needs: ["build-image", "test-image"]
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker pull $IMAGE_TAG
- docker tag $IMAGE_TAG $RELEASE_TAG
- docker push $RELEASE_TAG
only:
- master