Skip to content

Commit 4a9bb16

Browse files
committed
Refactor
1 parent d746980 commit 4a9bb16

4 files changed

Lines changed: 45 additions & 47 deletions

File tree

lib/fastlane/plugin/ddg_apple_automation/actions/tds_perf_test.rb

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,40 @@
88
module Fastlane
99
module Actions
1010
class TdsPerfTestAction < Action
11+
# Define platform-specific constants
12+
IOS_TEST_PARAMS = {
13+
ut_file_name: "ios-tds.json",
14+
ut_url: "https://staticcdn.duckduckgo.com/trackerblocking/v5/current/ios-tds.json",
15+
ref_file_name: "trackerData.json",
16+
ref_url: "https://github.com/duckduckgo/apple-browsers/tree/main/iOS/Core"
17+
}.freeze
18+
19+
MAC_TEST_PARAMS = {
20+
ut_file_name: "macos-tds.json",
21+
ut_url: "https://staticcdn.duckduckgo.com/trackerblocking/v6/current/",
22+
ref_file_name: "trackerData.json",
23+
ref_url: "https://github.com/duckduckgo/apple-browsers/tree/main/macOS/DuckDuckGo/ContentBlocker"
24+
}.freeze
25+
1126
def self.run(params)
1227
UI.message("Starting TDS Performance Testing...")
1328

29+
# Determine platform and set default parameters if needed
30+
platform = lane_context[SharedValues::PLATFORM_NAME]
31+
default_params = platform == :ios ? IOS_TEST_PARAMS : MAC_TEST_PARAMS
32+
33+
# Use provided parameters or defaults
34+
ut_file_name = params[:ut_file_name] || default_params[:ut_file_name]
35+
ut_url = params[:ut_url] || default_params[:ut_url]
36+
ref_file_name = params[:ref_file_name] || default_params[:ref_file_name]
37+
ref_url = params[:ref_url] || default_params[:ref_url]
38+
39+
UI.message("Using TDS parameters for #{platform} platform:")
40+
UI.message(" Under-test file: #{ut_file_name}")
41+
UI.message(" Under-test URL: #{ut_url}")
42+
UI.message(" Reference file: #{ref_file_name}")
43+
UI.message(" Reference URL: #{ref_url}")
44+
1445
# Create temporary directory
1546
tmp_dir = "#{ENV.fetch('TMPDIR', nil)}/tds-perf-testing"
1647

@@ -27,10 +58,10 @@ def self.run(params)
2758
# Set environment variables and run test
2859
test_command = [
2960
"env",
30-
"TEST_RUNNER_TDS_UT_FILE_NAME=#{params[:ut_file_name]}",
31-
"TEST_RUNNER_TDS_UT_URL=#{params[:ut_url]}",
32-
"TEST_RUNNER_TDS_REF_FILE_NAME=#{params[:ref_file_name]}",
33-
"TEST_RUNNER_TDS_REF_URL=#{params[:ref_url]}",
61+
"TEST_RUNNER_TDS_UT_FILE_NAME=#{ut_file_name}",
62+
"TEST_RUNNER_TDS_UT_URL=#{ut_url}",
63+
"TEST_RUNNER_TDS_REF_FILE_NAME=#{ref_file_name}",
64+
"TEST_RUNNER_TDS_REF_URL=#{ref_url}",
3465
"xcodebuild test-without-building",
3566
"-scheme TrackerRadarKit",
3667
"-destination 'platform=macOS'",
@@ -58,7 +89,7 @@ def self.description
5889
end
5990

6091
def self.authors
61-
["Your Name"]
92+
["Lorenzo Mattei"]
6293
end
6394

6495
def self.available_options
@@ -68,28 +99,28 @@ def self.available_options
6899
env_name: "TEST_RUNNER_TDS_UT_FILE_NAME",
69100
description: "The file name for the under-test TDS",
70101
type: String,
71-
optional: false
102+
optional: true
72103
),
73104
FastlaneCore::ConfigItem.new(
74105
key: :ut_url,
75106
env_name: "TEST_RUNNER_TDS_UT_URL",
76107
description: "The URL for the under-test TDS",
77108
type: String,
78-
optional: false
109+
optional: true
79110
),
80111
FastlaneCore::ConfigItem.new(
81112
key: :ref_file_name,
82113
env_name: "TEST_RUNNER_TDS_REF_FILE_NAME",
83114
description: "The file name for the reference TDS",
84115
type: String,
85-
optional: false
116+
optional: true
86117
),
87118
FastlaneCore::ConfigItem.new(
88119
key: :ref_url,
89120
env_name: "TEST_RUNNER_TDS_REF_URL",
90121
description: "The URL for the reference TDS",
91122
type: String,
92-
optional: false
123+
optional: true
93124
)
94125
]
95126
end

lib/fastlane/plugin/ddg_apple_automation/helper/ddg_apple_automation_helper.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
require "semantic"
66
require_relative "github_actions_helper"
77
require_relative "git_helper"
8-
require_relative "perf_testing_helper"
98

109
module Fastlane
1110
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
@@ -228,7 +227,11 @@ def self.create_release_branch(platform, version)
228227
end
229228

230229
def self.update_embedded_files(platform, other_action)
231-
Helper::PerfTestingHelper.test_tds_embedded_files(other_action)
230+
tds_perf_test_result = other_action.tds_perf_test
231+
232+
unless tds_perf_test_result
233+
UI.important("TDS performance tests failed. Proceeding with caution.")
234+
end
232235
Actions.sh("./scripts/update_embedded.sh")
233236

234237
# Verify no unexpected files were modified

lib/fastlane/plugin/ddg_apple_automation/helper/perf_testing_helper.rb

Lines changed: 0 additions & 28 deletions
This file was deleted.

spec/tds_perf_test_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,6 @@
108108
:ref_url
109109
)
110110
end
111-
112-
it 'marks all parameters as required' do
113-
options = Fastlane::Actions::TdsPerfTestAction.available_options
114-
115-
options.each do |option|
116-
expect(option.optional).to be false
117-
end
118-
end
119111
end
120112

121113
describe '#is_supported?' do

0 commit comments

Comments
 (0)