Skip to content

Commit 53147d9

Browse files
committed
Update Fastfile with automation to inject Buildkite token
1 parent 877f430 commit 53147d9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

fastlane/Fastfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,11 @@ lane :test_without_building do |options|
10421042
e.include?(options[:name])
10431043
end.first
10441044

1045+
# FIXME: I do realize the variable is called "test plan path" but we're
1046+
# actually dealing with an `xctestrun`. I'll rename them all once established
1047+
# this approach works
1048+
add_buildkite_analytics_token(xctestrun_path: testPlanPath)
1049+
10451050
UI.user_error!('Unable to find .xctestrun file') unless !testPlanPath.nil? && File.exist?((testPlanPath))
10461051

10471052
run_tests(
@@ -1101,3 +1106,20 @@ def trigger_buildkite_release_build(branch:, beta:)
11011106
pipeline_file: 'release-builds.yml'
11021107
)
11031108
end
1109+
1110+
def add_buildkite_analytics_token(xctestrun_path:)
1111+
require 'plist'
1112+
1113+
token_key = 'BUILDKITE_ANALYTICS_TOKEN'
1114+
token = ENV[token_key]
1115+
return if token.nil?
1116+
1117+
xctestrun = Plist.parse_xml(xctestrun_path)
1118+
xctestrun['TestConfigurations'].each do |configuration|
1119+
configuration['TestTargets'].each do |target|
1120+
target['EnvironmentVariables'][token_key] = token
1121+
end
1122+
end
1123+
1124+
File.write(xctestrun_path, Plist::Emit.dump(xctestrun))
1125+
end

0 commit comments

Comments
 (0)