Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorg script #21

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions .github/workflows/fetch_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,6 @@

ENV['AWS_REGION'] ||= 'us-east-1'

def download_artifact(platform:, checksum:, version: VERSION, base_url: BASE_URL)
filename = "skylight_otlp_#{platform}.tar.gz"
output_filename = filename.sub('skylight_otlp', "skylight_#{version}")
path = File.join("artifacts/#{output_filename}")
FileUtils.mkdir_p(File.dirname(path))

uri = URI("#{base_url}/#{version}/#{filename}")
digest = Digest::SHA2.new
puts "fetching Skylight for OTLP; platform=#{platform}"

Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
request = Net::HTTP::Get.new uri
http.request request do |response|
raise response.code unless response.code == '200'

File.open(path, 'wb') do |f|
response.read_body do |chunk|
digest << chunk
f.write(chunk)
end
end
end
end

fetched_checksum = digest.hexdigest

return Artifact.new(checksum: checksum, path: path, platform: platform) if checksum == fetched_checksum

raise "non-matching checksum (expected = #{checksum}; actual = #{fetched_checksum} for #{platform}"
end

artifacts = []

CHECKSUMS.each do |platform, checksum|
artifacts << download_artifact(platform: platform, checksum: checksum)
end

LAMBDA_PLATFORMS = { "x86_64-linux" => "x86_64", "aarch64-linux" => "arm64" }.freeze

class Artifact
attr_reader :layer_version_arn

Expand Down Expand Up @@ -135,6 +96,45 @@ def upload_lambda_layer(aws)
end
end

def download_artifact(platform:, checksum:, version: VERSION, base_url: BASE_URL)
filename = "skylight_otlp_#{platform}.tar.gz"
output_filename = filename.sub('skylight_otlp', "skylight_#{version}")
path = File.join("artifacts/#{output_filename}")
FileUtils.mkdir_p(File.dirname(path))

uri = URI("#{base_url}/#{version}/#{filename}")
digest = Digest::SHA2.new
puts "fetching Skylight for OTLP; platform=#{platform}"

Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
request = Net::HTTP::Get.new uri
http.request request do |response|
raise response.code unless response.code == '200'

File.open(path, 'wb') do |f|
response.read_body do |chunk|
digest << chunk
f.write(chunk)
end
end
end
end

fetched_checksum = digest.hexdigest

return Artifact.new(checksum: checksum, path: path, platform: platform) if checksum == fetched_checksum

raise "non-matching checksum (expected = #{checksum}; actual = #{fetched_checksum} for #{platform}"
end

artifacts = []

CHECKSUMS.each do |platform, checksum|
artifacts << download_artifact(platform: platform, checksum: checksum)
end

LAMBDA_PLATFORMS = { "x86_64-linux" => "x86_64", "aarch64-linux" => "arm64" }.freeze

aws = Aws::Lambda::Client.new
# do this first to get the ARNs
artifacts.each do |artifact|
Expand Down
Loading