Skip to content

Commit

Permalink
Removing binding method and ensuring validation output files get cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
tamerbader committed Jul 2, 2024
1 parent 433c7fb commit 14f6d07
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Scripts/git/pull-request-validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

# Validate Podspecs, SPM, and Templated Files
unless Validator.validate_podspecs && Validator.validate_spm_package && Validator.validate_template_files
puts "❎ Pull Request Validation Failed."
puts "❎ Pull Request Validation Failed"
exit 1
else
puts "✅ Pull Request Validation Passed!"
puts "✅ Pull Request Validation Passed"
exit 0
end
8 changes: 1 addition & 7 deletions Scripts/sdk_utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@ def initialize(version, commit_sha, license, homepage_url, authors, ios_deployme
def build_and_write(template_path, file_name, output_dir)
template = File.read(template_path)
renderer = ERB.new(template)
result = renderer.result(get_binding)
result = renderer.result(binding)
File.open("#{output_dir}#{file_name}", 'w+') do |file|
file.write(result)
end
end

private

def get_binding
binding
end
end

class CommandExecutor
Expand Down
10 changes: 8 additions & 2 deletions Scripts/sdk_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def self.validate_podspecs
# Validates output
unless stdout.include?("All the specs passed validation.")
puts "❎ Podspecs could not be validated"
puts stderr
puts stdout
return false
end

Expand Down Expand Up @@ -46,10 +46,13 @@ def self.validate_spm_package
for package in packages_to_validate do
unless File.directory?("./.build/artifacts/mobile-payments-sdk-ios/#{package}/#{package}.xcframework")
puts "❎ SPM was unable to resolve #{package}"
FileUtils.rm_rf('.build')
return false
end
end

FileUtils.rm_rf('.build')

puts "✅ SPM package has passed validation"
return true
end
Expand Down Expand Up @@ -79,12 +82,15 @@ def self.validate_template_files
for file in files_to_test do
template_builder.build_and_write("./Scripts/templates/#{file}.erb", file, './tmp/')
unless FileComparator.compare("./#{file}", "./tmp/#{file}")
puts "Output of #{file}.erb rendering does not match #{file_name}."
puts "Output of #{file}.erb rendering does not match #{file}."
puts "Please ensure you are modifying the erb template and not the output file"
FileUtils.rm_rf('tmp')
return false
end
end

FileUtils.rm_rf('tmp')

puts "✅ Template files have passed validation"
return true
end
Expand Down

0 comments on commit 14f6d07

Please sign in to comment.