Skip to content

Commit 1ce69d1

Browse files
committed
ci: move linux builds and tests to a container
Referenced issue: * status-im/infra-ci#188
1 parent cad3569 commit 1ce69d1

10 files changed

+531
-7
lines changed

_assets/ci/Jenkinsfile.android

Lines changed: 0 additions & 1 deletion
This file was deleted.

_assets/ci/Jenkinsfile.android

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env groovy
2+
library 'status-jenkins-lib@v1.9.26'
3+
4+
pipeline {
5+
agent {
6+
dockerfile {
7+
label 'linuxcontainer'
8+
filename 'linux.Dockerfile'
9+
dir '_assets/ci/'
10+
args '--volume=/nix:/nix ' +
11+
'--volume=/etc/nix:/etc/nix '
12+
}
13+
}
14+
15+
parameters {
16+
string(
17+
name: 'BRANCH',
18+
defaultValue: 'develop',
19+
description: 'Name of branch to build.'
20+
)
21+
booleanParam(
22+
name: 'RELEASE',
23+
defaultValue: false,
24+
description: 'Enable to create build for release.',
25+
)
26+
}
27+
28+
options {
29+
timestamps()
30+
ansiColor('xterm')
31+
/* Prevent Jenkins jobs from running forever */
32+
timeout(time: 15, unit: 'MINUTES')
33+
disableConcurrentBuilds()
34+
disableRestartFromStage()
35+
/* manage how many builds we keep */
36+
buildDiscarder(logRotator(
37+
numToKeepStr: '5',
38+
daysToKeepStr: '30',
39+
artifactNumToKeepStr: '1',
40+
))
41+
}
42+
43+
environment {
44+
PLATFORM = "android"
45+
EXT = "so"
46+
TMPDIR = "${WORKSPACE_TMP}"
47+
GOPATH = "${WORKSPACE_TMP}/go"
48+
GOCACHE = "${WORKSPACE_TMP}/gocache"
49+
PATH = "${PATH}:${GOPATH}/bin"
50+
REPO_SRC = "${GOPATH}/src/github.com/status-im/status-go"
51+
VERSION = sh(script: "./_assets/scripts/version.sh", returnStdout: true)
52+
ARTIFACT = utils.pkgFilename(
53+
name: 'status-go',
54+
type: env.PLATFORM,
55+
version: env.VERSION,
56+
ext: env.EXT
57+
)
58+
/* prevent sharing cache dir across different jobs */
59+
GO_GENERATE_FAST_DIR = "${env.WORKSPACE_TMP}/go-generate-fast"
60+
}
61+
62+
stages {
63+
stage('Setup') {
64+
steps { /* Go needs to find status-go in GOPATH. */
65+
sh "mkdir -p \$(dirname ${REPO_SRC})"
66+
sh "ln -s ${WORKSPACE} ${REPO_SRC}"
67+
}
68+
}
69+
70+
stage('Compile') {
71+
steps { script {
72+
nix.develop("make statusgo-${env.PLATFORM}-library", pure: false, sandbox: true)
73+
sh "mv build/bin/libstatus.${env.EXT} ${ARTIFACT}"
74+
} }
75+
}
76+
77+
stage('Archive') {
78+
steps { script {
79+
archiveArtifacts(ARTIFACT)
80+
} }
81+
}
82+
83+
stage('Upload') {
84+
steps { script {
85+
env.PKG_URL = s5cmd.upload(ARTIFACT)
86+
} }
87+
}
88+
} // stages
89+
post {
90+
success { script { github.notifyPR(true) } }
91+
failure { script { github.notifyPR(false) } }
92+
cleanup {
93+
cleanWs()
94+
dir("${env.WORKSPACE}@tmp") { deleteDir() }
95+
}
96+
} // post
97+
} // pipeline

_assets/ci/Jenkinsfile.linux

Lines changed: 0 additions & 1 deletion
This file was deleted.

_assets/ci/Jenkinsfile.linux

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/usr/bin/env groovy
2+
// vim: ft=groovy
3+
library 'status-jenkins-lib@v1.9.26'
4+
5+
pipeline {
6+
agent {
7+
dockerfile {
8+
label 'linuxcontainer'
9+
filename 'linux.Dockerfile'
10+
dir '_assets/ci/'
11+
args '--volume=/nix:/nix ' +
12+
'--volume=/etc/nix:/etc/nix '
13+
}
14+
}
15+
16+
parameters {
17+
string(
18+
name: 'BRANCH',
19+
defaultValue: 'develop',
20+
description: 'Name of branch to build.'
21+
)
22+
booleanParam(
23+
name: 'RELEASE',
24+
defaultValue: false,
25+
description: 'Enable to create build for release.',
26+
)
27+
booleanParam(
28+
name: 'USE_NWAKU',
29+
description: 'Whether to build with nwaku or not',
30+
defaultValue: params.USE_NWAKU ?: getNWakuMode(),
31+
)
32+
}
33+
34+
options {
35+
timestamps()
36+
ansiColor('xterm')
37+
/* Prevent Jenkins jobs from running forever */
38+
timeout(time: 30, unit: 'MINUTES')
39+
disableConcurrentBuilds()
40+
disableRestartFromStage()
41+
/* manage how many builds we keep */
42+
buildDiscarder(logRotator(
43+
numToKeepStr: '5',
44+
daysToKeepStr: '30',
45+
artifactNumToKeepStr: '1',
46+
))
47+
}
48+
49+
environment {
50+
PLATFORM = "linux/${params.USE_NWAKU ? 'nwaku' : 'status-go'}"
51+
TMPDIR = "${WORKSPACE_TMP}"
52+
GOPATH = "${WORKSPACE_TMP}/go"
53+
GOCACHE = "${WORKSPACE_TMP}/gocache"
54+
PATH = "${PATH}:${GOPATH}/bin:/c/Users/jenkins/go/bin"
55+
REPO_SRC = "${GOPATH}/src/github.com/status-im/status-go"
56+
VERSION = sh(script: "./_assets/scripts/version.sh", returnStdout: true)
57+
ARTIFACT = utils.pkgFilename(
58+
name: 'status-go',
59+
type: env.PLATFORM,
60+
version: env.VERSION,
61+
ext: 'zip',
62+
)
63+
/* prevent sharing cache dir across different jobs */
64+
GO_GENERATE_FAST_DIR = "${env.WORKSPACE_TMP}/go-generate-fast"
65+
/* Ensure env var is set on first run. */
66+
USE_NWAKU = "${params.USE_NWAKU}"
67+
68+
/* fixes nim cache collision */
69+
XDG_CACHE_HOME = "${env.WORKSPACE_TMP}/.cache"
70+
}
71+
72+
stages {
73+
stage('Setup') {
74+
steps {
75+
script {
76+
if (!env.PLATFORM.startsWith('windows')) {
77+
sh "mkdir -p \$(dirname ${REPO_SRC})"
78+
sh "ln -s ${WORKSPACE} ${REPO_SRC}"
79+
}
80+
}
81+
}
82+
}
83+
84+
stage('Deps') {
85+
steps { script {
86+
nix.develop('make status-go-deps', pure: false)
87+
}
88+
}
89+
}
90+
91+
stage('Generate') {
92+
steps { script {
93+
nix.develop('make generate', pure: false)
94+
}
95+
}
96+
}
97+
98+
stage('Build Static Lib') {
99+
steps {
100+
script {
101+
nix.develop('make statusgo-library', pure: false)
102+
}
103+
}
104+
}
105+
106+
stage('Build Shared Lib') {
107+
steps {
108+
script {
109+
nix.develop('make statusgo-shared-library', pure: false)
110+
}
111+
}
112+
}
113+
114+
stage('Archive') {
115+
steps {
116+
zip zipFile: "${ARTIFACT}", archive: true, dir: 'build/bin'
117+
}
118+
}
119+
120+
stage('Upload') {
121+
steps {
122+
script {
123+
env.PKG_URL = s5cmd.upload(ARTIFACT)
124+
}
125+
}
126+
}
127+
} // stages
128+
post {
129+
success { script { github.notifyPR(true) } }
130+
failure { script { github.notifyPR(false) } }
131+
cleanup {
132+
cleanWs()
133+
dir("${env.WORKSPACE}@tmp") { deleteDir() }
134+
}
135+
} // post
136+
} // pipeline
137+
138+
/* We extract the name of the job from currentThread because
139+
* before an agent is picked env is not available. */
140+
def getJobPathTokens() {
141+
return Thread.currentThread().getName().split('/')
142+
}
143+
144+
def getNWakuMode() {
145+
return getJobPathTokens().contains('nwaku')
146+
}

_assets/ci/Jenkinsfile.linux-nix

Lines changed: 0 additions & 1 deletion
This file was deleted.

_assets/ci/Jenkinsfile.linux-nix

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env groovy
2+
// vim: ft=groovy
3+
library 'status-jenkins-lib@v1.9.26'
4+
5+
pipeline {
6+
agent {
7+
dockerfile {
8+
label 'linuxcontainer'
9+
filename 'linux.Dockerfile'
10+
dir '_assets/ci/'
11+
args '--volume=/nix:/nix ' +
12+
'--volume=/etc/nix:/etc/nix '
13+
}
14+
}
15+
16+
options {
17+
disableConcurrentBuilds()
18+
disableRestartFromStage()
19+
/* manage how many builds we keep */
20+
buildDiscarder(logRotator(
21+
numToKeepStr: '20',
22+
daysToKeepStr: '30',
23+
))
24+
}
25+
26+
stages {
27+
stage('Build library') {
28+
steps {
29+
script {
30+
nix.flake("status-go-library")
31+
}
32+
}
33+
}
34+
}
35+
36+
post {
37+
cleanup { cleanWs() }
38+
}
39+
}

_assets/ci/Jenkinsfile.nwaku

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)