2023-06-29 13:40:43 +00:00
|
|
|
#!/usr/bin/env groovy
|
2024-09-13 03:06:38 +00:00
|
|
|
library 'status-jenkins-lib@v1.9.10'
|
2020-03-06 15:43:04 +00:00
|
|
|
|
2019-02-28 10:56:58 +00:00
|
|
|
pipeline {
|
2019-04-18 12:39:40 +00:00
|
|
|
agent { label params.AGENT_LABEL }
|
2019-02-28 10:56:58 +00:00
|
|
|
|
2021-06-24 12:02:20 +00:00
|
|
|
parameters {
|
|
|
|
string(
|
|
|
|
name: 'NIX_CACHE_HOST',
|
|
|
|
description: 'FQDN of Nix binary cache host.',
|
|
|
|
defaultValue: params.NIX_CACHE_HOST ?: 'cache-01.do-ams3.nix.ci.statusim.net'
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'NIX_CACHE_USER',
|
|
|
|
description: 'Username for Nix binary cache host.',
|
|
|
|
defaultValue: params.NIX_CACHE_USER ?: 'nix-cache'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-02-28 10:56:58 +00:00
|
|
|
environment {
|
|
|
|
/* we source .bash_profile to be able to use nix-store */
|
2024-01-04 09:57:05 +00:00
|
|
|
NIX_SSHOPTS = "-oStrictHostKeyChecking=no"
|
2019-04-03 11:06:42 +00:00
|
|
|
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
|
2024-01-04 09:57:05 +00:00
|
|
|
NIX_STORE_CMD = '/nix/var/nix/profiles/default/bin/nix-store'
|
|
|
|
NIX_SSH_REMOTE = "ssh://${params.NIX_CACHE_USER}@${params.NIX_CACHE_HOST}?remote-program=${env.NIX_STORE_CMD}"
|
2019-02-28 10:56:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
timestamps()
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
/* Prevent Jenkins jobs from running forever */
|
2023-06-15 07:39:28 +00:00
|
|
|
timeout(time: 120, unit: 'MINUTES')
|
2019-02-28 10:56:58 +00:00
|
|
|
/* Limit builds retained */
|
|
|
|
buildDiscarder(logRotator(
|
|
|
|
numToKeepStr: '20',
|
|
|
|
daysToKeepStr: '30',
|
2024-02-28 14:50:47 +00:00
|
|
|
artifactNumToKeepStr: '1',
|
2019-02-28 10:56:58 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Setup') {
|
2019-07-15 16:34:33 +00:00
|
|
|
steps { script {
|
2021-04-12 14:07:55 +00:00
|
|
|
nix.shell('nix-env -i openssh', sandbox: false, pure: false)
|
2019-11-29 10:20:08 +00:00
|
|
|
/* some build targets don't build on MacOS */
|
2024-01-04 09:57:05 +00:00
|
|
|
os = sh(script: 'uname', returnStdout: true).trim()
|
|
|
|
arch = sh(script: 'arch', returnStdout: true).trim()
|
2019-07-15 16:34:33 +00:00
|
|
|
} }
|
2019-02-28 10:56:58 +00:00
|
|
|
}
|
2019-07-22 03:31:47 +00:00
|
|
|
stage('Build status-go') {
|
|
|
|
steps { script {
|
2023-06-15 07:39:28 +00:00
|
|
|
def platforms = ['mobile.android', 'mobile.ios', 'library']
|
|
|
|
if (os != 'Darwin') { platforms.removeAll { it == 'mobile.ios' } }
|
2024-01-04 09:57:05 +00:00
|
|
|
/* FIXME: "'x86_64-darwin' with features {} is required to build" */
|
2023-06-15 07:39:28 +00:00
|
|
|
if (arch == 'arm64') { platforms.removeAll { it == 'mobile.android' } }
|
2024-01-04 09:57:05 +00:00
|
|
|
platforms.each { platform ->
|
|
|
|
/* Allow for Android builds on Apple ARM. */
|
|
|
|
env.NIXPKGS_SYSTEM_OVERRIDE = nixSysOverride(os, arch, platform)
|
2019-07-15 16:34:33 +00:00
|
|
|
nix.build(
|
2024-01-04 09:57:05 +00:00
|
|
|
attr: "targets.status-go.${platform}",
|
2020-02-29 10:40:11 +00:00
|
|
|
sandbox: false,
|
2019-07-15 16:34:33 +00:00
|
|
|
link: false
|
|
|
|
)
|
2019-07-22 03:31:47 +00:00
|
|
|
}
|
|
|
|
} }
|
|
|
|
}
|
2019-07-26 14:51:06 +00:00
|
|
|
stage('Build android jsbundle') {
|
2019-07-15 16:34:33 +00:00
|
|
|
steps { script {
|
2023-05-30 15:05:10 +00:00
|
|
|
/* Build/fetch deps required for jsbundle build. */
|
2019-07-15 16:34:33 +00:00
|
|
|
nix.build(
|
2023-05-30 15:05:10 +00:00
|
|
|
attr: 'targets.mobile.jsbundle',
|
2020-02-29 10:40:11 +00:00
|
|
|
sandbox: false,
|
2019-07-15 16:34:33 +00:00
|
|
|
pure: false,
|
|
|
|
link: false
|
|
|
|
)
|
|
|
|
} }
|
|
|
|
}
|
|
|
|
stage('Build android deps') {
|
|
|
|
steps { script {
|
2024-01-04 09:57:05 +00:00
|
|
|
/* Allow for Android builds on Apple ARM. */
|
|
|
|
env.NIXPKGS_SYSTEM_OVERRIDE = nixSysOverride(os, arch, 'android')
|
2023-05-30 15:05:10 +00:00
|
|
|
/* Build/fetch deps required to build android release. */
|
2019-07-15 16:34:33 +00:00
|
|
|
nix.build(
|
2024-02-15 08:18:11 +00:00
|
|
|
attr: 'targets.mobile.android.build.buildInputs',
|
2020-02-29 10:40:11 +00:00
|
|
|
sandbox: false,
|
2019-07-15 16:34:33 +00:00
|
|
|
pure: false,
|
|
|
|
link: false
|
|
|
|
)
|
|
|
|
} }
|
2019-06-04 16:50:29 +00:00
|
|
|
}
|
|
|
|
stage('Build nix shell deps') {
|
2019-07-15 16:34:33 +00:00
|
|
|
steps { script {
|
2023-06-15 07:39:28 +00:00
|
|
|
def shells = ['android', 'ios', 'fastlane', 'keytool', 'clojure', 'gradle']
|
2024-01-04 09:57:05 +00:00
|
|
|
if (os != 'Darwin') { shells.removeAll { it == 'ios' } }
|
|
|
|
/* FIXME: "'x86_64-darwin' with features {} is required to build" */
|
|
|
|
if (arch == 'arm64') { shells.removeAll { it == 'android' } }
|
2023-05-30 15:05:10 +00:00
|
|
|
/* Build/fetch deps required to start default Nix shell. */
|
2023-06-15 07:39:28 +00:00
|
|
|
shells.each { shell ->
|
2024-01-04 09:57:05 +00:00
|
|
|
/* Allow for Android builds on Apple ARM. */
|
|
|
|
env.NIXPKGS_SYSTEM_OVERRIDE = nixSysOverride(os, arch, shell)
|
2023-06-15 07:39:28 +00:00
|
|
|
nix.build(
|
|
|
|
attr: "shells.${shell}.buildInputs",
|
|
|
|
sandbox: false,
|
|
|
|
link: false
|
|
|
|
)
|
|
|
|
}
|
2019-07-15 16:34:33 +00:00
|
|
|
} }
|
2019-02-28 10:56:58 +00:00
|
|
|
}
|
|
|
|
stage('Upload') {
|
2019-07-15 16:34:33 +00:00
|
|
|
steps { script {
|
2019-02-28 10:56:58 +00:00
|
|
|
sshagent(credentials: ['nix-cache-ssh']) {
|
2019-07-15 16:34:33 +00:00
|
|
|
nix.shell("""
|
2019-07-26 14:51:06 +00:00
|
|
|
find /nix/store/ -mindepth 1 -maxdepth 1 -type d \
|
2022-07-17 12:37:46 +00:00
|
|
|
-not -name '*.links' -and -not -name '*-status-mobile-*' \
|
2024-01-04 09:57:05 +00:00
|
|
|
| xargs nix copy --to ${NIX_SSH_REMOTE}
|
2019-07-15 16:34:33 +00:00
|
|
|
""",
|
|
|
|
pure: false
|
|
|
|
)
|
2019-02-28 10:56:58 +00:00
|
|
|
}
|
2019-07-15 16:34:33 +00:00
|
|
|
} }
|
2019-02-28 10:56:58 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-04 16:50:29 +00:00
|
|
|
post {
|
2019-07-15 16:34:33 +00:00
|
|
|
always { script {
|
|
|
|
nix.shell('nix-store --optimize', pure: false)
|
|
|
|
} }
|
2019-06-04 16:50:29 +00:00
|
|
|
}
|
2019-02-28 10:56:58 +00:00
|
|
|
}
|
2024-01-04 09:57:05 +00:00
|
|
|
|
|
|
|
def nixSysOverride(os, arch, target='android') {
|
|
|
|
return (
|
|
|
|
os == 'Darwin' &&
|
|
|
|
arch == 'arm64' &&
|
|
|
|
target =~ /.*android$/
|
|
|
|
) ? 'x86_64-darwin' : ''
|
|
|
|
}
|