Skip to content

Commit 9bf2a29

Browse files
authored
Report to dedicated suites for unit, UI iPhone, and UI iPad (#7490)
2 parents db28955 + 7d068e3 commit 9bf2a29

File tree

8 files changed

+72
-72
lines changed

8 files changed

+72
-72
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

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ Metrics/BlockLength:
22
Exclude:
33
- fastlane/Fastfile
44

5+
Metrics/MethodLength:
6+
Max: 20
7+
58
Style/AsciiComments:
69
Exclude:
710
- fastlane/Fastfile

WooCommerce.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 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 */,
@@ -11321,7 +11321,7 @@
1132111321
repositoryURL = "https://github.com/buildkite/test-collector-swift";
1132211322
requirement = {
1132311323
kind = upToNextMajorVersion;
11324-
minimumVersion = 0.1.1;
11324+
minimumVersion = 0.3.0;
1132511325
};
1132611326
};
1132711327
3FF2247126706AA3008FFA87 /* XCRemoteSwiftPackageReference "ScreenObject" */ = {

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: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ SCREENSHOT_DEVICES = [
2828
MAIN_BUNDLE_IDENTIFIERS = %w[com.automattic.woocommerce].freeze # Registered in our main account, for development and AppStore
2929
ALPHA_BUNDLE_IDENTIFIERS = %w[com.automattic.alpha.woocommerce].freeze # Registered in our Enterprise account, for App Center / Installable Builds
3030

31+
TEST_SCHEME = 'WooCommerce'
32+
3133
# List of `.strings` files manually maintained by developers (as opposed to being automatically extracted from the code)
3234
# which we will merge into the main `Localizable.strings` file imported by GlotPress, then extract back once we download the translations.
3335
#
@@ -556,7 +558,7 @@ platform :ios do
556558
lane :build_for_testing do |options|
557559
run_tests(
558560
workspace: 'WooCommerce.xcworkspace',
559-
scheme: 'WooCommerce',
561+
scheme: TEST_SCHEME,
560562
derived_data_path: 'DerivedData',
561563
build_for_testing: true,
562564
device: options[:device],
@@ -1042,11 +1044,15 @@ lane :test_without_building do |options|
10421044
e.include?(options[:name])
10431045
end.first
10441046

1045-
UI.user_error!('Unable to find .xctestrun file') unless !xctestrun_path.nil? && File.exist?((xctestrun_path))
1047+
unless !xctestrun_path.nil? && File.exist?((xctestrun_path))
1048+
UI.user_error!("Unable to find .xctestrun file at #{xctestrun_path}")
1049+
end
1050+
1051+
inject_buildkite_analytics_environment(xctestrun_path: xctestrun_path) if buildkite_ci?
10461052

10471053
run_tests(
10481054
workspace: 'WooCommerce.xcworkspace',
1049-
scheme: 'WooCommerce',
1055+
scheme: TEST_SCHEME,
10501056
device: options[:device],
10511057
deployment_target_version: options[:ios_version],
10521058
test_without_building: true,
@@ -1101,3 +1107,37 @@ def trigger_buildkite_release_build(branch:, beta:)
11011107
pipeline_file: 'release-builds.yml'
11021108
)
11031109
end
1110+
1111+
def inject_buildkite_analytics_environment(xctestrun_path:)
1112+
require 'plist'
1113+
1114+
xctestrun = Plist.parse_xml(xctestrun_path)
1115+
xctestrun['TestConfigurations'].each do |configuration|
1116+
configuration['TestTargets'].each do |target|
1117+
TEST_ANALYTICS_ENVIRONMENT.each do |key|
1118+
value = ENV.fetch(key)
1119+
next if value.nil?
1120+
1121+
target['EnvironmentVariables'][key] = value
1122+
end
1123+
end
1124+
end
1125+
1126+
File.write(xctestrun_path, Plist::Emit.dump(xctestrun))
1127+
end
1128+
1129+
def buildkite_ci?
1130+
ENV.fetch('BUILDKITE', false)
1131+
end
1132+
1133+
# https://buildkite.com/docs/test-analytics/ci-environments
1134+
TEST_ANALYTICS_ENVIRONMENT = %w[
1135+
BUILDKITE_ANALYTICS_TOKEN
1136+
BUILDKITE_BUILD_ID
1137+
BUILDKITE_BUILD_NUMBER
1138+
BUILDKITE_JOB_ID
1139+
BUILDKITE_BRANCH
1140+
BUILDKITE_COMMIT
1141+
BUILDKITE_MESSAGE
1142+
BUILDKITE_BUILD_URL
1143+
].freeze

0 commit comments

Comments
 (0)