-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathJenkinsfile
More file actions
147 lines (145 loc) · 6.29 KB
/
Jenkinsfile
File metadata and controls
147 lines (145 loc) · 6.29 KB
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
@Library('jenkins-library')
String agentLabel = 'docker-build-agent-docker-20'
String registry = 'docker.soramitsu.co.jp'
String dockerBuildToolsUserId = 'bot-build-tools-ro'
String dockerRegistryRWUserId = 'bot-sora2-rw'
String cargoAuditImage = registry + '/build-tools/cargo_audit'
String envImageName = registry + '/sora2/env:sub4'
String rustcVersion = 'nightly-2021-12-10'
String wasmReportFile = 'subwasm_report.json'
String appImageName = 'docker.soramitsu.co.jp/sora2/substrate'
String secretScannerExclusion = '.*Cargo.toml'
Boolean disableSecretScanner = false
String featureList = 'private-net include-real-files reduced-pswap-reward-periods enable-beefy'
Map pushTags = ['master': 'latest', 'develop': 'dev','trustless-evm-bridge': 'bridge']
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '20'))
timestamps()
disableConcurrentBuilds()
}
agent {
label agentLabel
}
stages {
stage('Secret scanner') {
steps {
script {
gitNotify('main-CI', 'PENDING', 'This commit is being built')
docker.withRegistry('https://' + registry, dockerBuildToolsUserId) {
secretScanner(disableSecretScanner, secretScannerExclusion)
}
}
}
}
stage('Audit') {
steps {
script {
docker.withRegistry( 'https://' + registry, dockerBuildToolsUserId) {
docker.image(cargoAuditImage + ':latest').inside(){
sh '''
cargo audit > cargoAuditReport.txt || exit 0
'''
archiveArtifacts artifacts: "cargoAuditReport.txt"
}
}
}
}
}
stage('Build & Tests') {
environment {
PACKAGE = 'framenode-runtime'
RUSTFLAGS = '-Dwarnings'
RUNTIME_DIR = 'runtime'
RUSTC_VERSION = "${rustcVersion}"
}
steps {
script {
docker.withRegistry('https://' + registry, dockerRegistryRWUserId) {
if (getPushVersion(pushTags)) {
docker.image(envImageName).inside() {
if (env.TAG_NAME =~ 'benchmarking.*') {
featureList = 'runtime-benchmarks main-net-coded'
}
else if (env.TAG_NAME =~ 'stage.*') {
featureList = 'private-net include-real-files'
}
else if (env.TAG_NAME =~ 'test.*') {
featureList = 'private-net include-real-files reduced-pswap-reward-periods'
}
else if (env.TAG_NAME) {
featureList = 'include-real-files'
}
sh """
cargo test --release --features runtime-benchmarks
cargo build --release --features \"${featureList}\"
mv ./target/release/framenode .
mv ./target/release/relayer ./relayer.bin
wasm-opt -Os -o ./framenode_runtime.compact.wasm ./target/release/wbuild/framenode-runtime/framenode_runtime.compact.wasm
subwasm --json info framenode_runtime.compact.wasm > ${wasmReportFile}
"""
archiveArtifacts artifacts:
"framenode_runtime.compact.wasm, ${wasmReportFile}"
}
} else {
docker.image(envImageName).inside() {
sh '''
cargo fmt -- --check > /dev/null
cargo test
cargo test --features private-net
cargo test --features runtime-benchmarks
'''
}
}
}
}
}
}
stage('Code Coverage') {
when {
expression { getPushVersion(pushTags) }
}
steps {
script {
docker.withRegistry('https://' + registry, dockerRegistryRWUserId) {
docker.image(envImageName).inside() {
sh './housekeeping/coverage.sh'
cobertura coberturaReportFile: 'cobertura_report'
}
}
}
}
}
stage('Push Image') {
when {
expression { getPushVersion(pushTags) }
}
steps {
script {
sh "docker build -f housekeeping/docker/release/Dockerfile -t ${appImageName} ."
baseImageTag = "${getPushVersion(pushTags)}"
docker.withRegistry('https://' + registry, dockerRegistryRWUserId) {
sh """
docker tag ${appImageName} ${appImageName}:${baseImageTag}
docker push ${appImageName}:${baseImageTag}
"""
}
docker.withRegistry('https://index.docker.io/v1/', 'docker-hub-credentials') {
sh """
docker tag ${appImageName} sora2/substrate:${baseImageTag}
docker push sora2/substrate:${baseImageTag}
"""
}
}
}
}
}
post {
always {
script{
gitNotify('main-CI', currentBuild.result, currentBuild.result)
}
}
cleanup { cleanWs() }
}
}