Skip to content

Commit d746980

Browse files
committed
Make rubocop almost happy
1 parent f05a198 commit d746980

4 files changed

Lines changed: 264 additions & 241 deletions

File tree

Lines changed: 97 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,106 @@
1+
require "fastlane/action"
2+
require "fastlane_core/configuration/config_item"
3+
require "octokit"
4+
require_relative "../helper/asana_helper"
5+
require_relative "../helper/ddg_apple_automation_helper"
6+
require_relative "../helper/git_helper"
7+
18
module Fastlane
2-
module Actions
3-
class TdsPerfTestAction < Action
4-
def self.run(params)
5-
UI.message("Starting TDS Performance Testing...")
6-
7-
# Create temporary directory
8-
tmp_dir = "#{ENV['TMPDIR']}/tds-perf-testing"
9-
10-
begin
11-
Actions.sh("mkdir -p \"#{tmp_dir}\"")
9+
module Actions
10+
class TdsPerfTestAction < Action
11+
def self.run(params)
12+
UI.message("Starting TDS Performance Testing...")
13+
14+
# Create temporary directory
15+
tmp_dir = "#{ENV.fetch('TMPDIR', nil)}/tds-perf-testing"
16+
17+
begin
18+
Actions.sh("mkdir -p \"#{tmp_dir}\"")
19+
20+
# Navigate to temp directory
21+
Dir.chdir(tmp_dir) do
22+
# Clone repository
23+
Actions.sh("git clone --depth=1 git@github.com:duckduckgo/TrackerRadarKit.git")
24+
25+
# Navigate to cloned repository
26+
Dir.chdir("TrackerRadarKit") do
27+
# Set environment variables and run test
28+
test_command = [
29+
"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]}",
34+
"xcodebuild test-without-building",
35+
"-scheme TrackerRadarKit",
36+
"-destination 'platform=macOS'",
37+
"-only-testing:TrackerRadarKitPerformanceTests/NextTrackerDataSetPerformanceTests"
38+
].join(" ")
1239

13-
# Navigate to temp directory
14-
Dir.chdir(tmp_dir) do
15-
# Clone repository
16-
Actions.sh("git clone --depth=1 git@github.com:duckduckgo/TrackerRadarKit.git")
17-
18-
# Navigate to cloned repository
19-
Dir.chdir("TrackerRadarKit") do
20-
# Set environment variables and run test
21-
test_command = [
22-
"env",
23-
"TEST_RUNNER_TDS_UT_FILE_NAME=#{params[:ut_file_name]}",
24-
"TEST_RUNNER_TDS_UT_URL=#{params[:ut_url]}",
25-
"TEST_RUNNER_TDS_REF_FILE_NAME=#{params[:ref_file_name]}",
26-
"TEST_RUNNER_TDS_REF_URL=#{params[:ref_url]}",
27-
"xcodebuild test-without-building",
28-
"-scheme TrackerRadarKit",
29-
"-destination 'platform=macOS'",
30-
"-only-testing:TrackerRadarKitPerformanceTests/NextTrackerDataSetPerformanceTests"
31-
].join(" ")
32-
33-
begin
34-
Actions.sh(test_command)
35-
result = true
36-
rescue => ex
37-
UI.error("Performance tests failed: #{ex}")
38-
result = false
39-
end
40+
begin
41+
Actions.sh(test_command)
42+
true
43+
rescue StandardError => e
44+
UI.error("Performance tests failed: #{e}")
45+
false
4046
end
4147
end
42-
ensure
43-
# Cleanup step - always executed regardless of success or failure
44-
UI.message("Cleaning up temporary test directory...")
45-
Actions.sh("rm -rf \"#{tmp_dir}\"")
4648
end
49+
ensure
50+
# Cleanup step - always executed regardless of success or failure
51+
UI.message("Cleaning up temporary test directory...")
52+
Actions.sh("rm -rf \"#{tmp_dir}\"")
4753
end
48-
49-
def self.description
50-
"Runs performance tests for Tracker Radar Kit with specified TDS files"
51-
end
52-
53-
def self.authors
54-
["Your Name"]
55-
end
56-
57-
def self.available_options
58-
[
59-
FastlaneCore::ConfigItem.new(
60-
key: :ut_file_name,
61-
env_name: "TEST_RUNNER_TDS_UT_FILE_NAME",
62-
description: "The file name for the under-test TDS",
63-
type: String,
64-
optional: false
65-
),
66-
FastlaneCore::ConfigItem.new(
67-
key: :ut_url,
68-
env_name: "TEST_RUNNER_TDS_UT_URL",
69-
description: "The URL for the under-test TDS",
70-
type: String,
71-
optional: false
72-
),
73-
FastlaneCore::ConfigItem.new(
74-
key: :ref_file_name,
75-
env_name: "TEST_RUNNER_TDS_REF_FILE_NAME",
76-
description: "The file name for the reference TDS",
77-
type: String,
78-
optional: false
79-
),
80-
FastlaneCore::ConfigItem.new(
81-
key: :ref_url,
82-
env_name: "TEST_RUNNER_TDS_REF_URL",
83-
description: "The URL for the reference TDS",
84-
type: String,
85-
optional: false
86-
)
87-
]
88-
end
89-
90-
def self.is_supported?(platform)
91-
[:ios, :mac].include?(platform)
92-
end
93-
94-
def self.return_value
95-
"Returns true if tests passed, false otherwise"
96-
end
54+
end
55+
56+
def self.description
57+
"Runs performance tests for Tracker Radar Kit with specified TDS files"
58+
end
59+
60+
def self.authors
61+
["Your Name"]
62+
end
63+
64+
def self.available_options
65+
[
66+
FastlaneCore::ConfigItem.new(
67+
key: :ut_file_name,
68+
env_name: "TEST_RUNNER_TDS_UT_FILE_NAME",
69+
description: "The file name for the under-test TDS",
70+
type: String,
71+
optional: false
72+
),
73+
FastlaneCore::ConfigItem.new(
74+
key: :ut_url,
75+
env_name: "TEST_RUNNER_TDS_UT_URL",
76+
description: "The URL for the under-test TDS",
77+
type: String,
78+
optional: false
79+
),
80+
FastlaneCore::ConfigItem.new(
81+
key: :ref_file_name,
82+
env_name: "TEST_RUNNER_TDS_REF_FILE_NAME",
83+
description: "The file name for the reference TDS",
84+
type: String,
85+
optional: false
86+
),
87+
FastlaneCore::ConfigItem.new(
88+
key: :ref_url,
89+
env_name: "TEST_RUNNER_TDS_REF_URL",
90+
description: "The URL for the reference TDS",
91+
type: String,
92+
optional: false
93+
)
94+
]
95+
end
96+
97+
def self.is_supported?(platform)
98+
[:ios, :mac].include?(platform)
99+
end
100+
101+
def self.return_value
102+
"Returns true if tests passed, false otherwise"
97103
end
98104
end
99105
end
100-
106+
end

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

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

910
module Fastlane
1011
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
@@ -227,19 +228,7 @@ def self.create_release_branch(platform, version)
227228
end
228229

229230
def self.update_embedded_files(platform, other_action)
230-
tds_perf_test_result = other_action.tds_perf_test(
231-
ut_file_name: "your_ut_file_name.json",
232-
ut_url: "https://example.com/your_ut_file.json",
233-
ref_file_name: "your_ref_file_name.json",
234-
ref_url: "https://example.com/your_ref_file.json"
235-
)
236-
237-
unless tds_perf_test_result
238-
UI.important("TDS performance tests failed. Proceeding with caution.")
239-
# Optionally, you could abort here if you want to make passing tests mandatory
240-
# UI.abort_with_message!("TDS performance tests failed. Aborting embedded file update.")
241-
end
242-
231+
Helper::PerfTestingHelper.test_tds_embedded_files(other_action)
243232
Actions.sh("./scripts/update_embedded.sh")
244233

245234
# Verify no unexpected files were modified
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require "fastlane_core/configuration/config_item"
2+
require "fastlane_core/ui/ui"
3+
require "httparty"
4+
require "rexml/document"
5+
require "semantic"
6+
require_relative "github_actions_helper"
7+
require_relative "git_helper"
8+
9+
module Fastlane
10+
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
11+
12+
module Helper
13+
class PerfTestingHelper
14+
def self.test_tds_embedded_files(other_action)
15+
tds_perf_test_result = other_action.tds_perf_test(
16+
ut_file_name: "your_ut_file_name.json",
17+
ut_url: "https://example.com/your_ut_file.json",
18+
ref_file_name: "your_ref_file_name.json",
19+
ref_url: "https://example.com/your_ref_file.json"
20+
)
21+
22+
unless tds_perf_test_result
23+
UI.important("TDS performance tests failed. Proceeding with caution.")
24+
end
25+
end
26+
end
27+
end
28+
end

0 commit comments

Comments
 (0)