Files
status-app/ci/Jenkinsfile.linux-nix
2026-08-28 16:38:43 +03:00

216 lines
6.1 KiB
Groovy

#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.9.48'
/* Options section can't access functions in objects. */
def isPRBuild = utils.isPRBuild()
def isNightlyBuild = utils.isNightlyBuild()
pipeline {
agent {
docker {
label 'linuxcontainer'
image 'harbor.status.im/infra/ci-build-containers:linux-base-1.0.0'
args '--volume=/nix:/nix ' +
'--volume=/etc/nix:/etc/nix '
}
}
//agent {
// dockerfile {
// label 'linuxcontainer'
// filename 'tests.Dockerfile'
// dir 'ci'
// args '--cap-add SYS_ADMIN ' +
// '--security-opt apparmor:unconfined ' +
// '--device /dev/fuse ' +
// '--group-add docker ' +
// '--volume=/var/run/docker.sock:/var/run/docker.sock ' +
// '--network=host ' +
// '--user jenkins'
// }
//}
parameters {
booleanParam(
name: 'RELEASE',
description: 'Decides whether release credentials are used.',
defaultValue: params.RELEASE ?: false
)
booleanParam(
name: 'INCLUDE_DEBUG_SYMBOLS',
description: 'Decides whether binaries are built with debug symbols.',
defaultValue: params.INCLUDE_DEBUG_SYMBOLS ?: false
)
choice(
name: 'VERBOSE',
description: 'Level of verbosity based on nimbus-build-system setup.',
choices: ['0', '1', '2']
)
string(
name: 'NIMFLAGS',
description: 'Extra Nim flags. Examples: --verbosity:2 --passL:"-v" --passC:"-v"',
defaultValue: ''
)
booleanParam(
name: 'USE_SIMULATED_KEYCARD',
description: 'Build with the simulated (jcardsim) keycard backend (used by keycard e2e tests).',
defaultValue: false
)
string(
name: 'STATUS_GO_REF',
description: 'Override vendor/status-go submodule to this SHA/ref.',
defaultValue: ''
)
}
options {
timestamps()
/* Prevent Jenkins jobs from running forever */
timeout(time: 30, unit: 'MINUTES')
/* manage how many builds we keep */
buildDiscarder(logRotator(
numToKeepStr: '10',
daysToKeepStr: '30',
artifactNumToKeepStr: '1',
))
/* Allows combined build to copy */
copyArtifactPermission('/status-app/*')
/* Abort old PR builds. */
disableConcurrentBuilds(
abortPrevious: isPRBuild
)
disableRestartFromStage()
}
// TODO: pass to nix.develop via keepEnv instaed of pure: false
environment {
PLATFORM = "linux-nix/${getArch()}"
/* Improve make performance */
MAKEFLAGS = "-j${utils.getProcCount()} V=${params.VERBOSE}"
/* Avoid weird bugs caused by stale cache. */
QML_DISABLE_DISK_CACHE = "true"
/* Control output the filename */
VERSION = "${utils.getVersion()}"
STATUS_CLIENT_APPIMAGE = "pkg/${utils.pkgFilename(ext: 'nix.AppImage', arch: getArch(), version: env.VERSION)}"
STATUS_CLIENT_TARBALL = "pkg/${utils.pkgFilename(ext: 'nix.tar.gz', arch: getArch(), version: env.VERSION)}"
/* prevent sharing cache dir across different jobs */
GO_GENERATE_FAST_DIR = "${env.WORKSPACE_TMP}/go-generate-fast"
SENTRY_PRODUCTION = "${utils.isReleaseBuild() ? 'true' : 'false'}"
/* Hack fix for params not being set in job on first run */
ENTITLEMENTS = "${params.ENTITLEMENTS}"
RELEASE = "${params.RELEASE}"
INCLUDE_DEBUG_SYMBOLS = "${params.INCLUDE_DEBUG_SYMBOLS}"
VERBOSE = "${params.VERBOSE}"
USE_SIMULATED_KEYCARD = "${params.USE_SIMULATED_KEYCARD}"
/* FIXME: figure out why NIMFLAGS are not respected */
XDG_CACHE_HOME = "${env.WORKSPACE_TMP}/.cache"
/* Ensure nimcache is not shared between builds. */
NIMFLAGS = "${params.NIMFLAGS} --colors:off"
}
stages {
stage('Cleanup Workspace') {
steps {
sh './scripts/clean-git.sh'
}
}
stage('debug') {
steps { script {
nix.develop("""
set -eux
echo "=== DEBUG ==="
""", pure: false)
} }
}
stage('Fetch submodules') {
steps {
sh 'git submodule update --init --recursive'
}
}
stage('Override status-go ref') {
when { expression { params.STATUS_GO_REF?.trim() } }
steps { script {
nix.develop('./scripts/override-status-go-ref.sh ${params.STATUS_GO_REF}', pure: false)
} }
}
stage('Deps') {
steps { script {
nix.develop('make update', pure: false)
nix.develop('make deps', pure: false)
} }
}
stage('status-go') {
steps { script {
nix.develop('make status-go', pure: false)
} }
}
stage('Build') {
environment {
NIMFLAGS = "${params.NIMFLAGS} --colors:off --nimcache:${env.WORKSPACE_TMP}/nimcache"
}
steps { script {
nix.develop('make nim_status_client', pure: false)
} }
}
stage('Tests Nim') {
steps { script {
nix.develop('make tests-nim-linux', pure: false)
} }
}
stage('Check StatusQ Tests') {
steps { script {
nix.develop('QT_QPA_PLATFORM=offscreen make run-statusq-tests', pure: false)
} }
}
stage('Check StatusQ Sanity Checker') {
steps { script {
nix.develop('''
QT_QPA_PLATFORM=offscreen \
QT_FORCE_STDERR_LOGGING=1 \
make run-statusq-sanity-checker
''', pure: false)
}
}
}
stage('Check Storybook Tests') {
steps { script {
nix.develop('make run-storybook-tests', pure: false)
} }
}
stage('Check Storybook Pages Validator') {
steps { script {
nix.develop('QT_QPA_PLATFORM=offscreen make run-storybook-pages-validator', pure: false)
} }
}
}
post {
success { script { github.notifyPR(true) } }
failure { script { github.notifyPR(false) } }
// failure { script {
// discord.send(
// header: 'CI Desktop build Failure!',
// cred: 'discord-status-desktop-webhook',
// )
// } }
cleanup {
cleanWs(disableDeferredWipeout: true)
dir(env.WORKSPACE_TMP) { deleteDir() }
}
}
}
def getArch() {
def tokens = Thread.currentThread().getName().split('/')
for (def arch in ['x86_64', 'aarch64']) {
if (tokens.contains(arch)) { return arch }
}
}