forked from aionnetwork/aionr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
116 lines (105 loc) · 3.22 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
#!/usr/bin/env groovy
def message, lastCommit
@NonCPS
def getCommit(){
def changeLogSets = currentBuild.changeSets
def m = "";
for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
m = "${m}\n${entry.commitId} by ${entry.author} on ${new Date(entry.timestamp)}:\n\t${entry.msg}"
}
}
return m
}
pipeline {
agent any
triggers {
cron('H 23 * * *')
pollSCM('H/5 * * * *')
}
environment{
JAVA_ARGS="-Dorg.apache.commons.jelly.tags.fmt.timeZone=Asia/Shanghai"
JENKINS_JAVA_OPTIONS="-Dorg.apache.commons.jelly.tags.fmt.timeZone=Asia/Shanghai"
}
options {
timeout(time: 120, unit: 'MINUTES')
buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds()
}
stages {
stage('Format_Test') {
steps {
sh 'set -e'
echo "format testing..."
sh 'cargo +nightly fmt --all -- --check'
}
}
stage('Build'){
steps{
sh 'set -e'
echo "building..."
sh 'RUSTFLAGS="-D warnings" cargo build --release'
}
}
stage('Unit Test'){
steps{
sh 'ls test_results || mkdir test_results'
sh 'RUSTFLAGS="-D warnings" cargo +nightly test --all --no-run --release --exclude fastvm --exclude solidity'
script{
try{
sh '''#!/bin/bash
set -o pipefail
RUSTFLAGS="-D warnings" cargo +nightly test --all --release -- --nocapture --test-threads 1 2>&1 | tee test_results/ut_result.txt'''
sh 'echo $?'
lastCommit = sh(returnStdout: true, script: 'git rev-parse HEAD | cut -c 1-8')
echo "${lastCommit}"
sh "python scripts/bench.py -l test_results/ut_result.txt -r test_results/report.html -c ${lastCommit}"
}
catch(Exception e){
echo "${e}"
throw e
}
}
sh 'rm -rf $HOME/.aion/chains'
}
}
stage('RPC Test'){
steps{
sh 'set -e'
script{
try{
sh './scripts/run_RPCtest.sh'
sh 'echo $?'
}
catch(Exception e){
echo "${e}"
throw e
}
}
}
}
}
post{
always{
script {
//a GString like "${my_var}" and some class expects String. It can't be cast automatically.
//If you have some code like this, you have to convert it to String like this: "${my_var}".toString()
message = getCommit().toString();
}
}
success{
archiveArtifacts artifacts: 'target/release/aion,test_results/*.*',fingerprint:true
slackSend channel: '#ci',
color: 'good',
message: "${currentBuild.fullDisplayName} completed successfully. Grab the generated builds at ${env.BUILD_URL}\nArtifacts: ${env.BUILD_URL}artifact/\n Check BenchTest result: ${env.BUILD_URL}artifact/test_results/report.html \nCommit: ${GIT_COMMIT}\nChanges:${message}"
}
failure {
//cleanWs();
slackSend channel: '#ci',
color: 'danger',
message: "${currentBuild.fullDisplayName} failed at ${env.BUILD_URL}\nCommit: ${GIT_COMMIT}\nChanges:${message}"
}
}
}