forked from MooreThreads/torch_musa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
119 lines (111 loc) · 3.95 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
class PodTemplateFiles {
private Map files = [
'MThreads GPU': 'ci/templates/musa.yaml',
]
public String getPodTemplateFile(String platform) {
String file = files.get(platform)
return file
}
}
def ifTriggeredByTimer() {
return currentBuild.getBuildCauses()[0].shortDescription == 'Started by timer'
}
pipeline {
parameters {
choice(name: 'HARDWARE_PLATFORM', choices: ['MThreads GPU'], description: 'Target hardware platform')
}
agent {
kubernetes {
yamlFile "${new PodTemplateFiles().getPodTemplateFile(params.HARDWARE_PLATFORM)}"
defaultContainer "main"
}
}
triggers {
// UTC
cron(env.BRANCH_NAME == 'main' ? '0 18 * * *' : '')
}
stages {
stage('Lint') {
parallel {
stage('Python Lint') {
steps {
container('main') {
sh 'git config --global --add safe.directory \"*\"'
sh '/opt/conda/condabin/conda run -n py38 --no-capture-output /bin/bash tools/lint/pylint.sh'
}
}
}
stage('C++ Lint') {
steps {
container('main') {
sh 'git config --global --add safe.directory \"*\"'
sh '/opt/conda/condabin/conda run -n py38 --no-capture-output /bin/bash tools/lint/git-clang-format.sh --rev origin/${CHANGE_TARGET}'
}
}
}
}
}
stage('Build') {
steps {
container('main') {
sh '/bin/bash --login scripts/update_daily_mudnn.sh'
sh '/bin/bash --login -c "conda run -n py38 --no-capture-output /bin/bash build.sh"'
}
}
}
stage('Unit Test') {
steps {
container('main') {
sh '/bin/bash --login scripts/run_unittest.sh'
}
}
}
stage('Integration Test') {
steps {
container('main') {
sh '/bin/bash --login scripts/run_integration_test.sh'
}
}
}
stage('Daily Release') {
agent {
kubernetes {
yamlFile 'ci/templates/musa.yaml'
defaultContainer "main"
}
}
when {
beforeAgent true
allOf {
branch 'main'
expression { ifTriggeredByTimer() }
}
}
steps {
container('main') {
sh '/bin/bash --login scripts/update_daily_mudnn.sh'
// Build wheel packages under python3.8, using the existing conda environment
sh '/bin/bash --login -c "/opt/conda/condabin/conda run -n py38 --no-capture-output USE_STATIC_MKL=1 /bin/bash scripts/build_wheel.sh"'
// Copy built wheel packages to shared directory "/artifacts"
sh 'cp dist/*.whl /artifacts/ && cp ${PYTORCH_REPO_PATH}/dist/*.whl /artifacts/'
// Build wheel packages under python3.9, create a new conda environment
sh '/bin/bash --login -c "/opt/conda/condabin/conda env create -f docker/common/conda-env-torch_musa-py39.yaml" && \
/opt/conda/condabin/conda run -n py39 --no-capture-output pip install -r docker/common/requirements-py39.txt -i \
https://pypi.tuna.tsinghua.edu.cn/simple'
sh '/bin/bash --login -c "/opt/conda/condabin/conda run -n py39 --no-capture-output USE_STATIC_MKL=1 /bin/bash scripts/build_wheel.sh"'
sh 'cp dist/*.whl /artifacts/ && cp ${PYTORCH_REPO_PATH}/dist/*.whl /artifacts/'
// Add some description
sh 'echo "commit id: "$(git rev-parse HEAD) > /artifacts/README.txt'
sh 'echo "dependencies: " >> /artifacts/README.txt && \
DAILY_MUDNN_REL_DIR=$(find ./ -name "daily_mudnn*" | awk -F/ \'NR==1{print $NF}\') && \
echo "daily_mudnn:"$(find ${DAILY_MUDNN_REL_DIR} -name "*.txt" | awk -F/ \'{print $NF}\' | awk -F_ \'{print $1}\') >> /artifacts/README.txt && \
cat .musa_dependencies >> /artifacts/README.txt'
}
container('release') {
// Publish new release to oss (minio)
sh 'oss-release /artifacts/'
}
}
}
}
}