makit 0.0.157 → 0.0.158
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +41 -41
- data/exe/makit +5 -5
- data/lib/makit/apache.rb +28 -28
- data/lib/makit/auto.rb +48 -48
- data/lib/makit/azure/blob_storage.rb +257 -257
- data/lib/makit/azure/cli.rb +284 -284
- data/lib/makit/cli/base.rb +17 -17
- data/lib/makit/cli/build_commands.rb +500 -500
- data/lib/makit/cli/generators/base_generator.rb +74 -74
- data/lib/makit/cli/generators/dotnet_generator.rb +50 -50
- data/lib/makit/cli/generators/generator_factory.rb +49 -49
- data/lib/makit/cli/generators/node_generator.rb +50 -50
- data/lib/makit/cli/generators/ruby_generator.rb +77 -77
- data/lib/makit/cli/generators/rust_generator.rb +50 -50
- data/lib/makit/cli/generators/templates/dotnet_templates.rb +167 -167
- data/lib/makit/cli/generators/templates/node_templates.rb +161 -161
- data/lib/makit/cli/generators/templates/ruby/gemfile.rb +26 -26
- data/lib/makit/cli/generators/templates/ruby/gemspec.rb +41 -41
- data/lib/makit/cli/generators/templates/ruby/main_lib.rb +33 -33
- data/lib/makit/cli/generators/templates/ruby/rakefile.rb +35 -35
- data/lib/makit/cli/generators/templates/ruby/readme.rb +63 -63
- data/lib/makit/cli/generators/templates/ruby/test.rb +39 -39
- data/lib/makit/cli/generators/templates/ruby/test_helper.rb +29 -29
- data/lib/makit/cli/generators/templates/ruby/version.rb +29 -29
- data/lib/makit/cli/generators/templates/rust_templates.rb +128 -128
- data/lib/makit/cli/main.rb +78 -78
- data/lib/makit/cli/pipeline_commands.rb +311 -311
- data/lib/makit/cli/project_commands.rb +868 -868
- data/lib/makit/cli/repository_commands.rb +661 -661
- data/lib/makit/cli/strategy_commands.rb +207 -207
- data/lib/makit/cli/utility_commands.rb +521 -521
- data/lib/makit/commands/factory.rb +359 -359
- data/lib/makit/commands/middleware/base.rb +73 -73
- data/lib/makit/commands/middleware/cache.rb +248 -248
- data/lib/makit/commands/middleware/command_logger.rb +312 -312
- data/lib/makit/commands/middleware/validator.rb +269 -269
- data/lib/makit/commands/request.rb +316 -316
- data/lib/makit/commands/result.rb +323 -323
- data/lib/makit/commands/runner.rb +386 -386
- data/lib/makit/commands/strategies/base.rb +171 -171
- data/lib/makit/commands/strategies/child_process.rb +162 -162
- data/lib/makit/commands/strategies/factory.rb +136 -136
- data/lib/makit/commands/strategies/synchronous.rb +139 -139
- data/lib/makit/commands.rb +50 -50
- data/lib/makit/configuration/dotnet_project.rb +48 -48
- data/lib/makit/configuration/gitlab_helper.rb +61 -61
- data/lib/makit/configuration/project.rb +292 -292
- data/lib/makit/configuration/rakefile_helper.rb +43 -43
- data/lib/makit/configuration/step.rb +34 -34
- data/lib/makit/configuration/timeout.rb +74 -74
- data/lib/makit/configuration.rb +21 -21
- data/lib/makit/content/default_gitignore.rb +7 -7
- data/lib/makit/content/default_gitignore.txt +225 -225
- data/lib/makit/content/default_rakefile.rb +13 -13
- data/lib/makit/content/gem_rakefile.rb +16 -16
- data/lib/makit/context.rb +1 -1
- data/lib/makit/data.rb +49 -49
- data/lib/makit/directories.rb +170 -170
- data/lib/makit/directory.rb +262 -262
- data/lib/makit/docs/files.rb +89 -89
- data/lib/makit/docs/rake.rb +102 -102
- data/lib/makit/dotnet/cli.rb +69 -69
- data/lib/makit/dotnet/project.rb +217 -217
- data/lib/makit/dotnet/solution.rb +38 -38
- data/lib/makit/dotnet/solution_classlib.rb +239 -239
- data/lib/makit/dotnet/solution_console.rb +264 -264
- data/lib/makit/dotnet/solution_maui.rb +354 -354
- data/lib/makit/dotnet/solution_wasm.rb +275 -275
- data/lib/makit/dotnet/solution_wpf.rb +304 -304
- data/lib/makit/dotnet.rb +102 -102
- data/lib/makit/email.rb +90 -90
- data/lib/makit/environment.rb +142 -142
- data/lib/makit/examples/runner.rb +370 -370
- data/lib/makit/exceptions.rb +45 -45
- data/lib/makit/fileinfo.rb +32 -32
- data/lib/makit/files.rb +43 -43
- data/lib/makit/gems.rb +40 -40
- data/lib/makit/git/cli.rb +78 -54
- data/lib/makit/git/repository.rb +100 -100
- data/lib/makit/git.rb +104 -104
- data/lib/makit/gitlab/pipeline.rb +857 -857
- data/lib/makit/gitlab/pipeline_service_impl.rb +1535 -1535
- data/lib/makit/gitlab_runner.rb +59 -59
- data/lib/makit/humanize.rb +218 -218
- data/lib/makit/indexer.rb +47 -47
- data/lib/makit/io/filesystem.rb +111 -111
- data/lib/makit/io/filesystem_service_impl.rb +337 -337
- data/lib/makit/lint.rb +212 -212
- data/lib/makit/logging/configuration.rb +309 -309
- data/lib/makit/logging/format_registry.rb +84 -84
- data/lib/makit/logging/formatters/base.rb +39 -39
- data/lib/makit/logging/formatters/console_formatter.rb +140 -140
- data/lib/makit/logging/formatters/json_formatter.rb +65 -65
- data/lib/makit/logging/formatters/plain_text_formatter.rb +71 -71
- data/lib/makit/logging/formatters/text_formatter.rb +64 -64
- data/lib/makit/logging/log_request.rb +119 -119
- data/lib/makit/logging/logger.rb +199 -199
- data/lib/makit/logging/sinks/base.rb +91 -91
- data/lib/makit/logging/sinks/console.rb +72 -72
- data/lib/makit/logging/sinks/file_sink.rb +92 -92
- data/lib/makit/logging/sinks/structured.rb +123 -123
- data/lib/makit/logging/sinks/unified_file_sink.rb +296 -296
- data/lib/makit/logging.rb +578 -578
- data/lib/makit/markdown.rb +75 -75
- data/lib/makit/mp/basic_object_mp.rb +17 -17
- data/lib/makit/mp/command_mp.rb +13 -13
- data/lib/makit/mp/command_request.mp.rb +17 -17
- data/lib/makit/mp/project_mp.rb +199 -199
- data/lib/makit/mp/string_mp.rb +205 -205
- data/lib/makit/nuget.rb +74 -74
- data/lib/makit/podman/podman.rb +458 -458
- data/lib/makit/podman/podman_service_impl.rb +1081 -1081
- data/lib/makit/port.rb +32 -32
- data/lib/makit/process.rb +377 -377
- data/lib/makit/protoc.rb +112 -112
- data/lib/makit/rake/cli.rb +196 -196
- data/lib/makit/rake/trace_controller.rb +174 -174
- data/lib/makit/rake.rb +81 -81
- data/lib/makit/ruby/cli.rb +185 -185
- data/lib/makit/ruby.rb +25 -25
- data/lib/makit/rubygems.rb +137 -0
- data/lib/makit/secrets/azure_key_vault.rb +322 -322
- data/lib/makit/secrets/azure_secrets.rb +183 -183
- data/lib/makit/secrets/local_secrets.rb +72 -72
- data/lib/makit/secrets/secrets_manager.rb +105 -105
- data/lib/makit/secrets.rb +16 -16
- data/lib/makit/serializer.rb +130 -130
- data/lib/makit/services/builder.rb +186 -186
- data/lib/makit/services/error_handler.rb +226 -226
- data/lib/makit/services/repository_manager.rb +367 -367
- data/lib/makit/services/validator.rb +112 -112
- data/lib/makit/setup/classlib.rb +101 -101
- data/lib/makit/setup/gem.rb +268 -268
- data/lib/makit/setup/pages.rb +11 -11
- data/lib/makit/setup/razorclasslib.rb +101 -101
- data/lib/makit/setup/runner.rb +54 -54
- data/lib/makit/setup.rb +5 -5
- data/lib/makit/show.rb +110 -110
- data/lib/makit/storage.rb +126 -126
- data/lib/makit/symbols.rb +175 -175
- data/lib/makit/task_info.rb +130 -130
- data/lib/makit/tasks/at_exit.rb +15 -15
- data/lib/makit/tasks/build.rb +22 -22
- data/lib/makit/tasks/bump.rb +7 -7
- data/lib/makit/tasks/clean.rb +13 -13
- data/lib/makit/tasks/configure.rb +10 -10
- data/lib/makit/tasks/format.rb +10 -10
- data/lib/makit/tasks/hook_manager.rb +443 -443
- data/lib/makit/tasks/info.rb +368 -368
- data/lib/makit/tasks/init.rb +49 -49
- data/lib/makit/tasks/integrate.rb +60 -56
- data/lib/makit/tasks/pull_incoming.rb +13 -13
- data/lib/makit/tasks/secrets.rb +7 -7
- data/lib/makit/tasks/setup.rb +16 -16
- data/lib/makit/tasks/sync.rb +14 -17
- data/lib/makit/tasks/tag.rb +27 -27
- data/lib/makit/tasks/task_monkey_patch.rb +81 -81
- data/lib/makit/tasks/test.rb +22 -22
- data/lib/makit/tasks/update.rb +18 -18
- data/lib/makit/tasks/version.rb +6 -6
- data/lib/makit/tasks.rb +24 -24
- data/lib/makit/test_cache.rb +239 -239
- data/lib/makit/tree.rb +37 -37
- data/lib/makit/v1/configuration/project_service_impl.rb +370 -370
- data/lib/makit/v1/git/git_repository_service_impl.rb +295 -295
- data/lib/makit/v1/makit.v1_pb.rb +35 -35
- data/lib/makit/v1/makit.v1_services_pb.rb +27 -27
- data/lib/makit/v1/services/repository_manager_service_impl.rb +572 -572
- data/lib/makit/version.rb +661 -503
- data/lib/makit/version_util.rb +21 -21
- data/lib/makit/wix.rb +95 -95
- data/lib/makit/yaml.rb +29 -29
- data/lib/makit/zip.rb +17 -17
- data/lib/makit copy.rb +44 -44
- data/lib/makit.rb +115 -114
- metadata +3 -2
|
@@ -1,186 +1,186 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "validator"
|
|
4
|
-
require_relative "repository_manager"
|
|
5
|
-
|
|
6
|
-
module Makit
|
|
7
|
-
module Services
|
|
8
|
-
# Service class responsible for build operations and make processes
|
|
9
|
-
# Handles the complex build workflow including repository setup and execution
|
|
10
|
-
class Builder
|
|
11
|
-
class << self
|
|
12
|
-
# Build a repository at a specific commit
|
|
13
|
-
#
|
|
14
|
-
# @param url [String] the git repository URL
|
|
15
|
-
# @param commit [String] the commit hash or "latest" for the most recent commit
|
|
16
|
-
# @param force [Boolean] whether to force rebuild even if cached result exists
|
|
17
|
-
# @return [Makit::V1::MakeResult] the build result with all command outputs
|
|
18
|
-
def make_repository(url, commit, force: false)
|
|
19
|
-
Validator.validate_url_parameter(url)
|
|
20
|
-
Validator.validate_commit_parameter(commit)
|
|
21
|
-
|
|
22
|
-
log_filename = get_log_filename(url, commit)
|
|
23
|
-
|
|
24
|
-
return load_existing_result(log_filename) if should_load_existing_result?(log_filename, force, commit)
|
|
25
|
-
|
|
26
|
-
execute_make_process(url, commit, log_filename)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Ensure .gitignore exists in the current directory
|
|
30
|
-
def ensure_gitignore
|
|
31
|
-
return if File.exist?(".gitignore")
|
|
32
|
-
|
|
33
|
-
Makit::LOGGER.info("added .gitignore file")
|
|
34
|
-
File.open(".gitignore", "w") do |file|
|
|
35
|
-
file.puts Makit::Content::GITIGNORE
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
|
|
41
|
-
# Get the log filename for storing build results
|
|
42
|
-
def get_log_filename(url, commit)
|
|
43
|
-
File.join(
|
|
44
|
-
Directories.get_log_directory(url),
|
|
45
|
-
commit,
|
|
46
|
-
"#{Makit::RUNTIME_IDENTIFIER}.#{Makit::DEVICE}.json"
|
|
47
|
-
)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Check if we should load an existing cached result
|
|
51
|
-
def should_load_existing_result?(log_filename, force, commit)
|
|
52
|
-
File.exist?(log_filename) && !force && commit != Validator::COMMIT_LATEST
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Load existing build result from cache
|
|
56
|
-
def load_existing_result(log_filename)
|
|
57
|
-
Makit::V1::MakeResult.decode_json(File.read(log_filename))
|
|
58
|
-
rescue StandardError
|
|
59
|
-
FileUtils.rm(log_filename)
|
|
60
|
-
nil
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Execute the complete make process
|
|
64
|
-
def execute_make_process(url, commit, log_filename)
|
|
65
|
-
commands = []
|
|
66
|
-
begin
|
|
67
|
-
commands = setup_repository_for_build(url, commit, log_filename)
|
|
68
|
-
make_result = build_make_result(url, commit, commands)
|
|
69
|
-
save_make_result(make_result, log_filename)
|
|
70
|
-
make_result
|
|
71
|
-
rescue StandardError => e
|
|
72
|
-
handle_make_error(e, url, commit, commands)
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# Set up repository for build process
|
|
77
|
-
def setup_repository_for_build(url, commit, log_filename)
|
|
78
|
-
commands = initialize_repository_commands(url)
|
|
79
|
-
|
|
80
|
-
clone_dir = RepositoryManager.validate_clone_directory(url)
|
|
81
|
-
resolved_commit = resolve_commit_reference(commit, clone_dir, commands, log_filename, url)
|
|
82
|
-
prepare_make_directory(url, resolved_commit, clone_dir, commands)
|
|
83
|
-
|
|
84
|
-
commands
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Initialize repository commands (clone or pull)
|
|
88
|
-
def initialize_repository_commands(url)
|
|
89
|
-
RepositoryManager.clone_or_pull_repository(url).flatten
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Resolve commit reference (handle "latest" commit)
|
|
93
|
-
def resolve_commit_reference(commit, clone_dir, commands, log_filename, url)
|
|
94
|
-
return commit unless commit == Validator::COMMIT_LATEST
|
|
95
|
-
|
|
96
|
-
latest_commit = RepositoryManager.get_latest_commit(clone_dir, commands)
|
|
97
|
-
# Update log filename with resolved commit hash
|
|
98
|
-
log_filename.replace(
|
|
99
|
-
File.join(
|
|
100
|
-
Directories.get_log_directory(url),
|
|
101
|
-
latest_commit,
|
|
102
|
-
"#{Makit::RUNTIME_IDENTIFIER}.#{Makit::DEVICE}.json"
|
|
103
|
-
)
|
|
104
|
-
)
|
|
105
|
-
latest_commit
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
# Prepare make directory with repository clone
|
|
109
|
-
def prepare_make_directory(url, commit, clone_dir, commands)
|
|
110
|
-
make_dir = Directories.get_make_commit_directory(url, commit)
|
|
111
|
-
FileUtils.rm_rf(make_dir)
|
|
112
|
-
|
|
113
|
-
clone_command = Makit::Commands::Runner.default.execute("git clone #{clone_dir} #{make_dir}")
|
|
114
|
-
commands << clone_command
|
|
115
|
-
|
|
116
|
-
return if Dir.exist?(make_dir)
|
|
117
|
-
|
|
118
|
-
raise Makit::CloneError, "failed to clone repository: #{url} to #{make_dir}"
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# Build the make result by executing all build steps
|
|
122
|
-
def build_make_result(url, commit, commands)
|
|
123
|
-
Dir.chdir(Directories.get_make_commit_directory(url, commit)) do
|
|
124
|
-
execute_git_commands(commit, commands)
|
|
125
|
-
execute_build_commands(commands)
|
|
126
|
-
|
|
127
|
-
make_result = create_make_result_object(url, commit)
|
|
128
|
-
commands.flatten.each { |command| make_result.commands << command }
|
|
129
|
-
make_result
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
# Execute git-specific commands for the build
|
|
134
|
-
def execute_git_commands(commit, commands)
|
|
135
|
-
commands << Makit::Commands::Runner.default.execute("git reset --hard #{commit}")
|
|
136
|
-
commands << Makit::Commands::Runner.default.execute("git log -n 1")
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
# Execute build commands (bundle, rake, etc.)
|
|
140
|
-
def execute_build_commands(commands)
|
|
141
|
-
commands << Makit::Commands::Runner.default.execute("bundle install") if File.exist?("Gemfile")
|
|
142
|
-
|
|
143
|
-
return unless File.exist?("Rakefile") || File.exist?("rakefile.rb")
|
|
144
|
-
|
|
145
|
-
commands << Makit::Commands::Runner.default.execute("rake default")
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
# Create the make result object
|
|
149
|
-
def create_make_result_object(url, commit)
|
|
150
|
-
Makit::V1::MakeResult.new(
|
|
151
|
-
repository: url,
|
|
152
|
-
commit: commit,
|
|
153
|
-
branch: "?",
|
|
154
|
-
tag: "?",
|
|
155
|
-
device: Makit::DEVICE,
|
|
156
|
-
runtime_identifier: Makit::RUNTIME_IDENTIFIER,
|
|
157
|
-
)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
# Save make result to file
|
|
161
|
-
def save_make_result(make_result, log_filename)
|
|
162
|
-
FileUtils.mkdir_p(File.dirname(log_filename))
|
|
163
|
-
File.write(log_filename, make_result.to_json)
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
# Handle make process errors
|
|
167
|
-
def handle_make_error(error, url, commit, commands)
|
|
168
|
-
message_parts = [
|
|
169
|
-
"error raised attempting to make repository: #{url} commit: #{commit}",
|
|
170
|
-
"",
|
|
171
|
-
error.message,
|
|
172
|
-
error.backtrace.join("\\n"),
|
|
173
|
-
"",
|
|
174
|
-
"commands:",
|
|
175
|
-
]
|
|
176
|
-
|
|
177
|
-
commands.flatten.each do |command|
|
|
178
|
-
message_parts << Makit::Humanize.get_command_details(command)
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
raise Makit::BuildError, message_parts.join("\\n")
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "validator"
|
|
4
|
+
require_relative "repository_manager"
|
|
5
|
+
|
|
6
|
+
module Makit
|
|
7
|
+
module Services
|
|
8
|
+
# Service class responsible for build operations and make processes
|
|
9
|
+
# Handles the complex build workflow including repository setup and execution
|
|
10
|
+
class Builder
|
|
11
|
+
class << self
|
|
12
|
+
# Build a repository at a specific commit
|
|
13
|
+
#
|
|
14
|
+
# @param url [String] the git repository URL
|
|
15
|
+
# @param commit [String] the commit hash or "latest" for the most recent commit
|
|
16
|
+
# @param force [Boolean] whether to force rebuild even if cached result exists
|
|
17
|
+
# @return [Makit::V1::MakeResult] the build result with all command outputs
|
|
18
|
+
def make_repository(url, commit, force: false)
|
|
19
|
+
Validator.validate_url_parameter(url)
|
|
20
|
+
Validator.validate_commit_parameter(commit)
|
|
21
|
+
|
|
22
|
+
log_filename = get_log_filename(url, commit)
|
|
23
|
+
|
|
24
|
+
return load_existing_result(log_filename) if should_load_existing_result?(log_filename, force, commit)
|
|
25
|
+
|
|
26
|
+
execute_make_process(url, commit, log_filename)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Ensure .gitignore exists in the current directory
|
|
30
|
+
def ensure_gitignore
|
|
31
|
+
return if File.exist?(".gitignore")
|
|
32
|
+
|
|
33
|
+
Makit::LOGGER.info("added .gitignore file")
|
|
34
|
+
File.open(".gitignore", "w") do |file|
|
|
35
|
+
file.puts Makit::Content::GITIGNORE
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
# Get the log filename for storing build results
|
|
42
|
+
def get_log_filename(url, commit)
|
|
43
|
+
File.join(
|
|
44
|
+
Directories.get_log_directory(url),
|
|
45
|
+
commit,
|
|
46
|
+
"#{Makit::RUNTIME_IDENTIFIER}.#{Makit::DEVICE}.json"
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Check if we should load an existing cached result
|
|
51
|
+
def should_load_existing_result?(log_filename, force, commit)
|
|
52
|
+
File.exist?(log_filename) && !force && commit != Validator::COMMIT_LATEST
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Load existing build result from cache
|
|
56
|
+
def load_existing_result(log_filename)
|
|
57
|
+
Makit::V1::MakeResult.decode_json(File.read(log_filename))
|
|
58
|
+
rescue StandardError
|
|
59
|
+
FileUtils.rm(log_filename)
|
|
60
|
+
nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Execute the complete make process
|
|
64
|
+
def execute_make_process(url, commit, log_filename)
|
|
65
|
+
commands = []
|
|
66
|
+
begin
|
|
67
|
+
commands = setup_repository_for_build(url, commit, log_filename)
|
|
68
|
+
make_result = build_make_result(url, commit, commands)
|
|
69
|
+
save_make_result(make_result, log_filename)
|
|
70
|
+
make_result
|
|
71
|
+
rescue StandardError => e
|
|
72
|
+
handle_make_error(e, url, commit, commands)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Set up repository for build process
|
|
77
|
+
def setup_repository_for_build(url, commit, log_filename)
|
|
78
|
+
commands = initialize_repository_commands(url)
|
|
79
|
+
|
|
80
|
+
clone_dir = RepositoryManager.validate_clone_directory(url)
|
|
81
|
+
resolved_commit = resolve_commit_reference(commit, clone_dir, commands, log_filename, url)
|
|
82
|
+
prepare_make_directory(url, resolved_commit, clone_dir, commands)
|
|
83
|
+
|
|
84
|
+
commands
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Initialize repository commands (clone or pull)
|
|
88
|
+
def initialize_repository_commands(url)
|
|
89
|
+
RepositoryManager.clone_or_pull_repository(url).flatten
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Resolve commit reference (handle "latest" commit)
|
|
93
|
+
def resolve_commit_reference(commit, clone_dir, commands, log_filename, url)
|
|
94
|
+
return commit unless commit == Validator::COMMIT_LATEST
|
|
95
|
+
|
|
96
|
+
latest_commit = RepositoryManager.get_latest_commit(clone_dir, commands)
|
|
97
|
+
# Update log filename with resolved commit hash
|
|
98
|
+
log_filename.replace(
|
|
99
|
+
File.join(
|
|
100
|
+
Directories.get_log_directory(url),
|
|
101
|
+
latest_commit,
|
|
102
|
+
"#{Makit::RUNTIME_IDENTIFIER}.#{Makit::DEVICE}.json"
|
|
103
|
+
)
|
|
104
|
+
)
|
|
105
|
+
latest_commit
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Prepare make directory with repository clone
|
|
109
|
+
def prepare_make_directory(url, commit, clone_dir, commands)
|
|
110
|
+
make_dir = Directories.get_make_commit_directory(url, commit)
|
|
111
|
+
FileUtils.rm_rf(make_dir)
|
|
112
|
+
|
|
113
|
+
clone_command = Makit::Commands::Runner.default.execute("git clone #{clone_dir} #{make_dir}")
|
|
114
|
+
commands << clone_command
|
|
115
|
+
|
|
116
|
+
return if Dir.exist?(make_dir)
|
|
117
|
+
|
|
118
|
+
raise Makit::CloneError, "failed to clone repository: #{url} to #{make_dir}"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Build the make result by executing all build steps
|
|
122
|
+
def build_make_result(url, commit, commands)
|
|
123
|
+
Dir.chdir(Directories.get_make_commit_directory(url, commit)) do
|
|
124
|
+
execute_git_commands(commit, commands)
|
|
125
|
+
execute_build_commands(commands)
|
|
126
|
+
|
|
127
|
+
make_result = create_make_result_object(url, commit)
|
|
128
|
+
commands.flatten.each { |command| make_result.commands << command }
|
|
129
|
+
make_result
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Execute git-specific commands for the build
|
|
134
|
+
def execute_git_commands(commit, commands)
|
|
135
|
+
commands << Makit::Commands::Runner.default.execute("git reset --hard #{commit}")
|
|
136
|
+
commands << Makit::Commands::Runner.default.execute("git log -n 1")
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Execute build commands (bundle, rake, etc.)
|
|
140
|
+
def execute_build_commands(commands)
|
|
141
|
+
commands << Makit::Commands::Runner.default.execute("bundle install") if File.exist?("Gemfile")
|
|
142
|
+
|
|
143
|
+
return unless File.exist?("Rakefile") || File.exist?("rakefile.rb")
|
|
144
|
+
|
|
145
|
+
commands << Makit::Commands::Runner.default.execute("rake default")
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Create the make result object
|
|
149
|
+
def create_make_result_object(url, commit)
|
|
150
|
+
Makit::V1::MakeResult.new(
|
|
151
|
+
repository: url,
|
|
152
|
+
commit: commit,
|
|
153
|
+
branch: "?",
|
|
154
|
+
tag: "?",
|
|
155
|
+
device: Makit::DEVICE,
|
|
156
|
+
runtime_identifier: Makit::RUNTIME_IDENTIFIER,
|
|
157
|
+
)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Save make result to file
|
|
161
|
+
def save_make_result(make_result, log_filename)
|
|
162
|
+
FileUtils.mkdir_p(File.dirname(log_filename))
|
|
163
|
+
File.write(log_filename, make_result.to_json)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Handle make process errors
|
|
167
|
+
def handle_make_error(error, url, commit, commands)
|
|
168
|
+
message_parts = [
|
|
169
|
+
"error raised attempting to make repository: #{url} commit: #{commit}",
|
|
170
|
+
"",
|
|
171
|
+
error.message,
|
|
172
|
+
error.backtrace.join("\\n"),
|
|
173
|
+
"",
|
|
174
|
+
"commands:",
|
|
175
|
+
]
|
|
176
|
+
|
|
177
|
+
commands.flatten.each do |command|
|
|
178
|
+
message_parts << Makit::Humanize.get_command_details(command)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
raise Makit::BuildError, message_parts.join("\\n")
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|