Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devops 756 BrowserStack Integration #1822

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ pipeline {
agent {
label 'MAC'
}

tools {nodejs "NodeJS"}

parameters {
separator(name: "BROWSERSTACK", sectionHeader: "BrowerStack configuration",
separatorStyle: "border-width: 0",
sectionHeaderStyle: """
background-color: #ffff00;
text-align: center;
padding: 4px;
color: #000000;
font-size: 20px;
font-weight: normal;
font-family: 'Orienta', sans-serif;
letter-spacing: 1px;
font-style: italic;
""")
choice choices: ['IosDevices', 'iPhone 14 Pro-16', 'iPhone 14 Pro Max-16', 'iPhone 14 Plus-16', 'iPhone 14-16', 'iPhone 12 Pro Max-16', 'iPhone 12 Pro-16', 'iPhone 12 Mini-16', 'iPhone 11 Pro Max-16', 'iPhone XS-15', 'iPhone 13 Pro Max-15', 'iPhone 13 Pro-15', 'iPhone 13 Mini-15', 'iPhone 13-15', 'iPhone 11 Pro-15', 'iPhone 11-15', 'iPhone XS-14', 'iPhone 12 Pro Max-14', 'iPhone 12 Pro-14', 'iPhone 12 Mini-14', 'iPhone 12-14', 'iPhone 11 Pro Max-14', 'iPhone 11-14', 'iPhone XS-13', 'iPhone 11 Pro Max-13', 'iPhone 11 Pro-13', 'iPhone 11-13', 'iPhone XR-15', 'iPhone 8-15', 'iPhone 8-13', 'iPhone SE 2020-16', 'iPhone SE 2022-15', 'iPhone SE 2020-13', 'iPad Air 4-14', 'iPad 9th-15', 'iPad Pro 12.9 2022-16', 'iPad Pro 12.9 2020-16', 'iPad Pro 11 2022-16', 'iPad 10th-16', 'iPad Air 5-15', 'iPad Pro 12.9 2021-14', 'iPad Pro 12.9 2020-14', 'iPad Pro 11 2021-14', 'iPad Pro 12.9 2020-13', 'iPad 8th-16', 'iPad Pro 12.9 2018-15', 'iPad Mini 2021-15', 'iPad 8th-14', 'iPad Mini 2019-13', 'iPad Air 2019-13'], description: 'Available IOS Devices on BrowserStack', name: 'BROWSERSTACK_IOS_DEVICES'
booleanParam name: 'BROWSERSTACK_TESTING', defaultValue: false, description: 'When selected testing runs over BrowserStack'
booleanParam name: 'DEVICE_TESTING', defaultValue: true, description: 'When selected UI-testing runs locally'
choice choices: ['1', '2', '3', '4',' 5'], description: 'Number of Shards for running tests on BrowserStack. <a href="https://app-automate.browserstack.com/dashboard/v2/builds/">BrowserStack Dashboard</a>', name: 'BROWSERSTACK_SHARDS'
}

environment {
PATH = "$HOME/.rbenv/shims:$PATH"
Expand Down Expand Up @@ -31,6 +53,9 @@ pipeline {
}
}
stage('Build') {
when {
expression { params.DEVICE_TESTING == true }
}
steps {
sh 'cd src && bundle exec fastlane ios build_catty'
}
Expand All @@ -42,6 +67,25 @@ pipeline {
}
}
}
stage('BrowserStack testing') {
when {
expression { params.BROWSERSTACK_TESTING == true }
}
steps {
sh 'cd src && bundle exec fastlane ios ui_tests_app_automate'
withCredentials([usernamePassword(credentialsId: 'browserstack', passwordVariable: 'BROWSERSTACK_ACCESS_KEY', usernameVariable: 'BROWSERSTACK_USERNAME')]) {
script {
browserStack('src/fastlane/app_automate')
}
}
}
post {
always {
junit skipPublishingChecks: true, testResults: 'src/fastlane/report.xml'
// junitAndCoverage "$reports/jacoco/jacocoTestDebugUnitTestReport/jacoco.xml", 'unit', javaSrc
}
}
}
stage('Test') {
steps {
sh 'cd src && bundle exec fastlane ios tests'
Expand Down
27 changes: 27 additions & 0 deletions src/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,33 @@ platform :ios do
output_name: $build_name
)
end

desc "Build UI tests for App Automate"
lane :ui_tests_app_automate do
clear_derived_data

$output_dir = "fastlane/app_automate/"
$runner_path = "../" + $output_dir + $build_name + "-UITests.zip"

gym(
scheme: $catty_schemes["debug"],
xcodebuild_formatter: "xcbeautify",
configuration: "Debug",
export_method: "development",
output_directory: $output_dir,
output_name: $build_name
)

scan(
scheme: $catty_schemes["debug"],
xcodebuild_formatter: "xcbeautify",
destination: "generic/platform=iOS",
disable_slide_to_type: false,
build_for_testing: true
)

sh("pushd " + lane_context[SharedValues::SCAN_DERIVED_DATA_PATH] + "/Build/Products/Debug-iphoneos && zip --symlinks -r $OLDPWD/" + $runner_path + " CattyUITests-Runner.app && popd")
end

##########################################################################
#
Expand Down