-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
168 lines (168 loc) · 7.64 KB
/
Jenkinsfile
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
pipeline {
agent none
stages {
stage('Build') {
parallel {
stage('UI') {
stages {
stage('Build UI') {
agent {
kubernetes {
yamlFile 'jenkins-worker-dind.yml'
}
}
options {
timeout(time: 10, unit: 'MINUTES')
}
steps {
container('dind') {
withDockerRegistry(credentialsId: 'gcr:flipperkid-default', url: 'https://gcr.io/flipperkid-default') {
sh "docker build -f ui/Dockerfile -t gcr.io/flipperkid-default/antfarm-ui:${env.BUILD_TAG} ui"
sh "docker push gcr.io/flipperkid-default/antfarm-ui:${env.BUILD_TAG}"
}
}
}
}
stage('Test UI') {
agent {
kubernetes {
yamlFile 'jenkins-worker-ui.yml'
}
}
options {
timeout(time: 10, unit: 'MINUTES')
}
steps {
container('jenkins-worker-ui') {
dir('ui/js') {
sh 'yarn install --pure-lockfile'
sh 'yarn jest'
}
}
}
}
}
}
stage('Server') {
stages {
stage('Build Server') {
agent {
kubernetes {
yamlFile 'jenkins-worker-dind.yml'
}
}
options {
timeout(time: 10, unit: 'MINUTES')
}
steps {
container('dind') {
withDockerRegistry(credentialsId: 'gcr:flipperkid-default', url: 'https://gcr.io/flipperkid-default') {
sh "docker build -f server/Dockerfile -t gcr.io/flipperkid-default/antfarm-server:${env.BUILD_TAG} server"
sh "docker push gcr.io/flipperkid-default/antfarm-server:${env.BUILD_TAG}"
}
}
}
}
stage('Test Server') {
agent {
kubernetes {
yamlFile 'jenkins-worker-python.yml'
}
}
options {
timeout(time: 10, unit: 'MINUTES')
}
steps {
container('jenkins-worker-python') {
dir('server') {
sh 'pip install --no-cache-dir -r requirements.txt'
sh 'flake8 antfarm/training'
sh 'pylint -j 0 --load-plugins pylint_django antfarm'
// TODO (jordan) requires a running DB
// sh 'python manage.py test antfarm.training'
}
}
}
}
}
}
stage('Learning') {
stages {
stage('Build Learning') {
agent {
kubernetes {
yamlFile 'jenkins-worker-dind.yml'
}
}
options {
timeout(time: 10, unit: 'MINUTES')
}
steps {
container('dind') {
withDockerRegistry(credentialsId: 'gcr:flipperkid-default', url: 'https://gcr.io/flipperkid-default') {
sh "docker build -f learning/Dockerfile -t gcr.io/flipperkid-default/antfarm-learning:${env.BUILD_TAG} learning"
sh "docker push gcr.io/flipperkid-default/antfarm-learning:${env.BUILD_TAG}"
}
}
}
}
stage('Test Learning') {
agent {
kubernetes {
yaml """
spec:
containers:
- name: jenkins-worker-learning
image: gcr.io/flipperkid-default/antfarm-learning:${env.BUILD_TAG}
command:
- cat
tty: true
resources:
requests:
cpu: "150m"
"""
}
}
options {
timeout(time: 10, unit: 'MINUTES')
}
steps {
container('jenkins-worker-learning') {
dir('learning') {
sh 'flake8 environments examples' // TODO (jordan) include "runners"
sh 'pylint -j 0 --extension-pkg-whitelist=numpy environments' // TODO (jordan) include "runners"
sh 'pytest --durations=0 runners'
}
}
}
}
}
}
}
}
stage('System Test') {
agent {
kubernetes {
yaml """
spec:
containers:
- name: jenkins-worker-antfarm
image: gcr.io/flipperkid-default/antfarm-ui:${env.BUILD_TAG}
resources:
requests:
cpu: "150m"
"""
}
}
options {
timeout(time: 3, unit: 'MINUTES')
skipDefaultCheckout()
}
steps {
container('jenkins-worker-antfarm') {
sh 'curl http://127.0.0.1/static/index.html'
}
}
}
}
}