forked from intel/nemu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
150 lines (147 loc) · 5.39 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
stage ("Builds") {
parallel ('xenial': {
if (!env.BRANCH_NAME.contains("experiment/automatic-removal")) {
node ('xenial') {
stage ('Checkout: x86-64') {
checkout scm
}
stage ('Prepare: x86-64') {
sh "sudo apt-get update"
sh "sudo apt-get build-dep -y qemu"
}
stage ('Compile: x86-64') {
sh "SRCDIR=$WORKSPACE tools/build_x86_64.sh"
}
stage ('NATS: x86-64') {
sh "SRCDIR=$WORKSPACE tools/CI/run_nats.sh"
}
}
}
}, 'xenial-arm': {
node ('xenial-arm') {
stage ('Checkout: aarch64') {
checkout scm
}
stage ('Used files: aarch64') {
if (env.BRANCH_NAME.contains("topic/virt-x86")) {
sh "SRCDIR=$WORKSPACE $WORKSPACE/tools/used_files.sh $WORKSPACE/tools/build_aarch64.sh > $WORKSPACE/used-aarch64.txt"
azureUpload storageCredentialId: 'nemu-jenkins-storage-account',
filesPath: 'used-aarch64.txt',
storageType: 'blobstorage',
containerName: env.BUILD_TAG.replaceAll("%2F","-")
}
}
stage ('Compile: aarch64') {
sh "SRCDIR=$WORKSPACE tools/build_aarch64.sh"
}
stage ('NATS: aarch64') {
sh "SRCDIR=$WORKSPACE tools/CI/run_nats_aarch64.sh"
}
stage ('Upload binary: aarch64') {
if (env.BRANCH_NAME.contains("releases/candidate")) {
sh "cp $HOME/build-aarch64/aarch64-softmmu/qemu-system-aarch64 ."
azureUpload storageCredentialId: 'nemu-jenkins-storage-account',
filesPath: "qemu-system-aarch64",
storageType: 'blobstorage',
containerName: env.BUILD_TAG.replaceAll("%2F","-")
}
}
}
}, 'xenial-virt': {
node ('xenial') {
stage ('Checkout: x86-64 (virt only)') {
checkout scm
}
stage ('Prepare: x86-64 (virt only)') {
sh "sudo apt-get update"
sh "sudo apt-get build-dep -y qemu"
}
stage ('Used files: x86-64 (virt only)') {
if (env.BRANCH_NAME.contains("topic/virt-x86")) {
sh "SRCDIR=$WORKSPACE $WORKSPACE/tools/used_files.sh $WORKSPACE/tools/build_x86_64_virt.sh > $WORKSPACE/used-x86-64.txt"
azureUpload storageCredentialId: 'nemu-jenkins-storage-account',
filesPath: 'used-x86-64.txt',
storageType: 'blobstorage',
containerName: env.BUILD_TAG.replaceAll("%2F","-")
}
}
stage ('Compile: x86-64 (virt only)') {
sh "SRCDIR=$WORKSPACE tools/build_x86_64_virt.sh"
}
stage ('NATS: x86-64 (virt only)') {
sh "SRCDIR=$WORKSPACE tools/CI/run_nats.sh -run '.*/.*/virt/.*' -args -nemu-binary-path=$HOME/build-x86_64_virt/x86_64_virt-softmmu/qemu-system-x86_64_virt"
}
stage ('Upload binary: x86-64 (virt only)') {
if (env.BRANCH_NAME.contains("releases/candidate")) {
sh "cp $HOME/build-x86_64_virt/x86_64_virt-softmmu/qemu-system-x86_64_virt ."
azureUpload storageCredentialId: 'nemu-jenkins-storage-account',
filesPath: "qemu-system-x86_64_virt",
storageType: 'blobstorage',
containerName: env.BUILD_TAG.replaceAll("%2F","-")
}
}
}
})
}
stage ("Analyse") {
if (env.BRANCH_NAME.contains("topic/virt-x86")) {
node ('master'){
stage ('Checkout: analyse') {
checkout scm
}
stage ('Download results') {
azureDownload storageCredentialId: 'nemu-jenkins-storage-account',
downloadType: 'container',
containerName: env.BUILD_TAG.replaceAll("%2F","-")
}
stage ('Remove unused files') {
sh "cat $WORKSPACE/used-aarch64.txt $WORKSPACE/used-x86-64.txt | sort | uniq > $WORKSPACE/used-c-files.txt"
sh "find . | grep \\\\.[ch]\$ | sed 's#^./##' | sort | uniq > $WORKSPACE/all-c-files.txt"
sh "comm -23 $WORKSPACE/all-c-files.txt $WORKSPACE/used-c-files.txt | tee $WORKSPACE/unused-files.txt"
sh "git branch -D tmp-branch || true"
sh "git checkout -b tmp-branch"
sh 'cat $WORKSPACE/unused-files.txt | grep -v ^linux-headers | xargs -I {} -n 1 sh -c "git rm {} || true"'
sh 'git commit -m "TEMPORARY MESSAGE" -a'
writeFile file:'commit-message', text:"Automatic code removal\n\n"
sh "tools/cloc-change.sh `git rev-parse remotes/origin/${env.BRANCH_NAME}` >> $WORKSPACE/commit-message"
sh 'git commit --amend --file $WORKSPACE/commit-message'
writeFile file:'git-helper.sh', text:"#!/bin/bash\necho username=\$GIT_USERNAME\necho password=\$GIT_PASSWORD"
sh "chmod +x $WORKSPACE/git-helper.sh"
sh 'git config credential.helper "/bin/bash ' + env.WORKSPACE + '/git-helper.sh"'
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'a27947d5-1706-465f-99f7-231eff68787b',
usernameVariable: 'GIT_USERNAME',
passwordVariable: 'GIT_PASSWORD'
]]) {
String branch_suffix = env.BRANCH_NAME.replaceAll("topic/virt-x86","")
sh "git push origin -f tmp-branch:experiment/automatic-removal${branch_suffix}"
}
}
}
}
}
stage ("Release") {
if (env.BRANCH_NAME.contains("releases/candidate")) {
node ('master'){
stage ('Checkout: analyse') {
checkout scm
}
stage ('Download results') {
azureDownload storageCredentialId: 'nemu-jenkins-storage-account',
downloadType: 'container',
containerName: env.BUILD_TAG.replaceAll("%2F","-")
}
stage ('Create release') {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'a27947d5-1706-465f-99f7-231eff68787b',
usernameVariable: 'GITHUB_USERNAME',
passwordVariable: 'GITHUB_PASSWORD'
]]) {
sh "hub release create -m \"Release \$(date +%Y-%m-%d)\" -a qemu-system-x86_64_virt -a qemu-system-aarch64 release-`date +%Y-%m-%d`"
}
}
}
}
}