-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
108 lines (93 loc) · 2.31 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
101
102
103
104
105
106
107
108
image: python:3.9
variables:
DOCKER_IMAGE: $CI_REGISTRY_IMAGE
DOCKER_TAG: $CI_COMMIT_SHORT_SHA
stages:
- prepare
- build
- lint
- tests
- deploy
.ssh_key_template: &ssh_key_template
before_script:
- chmod 400 $SSH_PRIVATE_KEY
- mkdir -p ~/.ssh
- cp $SSH_PRIVATE_KEY ~/.ssh/id_rsa
- chmod 400 ~/.ssh/id_rsa
after_script:
- rm -f ~/.ssh/id_rsa
pull_model:
<<: *ssh_key_template
stage: prepare
script:
- make install_dvc
- make download_model
artifacts:
paths:
- models/*.onnx
expire_in: 1 day
.docker_login: &docker_login
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
.docker_common: &docker_common
image: docker
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
services:
- docker:20.10.5-dind
build_image:
stage: build
<<: *docker_common
script:
- *docker_login
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --cache-from $DOCKER_IMAGE:latest --tag ${DOCKER_IMAGE}:${DOCKER_TAG} --tag ${DOCKER_IMAGE}:latest .
- docker push ${DOCKER_IMAGE}:${DOCKER_TAG}
- docker push ${DOCKER_IMAGE}:latest
needs:
- pull_model
lint:
stage: lint
<<: *docker_common
script:
- *docker_login
- docker pull ${DOCKER_IMAGE}:${DOCKER_TAG}
- docker run ${DOCKER_IMAGE}:${DOCKER_TAG} bash -c 'make lint'
needs:
- build_image
unit_tests:
stage: tests
<<: *docker_common
script:
- *docker_login
- docker pull ${DOCKER_IMAGE}:${DOCKER_TAG}
- docker run ${DOCKER_IMAGE}:${DOCKER_TAG} bash -c 'make run_unit_tests'
needs:
- build_image
integration_tests:
stage: tests
<<: *docker_common
script:
- *docker_login
- docker pull ${DOCKER_IMAGE}:${DOCKER_TAG}
- docker run ${DOCKER_IMAGE}:${DOCKER_TAG} bash -c 'make run_integration_tests'
needs:
- build_image
deploy:
stage: deploy
variables:
ANSIBLE_HOST_KEY_CHECKING: "false"
script:
- python3 -m pip install ansible==6.0.0
- make deploy DOCKER_IMAGE=${DOCKER_IMAGE} DOCKER_TAG=${DOCKER_TAG}
when: manual
<<: *ssh_key_template
destroy:
stage: deploy
variables:
ANSIBLE_HOST_KEY_CHECKING: "false"
script:
- python3 -m pip install ansible==6.0.0
- make destroy
when: manual
<<: *ssh_key_template