forked from xmos/ai_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
123 lines (119 loc) · 5.03 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
@Library('[email protected]') _
getApproval()
pipeline {
agent {
dockerfile {
args "-v /home/jenkins/.keras:/root/.keras -v /etc/passwd:/etc/passwd:ro"
}
}
environment {
BAZEL_CACHE_KEY_FILE = credentials('BAZEL_REMOTE_CACHE_JSON_KEY')
BAZEL_CACHE_URL = 'https://storage.googleapis.com/bazel_remote_cache_0/jenkins'
}
parameters { // Available to modify on the job page within Jenkins if starting a build
string( // use to try different tools versions
name: 'TOOLS_VERSION',
defaultValue: '15.0.6',
description: 'The tools version to build with (check /projects/tools/ReleasesTools/)'
)
booleanParam( // use to check results of rolling all conda deps forward
name: 'UPDATE_ALL',
defaultValue: false,
description: 'Update all conda packages before building'
)
}
options { // plenty of things could go here
timestamps()
// on develop discard builds after a certain number else keep forever
buildDiscarder(logRotator(
numToKeepStr: env.BRANCH_NAME ==~ /develop/ ? '100' : '',
artifactNumToKeepStr: env.BRANCH_NAME ==~ /develop/ ? '100' : ''
))
}
stages {
stage("Setup") {
// Clone and install build dependencies
steps {
// clean auto default checkout
sh "rm -rf *"
// clone
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption',
threads: 8,
timeout: 20,
shallow: true,
parentCredentials: true,
recursiveSubmodules: true],
[$class: 'CleanCheckout']],
userRemoteConfigs: [[credentialsId: 'xmos-bot',
url: '[email protected]:xmos/ai_tools']]
])
// create venv and install pip packages
sh "conda env create -q -p ai_tools_venv -f ./environment.yml"
sh """. activate ./ai_tools_venv &&
pip install -r requirements.txt
"""
// Install xmos tools version
sh "/XMOS/get_tools.py " + params.TOOLS_VERSION
}
}
stage("Update all packages") {
// Roll all conda packages forward beyond their pinned versions
when { expression { return params.UPDATE_ALL } }
steps {
sh "conda update --all -y -q -p ai_tools_venv"
}
}
stage("Build") {
steps {
// below is how we can activate the tools, NOTE: xTIMEcomposer -> XTC at tools 15.0.5 and later
// sh """. /XMOS/tools/${params.TOOLS_VERSION}/XMOS/XTC/${params.TOOLS_VERSION}/SetEnv && //
sh """. /XMOS/tools/${params.TOOLS_VERSION}/XMOS/XTC/${params.TOOLS_VERSION}/SetEnv &&
. activate ./ai_tools_venv &&
cd third_party/lib_tflite_micro &&
make build &&
cd ../.. &&
make clean &&
make build
"""
sh """. activate ./ai_tools_venv && cd experimental/xformer &&
bazel build --remote_cache=${BAZEL_CACHE_URL} --google_credentials=${BAZEL_CACHE_KEY_FILE} //:xcore-opt --verbose_failures
"""
sh """. activate ./ai_tools_venv &&
(cd python && python3 setup.py bdist_wheel) &&
pip install ./python/dist/* &&
pip install -r "./requirements.txt"
"""
}
}
stage("Test") {
steps {
// xformer2 unit tests
sh """. activate ./ai_tools_venv && cd experimental/xformer &&
bazel test --remote_cache=${BAZEL_CACHE_URL} --google_credentials=${BAZEL_CACHE_KEY_FILE} //Test:all --verbose_failures --test_output=errors
"""
// xformer2 integration tests
sh """. activate ./ai_tools_venv &&
make test
"""
// Any call to pytest can be given the "--junitxml SOMETHING_junit.xml" option
// This step collects these files for display in Jenkins UI
junit "**/*_junit.xml"
// regression test for xmos_ai_tools juypiter notebooks
sh """. activate ./ai_tools_venv &&
pip install ./python/
pip install pytest nbmake
pytest --nbmake ./docs/notebooks/*.ipynb
"""
}
}
}
post {
cleanup {
cleanWs()
}
}
}