diff --git a/ci/Jenkinsfile.android b/ci/Jenkinsfile.android index d7a59a52de..bc3fca1949 100644 --- a/ci/Jenkinsfile.android +++ b/ci/Jenkinsfile.android @@ -22,13 +22,13 @@ pipeline { } environment { + LANG = "en_US.UTF-8" + LC_ALL = "en_US.UTF-8" + LANGUAGE = "en_US.UTF-8" TARGET_OS = 'android' - LANG = 'en_US.UTF-8' - LANGUAGE = 'en_US.UTF-8' - LC_ALL = 'en_US.UTF-8' + NIX_CONF_DIR = "${env.WORKSPACE}/nix" FASTLANE_DISABLE_COLORS = 1 REALM_DISABLE_ANALYTICS = 1 - CI_ENVIRONMENT = 'jenkins' /* since we are mounting it we need to specify location */ STATUS_RELEASE_STORE_FILE = '/home/jenkins/status-im.keystore' /* We use EXECUTOR_NUMBER to avoid multiple instances clashing */ @@ -54,17 +54,17 @@ pipeline { } stage('Lint') { steps { - script { cmn.utils.nix_sh('lein cljfmt check') } + script { cmn.nix.shell('lein cljfmt check') } } } stage('Tests') { steps { - script { cmn.utils.nix_sh('lein test-cljs') } + script { cmn.nix.shell('lein test-cljs') } } } stage('Build') { steps { - script { cmn.utils.nix_sh('lein prod-build-android') } + script { cmn.nix.shell('lein prod-build-android') } } } stage('Bundle') { diff --git a/ci/Jenkinsfile.fastlane.clean b/ci/Jenkinsfile.fastlane.clean index 78285f5e61..3c78d845ad 100644 --- a/ci/Jenkinsfile.fastlane.clean +++ b/ci/Jenkinsfile.fastlane.clean @@ -6,7 +6,6 @@ pipeline { LANGUAGE = "en_US.UTF-8" LC_ALL = "en_US.UTF-8" FASTLANE_DISABLE_COLORS = 1 - REALM_DISABLE_ANALYTICS = 1 } options { diff --git a/ci/Jenkinsfile.ios b/ci/Jenkinsfile.ios index 0722f5117b..e22e194d8e 100644 --- a/ci/Jenkinsfile.ios +++ b/ci/Jenkinsfile.ios @@ -22,15 +22,18 @@ pipeline { } environment { + LANG = "en_US.UTF-8" + LC_ALL = "en_US.UTF-8" + LANGUAGE = "en_US.UTF-8" TARGET_OS = 'ios' - CI_ENVIRONMENT = 'jenkins' - LANG = 'en_US.UTF-8' - LANGUAGE = 'en_US.UTF-8' - LC_ALL = 'en_US.UTF-8' NIX_CONF_DIR = "${env.WORKSPACE}/nix" - FASTLANE_DISABLE_COLORS=1 - REALM_DISABLE_ANALYTICS=1 + FASTLANE_DISABLE_COLORS = 1 + REALM_DISABLE_ANALYTICS = 1 BUNDLE_PATH = "${HOME}/.bundle" + /* We use EXECUTOR_NUMBER to avoid multiple instances clashing */ + LEIN_HOME = "/var/tmp/lein-${EXECUTOR_NUMBER}" + YARN_CACHE_FOLDER = "/var/tmp/yarn-${EXECUTOR_NUMBER}" + GRADLE_USER_HOME = "/var/tmp/gradle-${EXECUTOR_NUMBER}" } stages { @@ -50,17 +53,17 @@ pipeline { } stage('Lint') { steps { - script { cmn.utils.nix_sh('lein cljfmt check') } + script { cmn.nix.shell('lein cljfmt check') } } } stage('Tests') { steps { - script { cmn.utils.nix_sh('lein test-cljs') } + script { cmn.nix.shell('lein test-cljs') } } } stage('Build') { steps { - script { cmn.utils.nix_sh('lein prod-build-ios') } + script { cmn.nix.shell('lein prod-build-ios') } } } stage('Bundle') { diff --git a/ci/Jenkinsfile.linux b/ci/Jenkinsfile.linux index 148e75ea0c..ab7b73f28b 100644 --- a/ci/Jenkinsfile.linux +++ b/ci/Jenkinsfile.linux @@ -26,15 +26,16 @@ pipeline { * https://issues.jenkins-ci.org/browse/JENKINS-49076 **/ environment { + LANG = "en_US.UTF-8" + LC_ALL = "en_US.UTF-8" + LANGUAGE = "en_US.UTF-8" TARGET_OS = 'linux' - LANG = 'en_US.UTF-8' - LANGUAGE = 'en_US.UTF-8' - LC_ALL = 'en_US.UTF-8' - NPM_CONFIG_CACHE = '/var/tmp/npm' - CI_ENVIRONMENT = 'jenkins' - LEIN_HOME = '/var/tmp/lein' NIX_CONF_DIR = "${env.WORKSPACE}/nix" VERBOSE_LEVEL = '3' + /* We use EXECUTOR_NUMBER to avoid multiple instances clashing */ + LEIN_HOME = "/var/tmp/lein-${EXECUTOR_NUMBER}" + YARN_CACHE_FOLDER = "/var/tmp/yarn-${EXECUTOR_NUMBER}" + GRADLE_USER_HOME = "/var/tmp/gradle-${EXECUTOR_NUMBER}" } stages { @@ -54,12 +55,12 @@ pipeline { } stage('Lint') { steps { - script { cmn.utils.nix_sh('lein cljfmt check') } + script { cmn.nix.shell('lein cljfmt check') } } } stage('Tests') { steps { - script { cmn.utils.nix_sh('lein test-cljs') } + script { cmn.nix.shell('lein test-cljs') } } } stage('Build') { diff --git a/ci/Jenkinsfile.macos b/ci/Jenkinsfile.macos index 21917a14f9..08e80f0b89 100644 --- a/ci/Jenkinsfile.macos +++ b/ci/Jenkinsfile.macos @@ -22,13 +22,16 @@ pipeline { } environment { + LANG = "en_US.UTF-8" + LC_ALL = "en_US.UTF-8" + LANGUAGE = "en_US.UTF-8" TARGET_OS = 'macos' - CI_ENVIRONMENT = 'jenkins' - LANG = 'en_US.UTF-8' - LANGUAGE = 'en_US.UTF-8' - LC_ALL = 'en_US.UTF-8' NIX_CONF_DIR = "${env.WORKSPACE}/nix" VERBOSE_LEVEL = '3' + /* We use EXECUTOR_NUMBER to avoid multiple instances clashing */ + LEIN_HOME = "/var/tmp/lein-${EXECUTOR_NUMBER}" + YARN_CACHE_FOLDER = "/var/tmp/yarn-${EXECUTOR_NUMBER}" + GRADLE_USER_HOME = "/var/tmp/gradle-${EXECUTOR_NUMBER}" } stages { @@ -48,12 +51,12 @@ pipeline { } stage('Lint') { steps { - script { cmn.utils.nix_sh('lein cljfmt check') } + script { cmn.nix.shell('lein cljfmt check') } } } stage('Tests') { steps { - script { cmn.utils.nix_sh('lein test-cljs') } + script { cmn.nix.shell('lein test-cljs') } } } stage('Build') { diff --git a/ci/Jenkinsfile.nix-cache b/ci/Jenkinsfile.nix-cache index 1e956ba318..a6efd247c1 100644 --- a/ci/Jenkinsfile.nix-cache +++ b/ci/Jenkinsfile.nix-cache @@ -2,7 +2,6 @@ pipeline { agent { label params.AGENT_LABEL } environment { - CI_ENVIRONMENT = 'jenkins' /* we source .bash_profile to be able to use nix-store */ NIX_SSHOPTS = "-o StrictHostKeyChecking=no source .bash_profile;" /* where our /nix/store is hosted */ diff --git a/ci/Jenkinsfile.windows b/ci/Jenkinsfile.windows index 765ba84153..5f6dcb6e06 100644 --- a/ci/Jenkinsfile.windows +++ b/ci/Jenkinsfile.windows @@ -26,18 +26,20 @@ pipeline { * https://issues.jenkins-ci.org/browse/JENKINS-49076 **/ environment { + LANG = "en_US.UTF-8" + LC_ALL = "en_US.UTF-8" + LANGUAGE = "en_US.UTF-8" TARGET_OS = 'windows' - CI_ENVIRONMENT = 'jenkins' - LANG = 'en_US.UTF-8' - LANGUAGE = 'en_US.UTF-8' - LC_ALL = 'en_US.UTF-8' - NPM_CONFIG_CACHE = '/var/tmp/npm' - LEIN_HOME = '/var/tmp/lein' NIX_CONF_DIR = "${env.WORKSPACE}/nix" + VERBOSE_LEVEL = '3' + /* Conan settings */ CONAN_PRINT_RUN_COMMANDS = '1' CONAN_SYSREQUIRES_MODE = 'disabled' CONAN_SYSREQUIRES_SUDO = '0' - VERBOSE_LEVEL = '3' + /* We use EXECUTOR_NUMBER to avoid multiple instances clashing */ + LEIN_HOME = "/var/tmp/lein-${EXECUTOR_NUMBER}" + YARN_CACHE_FOLDER = "/var/tmp/yarn-${EXECUTOR_NUMBER}" + GRADLE_USER_HOME = "/var/tmp/gradle-${EXECUTOR_NUMBER}" } stages { @@ -57,12 +59,12 @@ pipeline { } stage('Lint') { steps { - script { cmn.utils.nix_sh('lein cljfmt check') } + script { cmn.nix.shell('lein cljfmt check') } } } stage('Tests') { steps { - script { cmn.utils.nix_sh('lein test-cljs') } + script { cmn.nix.shell('lein test-cljs') } } } stage('Build') { diff --git a/ci/android.groovy b/ci/android.groovy index 7d031a4a94..3e4e630f06 100644 --- a/ci/android.groovy +++ b/ci/android.groovy @@ -1,3 +1,4 @@ +nix = load 'ci/nix.groovy' utils = load 'ci/utils.groovy' def bundle() { @@ -24,7 +25,14 @@ def bundle() { passwordVariable: 'STATUS_RELEASE_KEY_PASSWORD' ) ]) { - utils.nix_sh "./gradlew assemble${target.capitalize()} ${gradleOpt}" + nix.shell( + "./gradlew assemble${target.capitalize()} ${gradleOpt}", + keep: [ + 'REALM_DISABLE_ANALYTICS', + 'STATUS_RELEASE_STORE_FILE', 'STATUS_RELEASE_STORE_PASSWORD', + 'STATUS_RELEASE_KEY_ALIAS', 'STATUS_RELEASE_KEY_PASSWORD' + ] + ) } } sh 'find android/app/build/outputs/apk' @@ -34,7 +42,6 @@ def bundle() { sh "cp ${outApk} ${pkg}" /* necessary for Fastlane */ env.APK_PATH = pkg - env.DIAWI_APK = pkg return pkg } @@ -42,7 +49,10 @@ def uploadToPlayStore(type = 'nightly') { withCredentials([ string(credentialsId: "SUPPLY_JSON_KEY_DATA", variable: 'GOOGLE_PLAY_JSON_KEY'), ]) { - utils.nix_fastlane_sh "android ${type}" + nix.shell( + "fastlane android ${type}", + keep: ['FASTLANE_DISABLE_COLORS', 'GOOGLE_PLAY_JSON_KEY'] + ) } } @@ -58,7 +68,13 @@ def uploadToSauceLabs() { string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'), string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME'), ]) { - utils.nix_fastlane_sh 'android saucelabs' + nix.shell( + 'fastlane android saucelabs', + keep: [ + 'FASTLANE_DISABLE_COLORS', 'APK_PATH', + 'SAUCE_ACCESS_KEY', 'SAUCE_USERNAME', 'SAUCE_LABS_NAME' + ] + ) } return env.SAUCE_LABS_NAME } @@ -68,7 +84,10 @@ def uploadToDiawi() { withCredentials([ string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'), ]) { - utils.nix_fastlane_sh 'android upload_diawi' + nix.shell( + 'fastlane android upload_diawi', + keep: ['FASTLANE_DISABLE_COLORS', 'APK_PATH', 'DIAWI_TOKEN'] + ) } diawiUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out" return diawiUrl diff --git a/ci/common.groovy b/ci/common.groovy index 999a21179c..c40d1394a0 100644 --- a/ci/common.groovy +++ b/ci/common.groovy @@ -1,8 +1,11 @@ import groovy.json.JsonBuilder +/* Libraries -----------------------------------------------------------------*/ + gh = load 'ci/github.groovy' ci = load 'ci/jenkins.groovy' gh = load 'ci/github.groovy' +nix = load 'ci/nix.groovy' utils = load 'ci/utils.groovy' ghcmgr = load 'ci/ghcmgr.groovy' @@ -42,19 +45,9 @@ def notifyPR(success) { } } -def prepNixEnvironment() { - if (env.TARGET_OS == 'linux' || env.TARGET_OS == 'windows' || env.TARGET_OS == 'android') { - def glibcLocales = sh( - returnStdout: true, - script: ". ~/.nix-profile/etc/profile.d/nix.sh && nix-build --no-out-link '' -A glibcLocales" - ).trim() - env.LOCALE_ARCHIVE_2_27 = "${glibcLocales}/lib/locale/locale-archive" - } -} - def prep(type = 'nightly') { /* build/downloads all nix deps in advance */ - prepNixEnvironment() + nix.prepEnv() /* rebase unless this is a release build */ utils.doGitRebase() /* ensure that we start from a known state */ @@ -69,7 +62,7 @@ def prep(type = 'nightly') { if (env.TARGET_OS == 'ios') { /* install ruby dependencies */ - utils.nix_sh 'bundle install --gemfile=fastlane/Gemfile --quiet' + nix.shell 'bundle install --gemfile=fastlane/Gemfile --quiet' } def prepareTarget=env.TARGET_OS @@ -77,7 +70,7 @@ def prep(type = 'nightly') { prepareTarget='desktop' } /* node deps, pods, and status-go download */ - utils.nix_impure_sh "scripts/prepare-for-platform.sh ${prepareTarget}" + utils.nix.shell("scripts/prepare-for-platform.sh ${prepareTarget}", pure: false) } return this diff --git a/ci/desktop.groovy b/ci/desktop.groovy index f79f3c084a..294dfacf20 100644 --- a/ci/desktop.groovy +++ b/ci/desktop.groovy @@ -1,20 +1,24 @@ -utils = load 'ci/utils.groovy' +nix = load 'ci/nix.groovy' cmn = load 'ci/common.groovy' +utils = load 'ci/utils.groovy' packageFolder = './StatusImPackage' def cleanupAndDeps() { sh 'make clean' sh 'cp .env.jenkins .env' - utils.nix_sh 'lein deps' + nix.shell 'lein deps' utils.installJSDeps('desktop') } def buildClojureScript() { - utils.nix_sh ''' - make prod-build-desktop && \ - ./scripts/build-desktop.sh buildClojureScript - ''' + nix.shell( + ''' + make prod-build-desktop && \ + ./scripts/build-desktop.sh buildClojureScript + ''', + keep: ['VERBOSE_LEVEL'] + ) } def uploadArtifact(filename) { @@ -51,13 +55,19 @@ def compile() { if (env.QT_PATH) { env.PATH = "${env.QT_PATH}:${env.PATH}" } - utils.nix_sh './scripts/build-desktop.sh compile' + nix.shell( + './scripts/build-desktop.sh compile', + keep: ['VERBOSE_LEVEL'] + ) } def bundleWindows(type = 'nightly') { def pkg - utils.nix_sh './scripts/build-desktop.sh bundle' + nix.shell( + './scripts/build-desktop.sh bundle', + keep: ['VERBOSE_LEVEL'] + ) dir(packageFolder) { pkg = utils.pkgFilename(type, 'exe') sh "mv ../Status-x86_64-setup.exe ${pkg}" @@ -67,7 +77,10 @@ def bundleWindows(type = 'nightly') { def bundleLinux(type = 'nightly') { def pkg - utils.nix_sh './scripts/build-desktop.sh bundle' + nix.shell( + './scripts/build-desktop.sh bundle', + keep: ['VERBOSE_LEVEL'] + ) dir(packageFolder) { pkg = utils.pkgFilename(type, 'AppImage') sh "mv ../Status-x86_64.AppImage ${pkg}" @@ -77,18 +90,25 @@ def bundleLinux(type = 'nightly') { def bundleMacOS(type = 'nightly') { def pkg = utils.pkgFilename(type, 'dmg') - utils.nix_sh './scripts/build-desktop.sh bundle' + nix.shell( + './scripts/build-desktop.sh bundle', + keep: ['VERBOSE_LEVEL'] + ) dir(packageFolder) { withCredentials([ string(credentialsId: 'desktop-gpg-outer-pass', variable: 'GPG_PASS_OUTER'), string(credentialsId: 'desktop-gpg-inner-pass', variable: 'GPG_PASS_INNER'), string(credentialsId: 'desktop-keychain-pass', variable: 'KEYCHAIN_PASS') ]) { - utils.nix_impure_sh """ + nix.shell( + """ ../scripts/sign-macos-pkg.sh Status.app ../deployment/macos/macos-developer-id.keychain-db.gpg && \ ../node_modules/appdmg/bin/appdmg.js ../deployment/macos/status-dmg.json ${pkg} && \ ../scripts/sign-macos-pkg.sh ${pkg} ../deployment/macos/macos-developer-id.keychain-db.gpg - """ + """, + pure: false, + keep: ['GPG_PASS_OUTER', 'GPG_PASS_INNER', 'KEYCHAIN_PASS'] + ) } } return "${packageFolder}/${pkg}".drop(2) diff --git a/ci/ios.groovy b/ci/ios.groovy index 573b52dcc4..e0322ab921 100644 --- a/ci/ios.groovy +++ b/ci/ios.groovy @@ -1,3 +1,4 @@ +nix = load('ci/nix.groovy') utils = load('ci/utils.groovy') def plutil(name, value) { @@ -16,7 +17,7 @@ def bundle() { default: target = 'nightly'; } /* configure build metadata */ - utils.nix_sh( + nix.shell( plutil('CFBundleShortVersionString', utils.getVersion('mobile_files')) + plutil('CFBundleVersion', utils.genBuildNumber()) + plutil('CFBundleBuildUrl', currentBuild.absoluteUrl) @@ -33,7 +34,14 @@ def bundle() { passwordVariable: 'FASTLANE_PASSWORD' ), ]) { - utils.nix_sh "bundle exec --gemfile=fastlane/Gemfile fastlane ios ${target}" + nix.shell( + "bundle exec --gemfile=fastlane/Gemfile fastlane ios ${target}", + keep: [ + 'FASTLANE_DISABLE_COLORS', + 'FASTLANE_PASSWORD', 'KEYCHAIN_PASSWORD', + 'MATCH_PASSWORD', 'FASTLANE_APPLE_ID', + ] + ) } /* rename built file for uploads and archivization */ def pkg = '' @@ -56,7 +64,10 @@ def uploadToDiawi() { withCredentials([ string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'), ]) { - utils.nix_sh 'bundle exec --gemfile=fastlane/Gemfile fastlane ios upload_diawi' + nix.shell( + 'bundle exec --gemfile=fastlane/Gemfile fastlane ios upload_diawi', + keep: ['FASTLANE_DISABLE_COLORS', 'DIAWI_TOKEN'] + ) } diawiUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out" return diawiUrl @@ -73,7 +84,10 @@ def uploadToSauceLabs() { string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'), string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME'), ]) { - utils.nix_sh 'bundle exec --gemfile=fastlane/Gemfile fastlane ios saucelabs' + nix.shell( + 'bundle exec --gemfile=fastlane/Gemfile fastlane ios saucelabs', + keep: ['FASTLANE_DISABLE_COLORS', 'SAUCE_ACCESS_KEY', 'SAUCE_USERNAME'] + ) } return env.SAUCE_LABS_NAME } diff --git a/ci/nix.groovy b/ci/nix.groovy new file mode 100644 index 0000000000..c5ce9efc56 --- /dev/null +++ b/ci/nix.groovy @@ -0,0 +1,53 @@ +/** + * Arguments: + * - pure - Use --pure mode with Nix for more deterministic behaviour + * - keep - List of env variables to keep even in pure mode + * - args - Map of arguments to provide to --argstr + **/ +def shell(Map opts = [:], String cmd) { + def defaults = [ + pure: true, + args: ['target-os': env.TARGET_OS], + keep: ['LOCALE_ARCHIVE_2_27'], + ] + /* merge defaults with received opts */ + opts = defaults + opts + /* Previous merge overwrites the array */ + opts.keep = (opts.keep + defaults.keep).unique() + + def isPure = opts.pure && env.TARGET_OS != 'windows' && env.TARGET_OS != 'ios' + def keepFlags = opts.keep.collect { var -> "--keep ${var} " } + def argsFlags = opts.args.collect { key,val -> "--argstr ${key} \'${val}\'" } + sh """ + set +x + . ~/.nix-profile/etc/profile.d/nix.sh + set -x + nix-shell \\ + ${isPure ? "--pure" : ""} \\ + ${keepFlags.join(" ")} \\ + ${argsFlags.join(" ")} \\ + --run \'${cmd}\' \\ + \'${env.WORKSPACE}/shell.nix\' + """ +} + +def prepEnv() { + if (env.TARGET_OS in ['linux', 'windows', 'android']) { + def glibcLocales = sh( + returnStdout: true, + script: """ + . ~/.nix-profile/etc/profile.d/nix.sh && \\ + nix-build --no-out-link '' -A glibcLocales + """ + ).trim() + /** + * This is a hack to fix missing locale errors. + * See: + * - https://github.com/NixOS/nixpkgs/issues/38991 + * - https://qiita.com/kimagure/items/4449ceb0bda5c10ca50f + **/ + env.LOCALE_ARCHIVE_2_27 = "${glibcLocales}/lib/locale/locale-archive" + } +} + +return this diff --git a/ci/utils.groovy b/ci/utils.groovy index 8b11433099..d53cce61b3 100644 --- a/ci/utils.groovy +++ b/ci/utils.groovy @@ -1,3 +1,5 @@ +nix = load 'ci/nix.groovy' + def getVersion(type = null) { /* if type is undefined we get VERSION from repo root */ def path = "${env.WORKSPACE}/VERSION" @@ -15,42 +17,6 @@ def getToolVersion(name) { return version } -def nix_impure_sh(cmd) { - _nix_sh(cmd, true) -} - -def nix_sh(cmd) { - _nix_sh(cmd, false) -} - -def _nix_sh(cmd, forceImpure) { - def isPure = !forceImpure && env.TARGET_OS != 'windows' && env.TARGET_OS != 'ios' - def pureFlag = isPure ? '--pure --keep LOCALE_ARCHIVE_2_27 --keep REALM_DISABLE_ANALYTICS --keep STATUS_RELEASE_STORE_FILE --keep STATUS_RELEASE_STORE_PASSWORD --keep STATUS_RELEASE_KEY_ALIAS --keep STATUS_RELEASE_KEY_PASSWORD --keep GPG_PASS_OUTER --keep GPG_PASS_INNER --keep KEYCHAIN_PASS --keep VERBOSE_LEVEL' : '' - - sh """ - set +x - . ~/.nix-profile/etc/profile.d/nix.sh - set -x - nix-shell --argstr target-os \'${env.TARGET_OS}\' \\ - ${pureFlag} --run \'${cmd}\' \\ - \'${env.WORKSPACE}/shell.nix\' - """ -} - -def nix_fastlane_sh(cmd) { - def isPure = env.TARGET_OS != 'ios' - def pureFlag = isPure ? '--pure --keep LANG --keep LANGUAGE --keep LC_ALL --keep DIAWI_TOKEN --keep DIAWI_IPA --keep APK_PATH --keep GOOGLE_PLAY_JSON_KEY --keep SAUCE_LABS_NAME --keep SAUCE_USERNAME --keep SAUCE_ACCESS_KEY --keep FASTLANE_DISABLE_COLORS --keep FASTLANE_APPLE_ID --keep FASTLANE_PASSWORD --keep KEYCHAIN_PASSWORD --keep MATCH_PASSWORD --keep REALM_DISABLE_ANALYTICS --keep STATUS_RELEASE_STORE_FILE --keep GRADLE_USER_HOME' : '' - - sh """ - set +x - . ~/.nix-profile/etc/profile.d/nix.sh - set -x - nix-shell --argstr target-os \'${env.TARGET_OS}\' \\ - ${pureFlag} --run \'fastlane ${cmd}\' \\ - \'${env.WORKSPACE}/shell.nix\' - """ -} - def branchName() { return env.GIT_BRANCH.replaceAll(/.*origin\//, '') } @@ -136,10 +102,10 @@ def installJSDeps(platform) { def maxAttempts = 10 def installed = false /* prepare environment for specific platform build */ - nix_sh "scripts/prepare-for-platform.sh ${platform}" + nix.shell "scripts/prepare-for-platform.sh ${platform}" while (!installed && attempt <= maxAttempts) { println "#${attempt} attempt to install npm deps" - nix_sh 'yarn install --frozen-lockfile' + nix.shell 'yarn install --frozen-lockfile' installed = fileExists('node_modules/web3/index.js') attemp = attempt + 1 } diff --git a/fastlane/Fastfile b/fastlane/Fastfile index db0c4450ea..79aea64d86 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -23,42 +23,43 @@ def unlock_keychain_if_needed end end -def curl_upload(url, file, user, conn_timeout=5, timeout=60, retries=3) - begin - return sh( - "curl", - "--fail", - "--silent", - "--user", user, - "--request", "POST", - "--header", "Content-Type: application/octet-stream", - "--data-binary", "@../#{file}", # `fastlane` is the cwd so we go one folder up - # we retry few times if upload doesn't succeed in sensible time - "--retry-connrefused", # consider ECONNREFUSED as error too retry - "--connect-timeout", conn_timeout.to_s, # max time in sec. for establishing connection - "--max-time", timeout.to_s, # max time in sec. for whole transfer to take - "--retry", retries.to_s, # number of retries to attempt - "--retry-max-time", timeout.to_s, # same as --max-time but for retries - "--retry-delay", "0", # an exponential backoff algorithm in sec. - url - ) - rescue => error - UI.error "Error: #{error}" - raise +def curl_upload(url, file, auth, conn_timeout=5, timeout=60, retries=3) + rval = sh( + "curl", + "--silent", + "--user", auth, + "--write-out", "\nHTTP_CODE:%{http_code}", + "--request", "POST", + "--header", "Content-Type: application/octet-stream", + "--data-binary", "@../#{file}", # `fastlane` is the cwd so we go one folder up + # we retry few times if upload doesn't succeed in sensible time + "--retry-connrefused", # consider ECONNREFUSED as error too retry + "--connect-timeout", conn_timeout.to_s, # max time in sec. for establishing connection + "--max-time", timeout.to_s, # max time in sec. for whole transfer to take + "--retry", retries.to_s, # number of retries to attempt + "--retry-max-time", timeout.to_s, # same as --max-time but for retries + "--retry-delay", "0", # an exponential backoff algorithm in sec. + url + ) + # We're not using --fail because it suppresses server response + if not rval.include? "HTTP_CODE:200" + raise "Error:\n#{rval}" end + return rval end -def retry_curl_upload(url, file, user, conn_timeout=5, timeout=60, retries=3) +def retry_curl_upload(url, file, auth, conn_timeout=5, timeout=60, retries=3) # since curl doesn't retry on connection and operation timeouts we roll our own try = 0 begin - return curl_upload(url, file, user, conn_timeout, timeout, retries) + return curl_upload(url, file, auth, conn_timeout, timeout, retries) rescue => error try += 1 if try <= retries UI.important "Warning: Retrying cURL upload! (attempt #{try}/#{retries})" retry else + UI.error "Error:\n#{error}" raise end end diff --git a/scripts/lib/setup/platform.sh b/scripts/lib/setup/platform.sh index 0e4e869ac2..8b313978cb 100755 --- a/scripts/lib/setup/platform.sh +++ b/scripts/lib/setup/platform.sh @@ -19,7 +19,6 @@ function exit_unless_os_supported() { cecho "@red[[This install script is not supported in a pure Nix shell]]" echo - exit 1 fi @@ -28,9 +27,7 @@ function exit_unless_os_supported() { via apt. To manually install, please visit the docs for more information:]] @blue[[https://status.im/build_status]]" - echo - exit 1 fi } diff --git a/scripts/setup b/scripts/setup index 66125c9c2e..37ad475817 100755 --- a/scripts/setup +++ b/scripts/setup @@ -28,7 +28,7 @@ if [ $_need_curl -eq 1 ] && ! program_exists "curl"; then exit 1 fi -if is_linux && [ -z "$CI_ENVIRONMENT" ]; then +if is_linux && [ -z "$JENKINS_URL" ]; then watches=$(cat /proc/sys/fs/inotify/max_user_watches) required_watches=524288 if [ $watches -lt $required_watches ]; then diff --git a/shell.nix b/shell.nix index 2c1a644113..5d43ebd7ba 100644 --- a/shell.nix +++ b/shell.nix @@ -48,4 +48,4 @@ in mkShell' { fi set +e ''; -} \ No newline at end of file +}