mirror of
https://github.com/ProtonMail/ios-mail.git
synced 2026-05-15 09:50:39 +00:00
210 lines
5.8 KiB
Ruby
210 lines
5.8 KiB
Ruby
opt_out_usage
|
|
|
|
default_platform(:ios)
|
|
|
|
APP_IDENTIFIER = "ch.protonmail.protonmail"
|
|
NOTIFICATION_EXTENSION_IDENTIFIER = "ch.protonmail.protonmail.notifications"
|
|
SHARE_EXTENSION_IDENTIFIER = "ch.protonmail.protonmail.Share"
|
|
DEVELOPER_KEYCHAIN_NAME = "PROTONMAIL_IOS_CERTIFICATE_KEYCHAIN"
|
|
DEVELOPER_KEYCHAIN_PASSWORD = "QrniqyS3LWTH3Ji"
|
|
CERTIFICATE_PATH = "fastlane/Certificates.p12"
|
|
XCODEPROJ = "ProtonMail.xcodeproj"
|
|
APP_TARGET = "ProtonMail"
|
|
UNIT_TESTS_SCHEME = "AllUnitAndSnapshotTests"
|
|
UI_TESTS_SCHEME = "ProtonMailUITest"
|
|
UI_TESTS_DEVICE = "iPhone 16 Pro"
|
|
UNIT_TESTS_DEVICE = "iPhone 16 Pro"
|
|
XCODEGEN_CONFIGURATION_FILE_PATH = "../project.yml"
|
|
|
|
CONCURRENT_WORKERS=2
|
|
MAX_CONCURRENT_SIMULATORS=2
|
|
SMOKE_PLAN_NAME="SmokeTests"
|
|
REGRESSION_PLAN_NAME="RegressionTests"
|
|
PERFORMANCE_PLAN_NAME="PerformanceTests"
|
|
|
|
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "120"
|
|
|
|
platform :ios do
|
|
def select_xcode
|
|
xcodes(version: '16.3', select_for_current_build_only: true)
|
|
end
|
|
|
|
def set_up_keychain
|
|
create_keychain(
|
|
name: DEVELOPER_KEYCHAIN_NAME,
|
|
password: DEVELOPER_KEYCHAIN_PASSWORD,
|
|
default_keychain: false,
|
|
add_to_search_list: true,
|
|
unlock: true,
|
|
timeout: 3600
|
|
)
|
|
import_certificate(
|
|
keychain_name: DEVELOPER_KEYCHAIN_NAME,
|
|
keychain_password: DEVELOPER_KEYCHAIN_PASSWORD,
|
|
certificate_path: CERTIFICATE_PATH,
|
|
certificate_password: ENV["DISTRIBUTION_CERTIFICATE_PASSWORD"]
|
|
)
|
|
end
|
|
|
|
def tear_down_keychain
|
|
delete_keychain(
|
|
name: DEVELOPER_KEYCHAIN_NAME
|
|
)
|
|
end
|
|
|
|
def get_xcode_profile
|
|
ids = [
|
|
APP_IDENTIFIER,
|
|
NOTIFICATION_EXTENSION_IDENTIFIER,
|
|
SHARE_EXTENSION_IDENTIFIER
|
|
]
|
|
|
|
ids.each do |id|
|
|
get_provisioning_profile(
|
|
app_identifier: id,
|
|
readonly: true,
|
|
)
|
|
end
|
|
end
|
|
|
|
def get_latest_build_number
|
|
latest_testflight_build_number(
|
|
app_identifier: APP_IDENTIFIER,
|
|
version: get_version_number(xcodeproj: XCODEPROJ, target: APP_TARGET),
|
|
initial_build_number: 0
|
|
)
|
|
end
|
|
|
|
def current_marketing_version
|
|
sh("sed -n 's/.*MARKETING_VERSION: \\(.*\\)/\\1/p' #{XCODEGEN_CONFIGURATION_FILE_PATH}").strip
|
|
end
|
|
|
|
def add_tag_and_push(build_number)
|
|
project_version = current_marketing_version
|
|
branch_name = ENV['CI_COMMIT_REF_NAME']
|
|
|
|
sh("git fetch origin #{branch_name}:#{branch_name}")
|
|
sh("git checkout #{branch_name}")
|
|
|
|
add_git_tag(tag: "v#{project_version}_#{build_number}")
|
|
push_to_git_remote
|
|
end
|
|
|
|
lane :decode_distribution_certificate do
|
|
sh "base64 -D -o Certificates.p12 <<< $DISTRIBUTION_CERTIFICATE"
|
|
end
|
|
|
|
desc "Run unit tests"
|
|
lane :tests do
|
|
select_xcode
|
|
|
|
run_tests(
|
|
app_identifier: APP_IDENTIFIER,
|
|
scheme: UNIT_TESTS_SCHEME,
|
|
devices: UNIT_TESTS_DEVICE,
|
|
clean: true,
|
|
reinstall_app: true,
|
|
result_bundle: true,
|
|
xcargs: "-skipPackagePluginValidation"
|
|
)
|
|
end
|
|
|
|
desc "Setup UI Tests assets"
|
|
lane :setup_uitests_assets do
|
|
sh("../scripts/uitests/setup-mock-network-assets.sh setup-remote")
|
|
sh("cd .. && mint run xcodegen") # We need to do it another time to include UI tests assets.
|
|
end
|
|
|
|
desc "Run UI Smoke Tests"
|
|
lane :uitests_smoke do
|
|
run_tests(
|
|
scheme: UI_TESTS_SCHEME,
|
|
devices: UI_TESTS_DEVICE,
|
|
max_concurrent_simulators: MAX_CONCURRENT_SIMULATORS,
|
|
concurrent_workers: CONCURRENT_WORKERS,
|
|
include_simulator_logs: true,
|
|
prelaunch_simulator: true,
|
|
reset_simulator: true,
|
|
result_bundle: true,
|
|
testplan: SMOKE_PLAN_NAME,
|
|
xcargs: "-skipPackagePluginValidation"
|
|
)
|
|
end
|
|
|
|
desc "Run UI Full Regression Tests"
|
|
lane :uitests_full_regression do
|
|
run_tests(
|
|
scheme: UI_TESTS_SCHEME,
|
|
devices: UI_TESTS_DEVICE,
|
|
max_concurrent_simulators: MAX_CONCURRENT_SIMULATORS,
|
|
concurrent_workers: CONCURRENT_WORKERS,
|
|
include_simulator_logs: true,
|
|
prelaunch_simulator: true,
|
|
reset_simulator: true,
|
|
result_bundle: true,
|
|
testplan: REGRESSION_PLAN_NAME,
|
|
xcargs: "-skipPackagePluginValidation"
|
|
)
|
|
end
|
|
|
|
desc "Run UI Performance Tests"
|
|
lane :uitests_performance do
|
|
# more info: https://keith.github.io/xcode-man-pages/xcodebuild.1.html#TEST_RUNNER__VAR_
|
|
['ET_USER', 'ET_USER_PWD', 'LOKI_ENDPOINT', 'CERTIFICATE_IOS_SDK_PASSPHRASE'].each { |env_var_key|
|
|
ENV["TEST_RUNNER_#{env_var_key}"] = ENV[env_var_key]
|
|
}
|
|
|
|
run_tests(
|
|
scheme: UI_TESTS_SCHEME,
|
|
devices: UI_TESTS_DEVICE,
|
|
max_concurrent_simulators: 1,
|
|
concurrent_workers: 1,
|
|
include_simulator_logs: true,
|
|
prelaunch_simulator: true,
|
|
reset_simulator: true,
|
|
result_bundle: true,
|
|
app_identifier: "ch.protonmail.protonmail",
|
|
testplan: PERFORMANCE_PLAN_NAME,
|
|
xcargs: "-skipPackagePluginValidation"
|
|
)
|
|
end
|
|
|
|
desc "Deploy to Test Flight"
|
|
lane :deploy do |options|
|
|
begin
|
|
select_xcode
|
|
|
|
decode_distribution_certificate
|
|
set_up_keychain
|
|
|
|
# parameters are passed from Apple App Store Connect integration: https://gitlab.protontech.ch/apple/inbox/mail/-/settings/integrations
|
|
app_store_connect_api_key
|
|
|
|
get_xcode_profile
|
|
|
|
latest_build_number = get_latest_build_number
|
|
new_build_number = latest_build_number + 1
|
|
increment_build_number(build_number: new_build_number)
|
|
|
|
build_app(
|
|
scheme: options[:scheme],
|
|
clean: true,
|
|
output_directory: "outputs/",
|
|
export_method: "app-store",
|
|
xcargs: "-skipPackagePluginValidation"
|
|
)
|
|
|
|
sentry_debug_files_upload
|
|
|
|
upload_to_testflight(
|
|
team_name: "Proton Technologies AG",
|
|
skip_waiting_for_build_processing: true
|
|
)
|
|
|
|
add_tag_and_push(new_build_number)
|
|
ensure
|
|
tear_down_keychain
|
|
end
|
|
end
|
|
end
|