Skip to content

Commit

Permalink
Fix diawi upload for nightlies.
Browse files Browse the repository at this point in the history
BRANCH_NAME isn't set for nightly builds, fix fastlane script accordingly.

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
  • Loading branch information
mandrigin committed Aug 15, 2018
1 parent c57a1f4 commit 6e80321
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 40 deletions.
5 changes: 0 additions & 5 deletions ci/Jenkinsfile
Expand Up @@ -25,11 +25,6 @@ def installJSDeps() {

timeout(90) {
node ('fastlane') {
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def branch;

load "$HOME/env.groovy"

try {
Expand Down
27 changes: 15 additions & 12 deletions ci/Jenkinsfile.nightly_fastlane
Expand Up @@ -28,6 +28,7 @@ def installJSDeps() {
timeout(90) {
node ('fastlane'){
def apkUrl = ''
def testApkUrl = ''
def ipaUrl = ''
def testPassed = true
def version
Expand Down Expand Up @@ -129,6 +130,9 @@ timeout(90) {
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
]) {
sh 'fastlane ios upload_diawi'

env.WORKSPACE = pwd()
ipaUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out"
}
}
} catch (e) {
Expand All @@ -151,18 +155,17 @@ timeout(90) {
}

stage('Upload apk for e2e tests') {
if (env.CHANGE_ID != null) {
env.SAUCE_LABS_APK = 'im.status.ethereum-e2e-' + env.CHANGE_ID + '.apk'
withCredentials([
string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'),
string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME'),
string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'),
string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GITHUB_TOKEN'),
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
]) {
sh 'fastlane android saucelabs'
sh 'fastlane android upload_diawi'
}
env.SAUCE_LABS_APK = 'im.status.ethereum-e2e-' + shortCommit + '.apk'
withCredentials([
string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'),
string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME'),
string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'),
string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GITHUB_TOKEN'),
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
]) {
sh 'fastlane android saucelabs'
sh 'fastlane android upload_diawi'
testApkUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out"
}
}

Expand Down
3 changes: 3 additions & 0 deletions ci/Jenkinsfile.parameters
Expand Up @@ -105,6 +105,9 @@ timeout(90) {
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
]) {
sh 'fastlane ios upload_diawi'

env.WORKSPACE = pwd()
ipaUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out"
}
}

Expand Down
25 changes: 13 additions & 12 deletions ci/Jenkinsfile.release
Expand Up @@ -115,6 +115,9 @@ timeout(90) {
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
]) {
sh 'fastlane ios upload_diawi'

env.WORKSPACE = pwd()
ipaUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out"
}
}

Expand All @@ -133,18 +136,16 @@ timeout(90) {
}

stage('Upload apk for e2e tests') {
if (env.CHANGE_ID != null) {
env.SAUCE_LABS_APK = 'im.status.ethereum-e2e-' + env.CHANGE_ID + '.apk'
withCredentials([
string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'),
string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME'),
string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'),
string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GITHUB_TOKEN'),
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
]) {
sh 'fastlane android saucelabs'
sh 'fastlane android upload_diawi'
}
env.SAUCE_LABS_APK = 'im.status.ethereum-e2e-' + shortCommit + '.apk'
withCredentials([
string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'),
string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME'),
string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'),
string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GITHUB_TOKEN'),
string(credentialsId: 'SLACK_JENKINS_WEBHOOK', variable: 'SLACK_URL')
]) {
sh 'fastlane android saucelabs'
sh 'fastlane android upload_diawi'
}
}

Expand Down
64 changes: 53 additions & 11 deletions fastlane/Fastfile
Expand Up @@ -22,6 +22,15 @@ def unlock_keychain_if_needed
end


def clean_up_realm_core_ios
realm_dir ="../node_modules/realm/vendor/realm-ios/"
if Dir.exists?(realm_dir)
FileUtils.remove_dir(realm_dir)
end
FileUtils.mkdir(realm_dir)
end


# uploads `file` to sauce labs (overwrites if there is anoter file from the
# same commit)
def upload_to_saucelabs(file)
Expand Down Expand Up @@ -58,6 +67,9 @@ def build_ios_adhoc
readonly: true,
keychain_name: "login.keychain"
)

workaround_realm_core_sync_issues

build_ios_app(
scheme: "StatusIm",
workspace: "ios/StatusIm.xcworkspace",
Expand All @@ -70,8 +82,10 @@ end


def notify_about_new_build(source, url)
branch_name = ENV["BRANCH_NAME"]
branch_name = "develop" if branch_name.nil?

msg = "Branch: " + ENV["BRANCH_NAME"] + ", "
msg = "Branch: " + branch_name + ", "

if source.end_with? ".ipa"
msg = msg + "iOS build uploaded to diawi: " + url
Expand All @@ -84,15 +98,21 @@ def notify_about_new_build(source, url)
slack_url: ENV["SLACK_URL"]
)

github_api(
server_url: "https://api.github.com",
api_token: ENV["GITHUB_TOKEN"],
http_method: "POST",
path: "/repos/status-im/status-react/issues/" + ENV["CHANGE_ID"] + "/comments",
body: {
"body": msg
}
)
change_id = ENV["CHANGE_ID"]

unless change_id.nil?

github_api(
server_url: "https://api.github.com",
api_token: ENV["GITHUB_TOKEN"],
http_method: "POST",
path: "/repos/status-im/status-react/issues/" + change_id + "/comments",
body: {
"body": msg
}
)

end

end

Expand All @@ -103,13 +123,14 @@ def upload_to_diawi_and_notify(source)
file: source
)

File.write("diawi.out", lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI])

notify_about_new_build(
source,
lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI]
)
end


platform :ios do
desc "`fastlane ios adhoc` - ad-hoc lane for iOS."
desc "This lane is used PRs, Releases, etc."
Expand All @@ -132,6 +153,9 @@ platform :ios do
readonly: true,
keychain_name: "login.keychain"
)

workaround_realm_core_sync_issues

build_ios_app(
scheme: "StatusIm",
workspace: "ios/StatusIm.xcworkspace",
Expand Down Expand Up @@ -162,6 +186,9 @@ platform :ios do
readonly: true,
keychain_name: "login.keychain"
)

workaround_realm_core_sync_issues

build_ios_app(
scheme: "StatusIm",
workspace: "ios/StatusIm.xcworkspace",
Expand Down Expand Up @@ -198,11 +225,24 @@ platform :ios do
desc "expects to have a github token as GITHUB_TOKEN env variable"
desc "expects to have a slack webhook URL as SLACK_URL env variable"
desc "will fails if file isn't there"
desc "---"
desc "Output: writes `fastlane/diawi.out` file url of the uploded file"
lane :upload_diawi do
upload_to_diawi_and_notify(
"status-adhoc/StatusIm.ipa"
)
end


desc "This fastlane step is a workaround!"
desc "every now and then Realm fails on iOS on the 'Download Core` step"
desc "the issue is being `node_modules/realm/vendor/realm-ios/` dir not being empty"
desc "but missing the lock file"
desc "as a workaround, we clean up this directory"
lane :workaround_realm_core_sync_issues do
clean_up_realm_core_ios
end

end


Expand Down Expand Up @@ -242,6 +282,8 @@ platform :android do
desc "expects to have a github token as GITHUB_TOKEN env variable"
desc "expects to have a slack webhook URL as SLACK_URL env variable"
desc "will fails if file isn't there"
desc "---"
desc "Output: writes `fastlane/diawi.out` file url of the uploded file"
lane :upload_diawi do
upload_to_diawi_and_notify(
"android/app/build/outputs/apk/release/app-release.apk"
Expand Down

0 comments on commit 6e80321

Please sign in to comment.