88module 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
0 commit comments