Skip to content

Commit ee3cb2d

Browse files
committed
Update automation setup multi-suite Test Analytics
- Inject Test Analytics environment variables via Fastlane in CI, so we don't need to jump through configuration hoops. - From Buildkite, make user the token for the current suite is exported as `BUILDKITE_ANALYTICS_TOKEN`, so Fastlane can inject it. - Remove now redundant env var declarations in the `xctestplan` files, so we don't need to maintain duplicated versions of them.
1 parent 3faab35 commit ee3cb2d

File tree

6 files changed

+25
-66
lines changed

6 files changed

+25
-66
lines changed

.buildkite/commands/run-ui-tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ IOS_VERSION=$3
66

77
echo "Running $TEST_NAME on $DEVICE for iOS $IOS_VERSION"
88

9+
# Run this at the start to fail early if value not available
10+
echo '--- :test-analytics: Configuring Test Analytics'
11+
if [[ $DEVICE =~ ^iPhone ]]; then
12+
export BUILDKITE_ANALYTICS_TOKEN=$BUILDKITE_ANALYTICS_TOKEN_UI_TESTS_IPHONE
13+
else
14+
export BUILDKITE_ANALYTICS_TOKEN=$BUILDKITE_ANALYTICS_TOKEN_UI_TESTS_IPAD
15+
fi
16+
917
# Workaround for https://github.com/Automattic/buildkite-ci/issues/79
1018
echo "--- :rubygems: Fixing Ruby Setup"
1119
gem install bundler

.buildkite/commands/run-unit-tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash -eu
22

3+
# Run this at the start to fail early if value not available
4+
echo '--- :test-analytics: Configuring Test Analytics'
5+
export BUILDKITE_ANALYTICS_TOKEN=$BUILDKITE_ANALYTICS_TOKEN_UNIT_TESTS
6+
37
echo "--- 📦 Downloading Build Artifacts"
48
buildkite-agent artifact download build-products.tar .
59
tar -xf build-products.tar

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,7 @@
24882488
31FE28C125E6D338003519F2 /* LearnMoreTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LearnMoreTableViewCell.swift; sourceTree = "<group>"; };
24892489
31FE28C725E6D384003519F2 /* LearnMoreTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LearnMoreTableViewCell.xib; sourceTree = "<group>"; };
24902490
33035144757869DE5E4DC88A /* Pods-WooCommerce.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WooCommerce.release.xcconfig"; path = "../Pods/Target Support Files/Pods-WooCommerce/Pods-WooCommerce.release.xcconfig"; sourceTree = "<group>"; };
2491+
3F271A9728A2684400E656AE /* UITests.xctestplan */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = UITests.xctestplan; sourceTree = "<group>"; };
24912492
3F58701E281B947E004F7556 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
24922493
3F587020281B9494004F7556 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
24932494
3F587027281B9C19004F7556 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
@@ -3192,7 +3193,6 @@
31923193
CCDC49CE23FFFFF4003166BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
31933194
CCDC49EC24000533003166BA /* TestCredentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestCredentials.swift; sourceTree = "<group>"; };
31943195
CCDC49F1240060F3003166BA /* UnitTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = UnitTests.xctestplan; path = WooCommerceTests/UnitTests.xctestplan; sourceTree = SOURCE_ROOT; };
3195-
CCDC49F224006130003166BA /* UITests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = UITests.xctestplan; path = WooCommerceUITests/UITests.xctestplan; sourceTree = SOURCE_ROOT; };
31963196
CCE4CD162667EBB100E09FD4 /* ShippingLabelPaymentMethodsViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelPaymentMethodsViewModelTests.swift; sourceTree = "<group>"; };
31973197
CCE4CD272669324300E09FD4 /* ShippingLabelPaymentMethodsTopBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelPaymentMethodsTopBanner.swift; sourceTree = "<group>"; };
31983198
CCEC256927B581E800EF9FA3 /* ProductVariationFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductVariationFormatter.swift; sourceTree = "<group>"; };
@@ -6987,8 +6987,8 @@
69876987
CCDC49CB23FFFFF4003166BA /* WooCommerceUITests */ = {
69886988
isa = PBXGroup;
69896989
children = (
6990+
3F271A9728A2684400E656AE /* UITests.xctestplan */,
69906991
800A5B9C275623E9009DE2CD /* Flows */,
6991-
CCDC49F224006130003166BA /* UITests.xctestplan */,
69926992
CCDC49D9240000B7003166BA /* Tests */,
69936993
CCFC00B623E9BD5500157A78 /* Mocks */,
69946994
CCDC49D8240000A5003166BA /* Utils */,

WooCommerce/WooCommerceTests/UnitTests.xctestplan

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,7 @@
1717
}
1818
],
1919
"environmentVariableEntries" : [
20-
{
21-
"key" : "BUILDKITE_ANALYTICS_TOKEN",
22-
"value" : "$(BUILDKITE_ANALYTICS_TOKEN)"
23-
},
24-
{
25-
"key" : "BUILDKITE_BRANCH",
26-
"value" : "$(BUILDKITE_BRANCH)"
27-
},
28-
{
29-
"key" : "BUILDKITE_BUILD_ID",
30-
"value" : "$(BUILDKITE_BUILD_ID)"
31-
},
32-
{
33-
"key" : "BUILDKITE_BUILD_NUMBER",
34-
"value" : "$(BUILDKITE_BUILD_NUMBER)"
35-
},
36-
{
37-
"key" : "BUILDKITE_BUILD_URL",
38-
"value" : "$(BUILDKITE_BUILD_URL)"
39-
},
40-
{
41-
"key" : "BUILDKITE_COMMIT",
42-
"value" : "$(BUILDKITE_COMMIT)"
43-
},
44-
{
45-
"key" : "BUILDKITE_JOB_ID",
46-
"value" : "$(BUILDKITE_JOB_ID)"
47-
},
48-
{
49-
"key" : "BUILDKITE_MESSAGE",
50-
"value" : "$(BUILDKITE_MESSAGE)"
51-
}
20+
5221
],
5322
"language" : "en",
5423
"region" : "US",

WooCommerce/WooCommerceUITests/UITests.xctestplan

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,20 @@
44
"id" : "DA512AA1-66D1-4829-BC02-EEFD0E226DE7",
55
"name" : "Configuration 1",
66
"options" : {
7+
"environmentVariableEntries" : [
78

9+
],
10+
"targetForVariableExpansion" : {
11+
"containerPath" : "container:WooCommerce.xcodeproj",
12+
"identifier" : "B56DB3C52049BFAA00D4AA8E",
13+
"name" : "WooCommerce"
14+
}
815
}
916
}
1017
],
1118
"defaultOptions" : {
1219
"environmentVariableEntries" : [
13-
{
14-
"key" : "BUILDKITE_ANALYTICS_TOKEN",
15-
"value" : "$BUILDKITE_ANALYTICS_TOKEN"
16-
},
17-
{
18-
"key" : "BUILDKITE_BRANCH",
19-
"value" : "$(BUILDKITE_BRANCH)"
20-
},
21-
{
22-
"key" : "BUILDKITE_BUILD_ID",
23-
"value" : "$(BUILDKITE_BUILD_ID)"
24-
},
25-
{
26-
"key" : "BUILDKITE_BUILD_NUMBER",
27-
"value" : "$(BUILDKITE_BUILD_NUMBER)"
28-
},
29-
{
30-
"key" : "BUILDKITE_BUILD_URL",
31-
"value" : "$(BUILDKITE_BUILD_URL)"
32-
},
33-
{
34-
"key" : "BUILDKITE_COMMIT",
35-
"value" : "$(BUILDKITE_COMMIT)"
36-
},
37-
{
38-
"key" : "BUILDKITE_JOB_ID",
39-
"value" : "$(BUILDKITE_JOB_ID)"
40-
},
41-
{
42-
"key" : "BUILDKITE_MESSAGE",
43-
"value" : "$(BUILDKITE_MESSAGE)"
44-
}
20+
4521
],
4622
"testRepetitionMode" : "retryOnFailure"
4723
},

fastlane/Fastfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,8 @@ lane :test_without_building do |options|
10481048
UI.user_error!("Unable to find .xctestrun file at #{xctestrun_path}")
10491049
end
10501050

1051+
inject_buildkite_analytics_environment(xctestrun_path: xctestrun_path) if buildkite_ci?
1052+
10511053
run_tests(
10521054
workspace: 'WooCommerce.xcworkspace',
10531055
scheme: TEST_SCHEME,

0 commit comments

Comments
 (0)