-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
596d75a
commit 3e8b378
Showing
5 changed files
with
239 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Jenkinsfile.unix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Jenkinsfile.unix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#!/usr/bin/env groovy | ||
library 'status-jenkins-lib@v1.9.6' | ||
|
||
pipeline { | ||
/* This way we run the same Jenkinsfile on different platforms. */ | ||
agent { label "${params.AGENT_LABEL} && nix-2.19" } | ||
|
||
parameters { | ||
string( | ||
name: 'BRANCH', | ||
defaultValue: 'develop', | ||
description: 'Name of branch to build.' | ||
) | ||
string( | ||
name: 'AGENT_LABEL', | ||
description: 'Label for targetted CI slave host: linux/macos', | ||
defaultValue: params.AGENT_LABEL ?: getAgentLabel(), | ||
) | ||
booleanParam( | ||
name: 'RELEASE', | ||
defaultValue: false, | ||
description: 'Enable to create build for release.', | ||
) | ||
} | ||
|
||
options { | ||
timestamps() | ||
ansiColor('xterm') | ||
/* Prevent Jenkins jobs from running forever */ | ||
timeout(time: 10, unit: 'MINUTES') | ||
disableConcurrentBuilds() | ||
/* manage how many builds we keep */ | ||
buildDiscarder(logRotator( | ||
numToKeepStr: '5', | ||
daysToKeepStr: '30', | ||
artifactNumToKeepStr: '1', | ||
)) | ||
} | ||
|
||
environment { | ||
PLATFORM = getPlatformFromLabel(params.AGENT_LABEL) | ||
TMPDIR = "${WORKSPACE_TMP}" | ||
GOPATH = "${WORKSPACE_TMP}/go" | ||
GOCACHE = "${WORKSPACE_TMP}/gocache" | ||
PATH = "${PATH}:${GOPATH}/bin" | ||
REPO_SRC = "${GOPATH}/src/github.com/status-im/status-go" | ||
VERSION = sh(script: "./_assets/scripts/version.sh", returnStdout: true) | ||
ARTIFACT = utils.pkgFilename( | ||
name: 'status-go', | ||
type: env.PLATFORM, | ||
version: env.VERSION, | ||
ext: 'zip', | ||
) | ||
} | ||
|
||
stages { | ||
stage('Setup') { | ||
steps { /* Go needs to find status-go in GOPATH. */ | ||
sh "mkdir -p \$(dirname ${REPO_SRC})" | ||
sh "ln -s ${WORKSPACE} ${REPO_SRC}" | ||
} | ||
} | ||
|
||
/* Sanity-check C bindings */ | ||
stage('Build Static Lib') { | ||
steps { script { | ||
nix.shell('make statusgo-library', pure: false) | ||
} } | ||
} | ||
|
||
stage('Build Shared Lib') { | ||
steps { script { | ||
nix.shell('make statusgo-shared-library', pure: false) | ||
} } | ||
} | ||
|
||
stage('Archive') { | ||
steps { | ||
sh "zip -q -r ${ARTIFACT} build/bin" | ||
archiveArtifacts(ARTIFACT) | ||
} | ||
} | ||
|
||
stage('Upload') { | ||
steps { script { | ||
env.PKG_URL = s5cmd.upload(ARTIFACT) | ||
} } | ||
} | ||
} // stages | ||
post { | ||
success { script { github.notifyPR(true) } } | ||
failure { script { github.notifyPR(false) } } | ||
cleanup { sh 'make deep-clean' } | ||
} // post | ||
} // pipeline | ||
|
||
/* This allows us to use one Jenkinsfile and run | ||
* jobs on different platforms based on job name. */ | ||
def getAgentLabel() { | ||
if (params.AGENT_LABEL) { return params.AGENT_LABEL } | ||
/* We extract the name of the job from currentThread because | ||
* before an agent is picket env is not available. */ | ||
def tokens = Thread.currentThread().getName().split('/') | ||
def labels = [] | ||
/* Check if the job path contains any of the valid labels. */ | ||
['linux', 'macos', 'windows', 'x86_64', 'aarch64', 'arm64'].each { | ||
if (tokens.contains(it)) { labels.add(it) } | ||
} | ||
return labels.join(' && ') | ||
} | ||
|
||
/* This function extracts the platform from the AGENT_LABEL */ | ||
def getPlatformFromLabel(label) { | ||
if (label.contains('linux')) { | ||
return 'linux' | ||
} else if (label.contains('macos')) { | ||
return 'macos' | ||
} else if (label.contains('windows')) { | ||
return 'windows' | ||
} else { | ||
return 'unknown' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/usr/bin/env groovy | ||
library 'status-jenkins-lib@v1.9.6' | ||
|
||
pipeline { | ||
/* This way we run the same Jenkinsfile on different platforms. */ | ||
agent { label "${params.AGENT_LABEL}" } | ||
|
||
parameters { | ||
string( | ||
name: 'BRANCH', | ||
defaultValue: 'develop', | ||
description: 'Name of branch to build.' | ||
) | ||
string( | ||
name: 'AGENT_LABEL', | ||
description: 'Label for targetted CI slave host: windows', | ||
defaultValue: params.AGENT_LABEL ?: getAgentLabel(), | ||
) | ||
booleanParam( | ||
name: 'RELEASE', | ||
defaultValue: false, | ||
description: 'Enable to create build for release.', | ||
) | ||
} | ||
|
||
options { | ||
timestamps() | ||
ansiColor('xterm') | ||
/* Prevent Jenkins jobs from running forever */ | ||
timeout(time: 10, unit: 'MINUTES') | ||
disableConcurrentBuilds() | ||
/* manage how many builds we keep */ | ||
buildDiscarder(logRotator( | ||
numToKeepStr: '5', | ||
daysToKeepStr: '30', | ||
artifactNumToKeepStr: '1', | ||
)) | ||
} | ||
|
||
environment { | ||
PLATFORM = getPlatformFromLabel(params.AGENT_LABEL) | ||
VERSION = sh(script: "./_assets/scripts/version.sh", returnStdout: true) | ||
ARTIFACT = utils.pkgFilename( | ||
name: 'status-go', | ||
type: env.PLATFORM, | ||
version: env.VERSION, | ||
ext: 'zip', | ||
) | ||
} | ||
|
||
stages { | ||
stage('Build Static Lib') { | ||
steps { | ||
sh 'make statusgo-library SHELL=/bin/sh' | ||
} | ||
} | ||
|
||
stage('Build Shared Lib') { | ||
steps { | ||
sh 'make statusgo-shared-library SHELL=/bin/sh' | ||
} | ||
} | ||
|
||
stage('Archive') { | ||
steps { | ||
zip zipFile: "${ARTIFACT}", archive: true, dir: 'build/bin' | ||
} | ||
} | ||
|
||
stage('Upload') { | ||
steps { script { | ||
env.PKG_URL = s3.uploadArtifact(env.ARTIFACT) | ||
} } | ||
} | ||
} // stages | ||
post { | ||
success { script { github.notifyPR(true) } } | ||
failure { script { github.notifyPR(false) } } | ||
cleanup { cleanWs() } | ||
} // post | ||
} // pipeline | ||
|
||
/* This allows us to run jobs on different platforms based on job name. */ | ||
def getAgentLabel() { | ||
if (params.AGENT_LABEL) { return params.AGENT_LABEL } | ||
/* We extract the name of the job from currentThread because | ||
* before an agent is picket env is not available. */ | ||
def tokens = Thread.currentThread().getName().split('/') | ||
def labels = [] | ||
/* Check if the job path contains any of the valid labels. */ | ||
['linux', 'macos', 'windows', 'x86_64', 'aarch64', 'arm64'].each { | ||
if (tokens.contains(it)) { labels.add(it) } | ||
} | ||
return labels.join(' && ') | ||
} | ||
|
||
/* This function extracts the platform from the AGENT_LABEL */ | ||
def getPlatformFromLabel(label) { | ||
if (label.contains('linux')) { | ||
return 'linux' | ||
} else if (label.contains('macos')) { | ||
return 'macos' | ||
} else if (label.contains('windows')) { | ||
return 'windows' | ||
} else { | ||
return 'unknown' | ||
} | ||
} |