-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
pr-upload: Upload bottles to the Internet Archive #10677
Conversation
--archive-item specifies the item identifier. HOMEBREW_ARCHIVE_KEY=access:secret specifies the S3 key.
Review period will end on 2021-02-24 at 01:26:35 UTC. |
Multiple cloud storage services support an S3-like API, including Amazon itself. Would it perhaps make more sense to have a |
This implementation could pretty easily be adapted to a true S3 implementation like Amazon S3, but in its current form will not work out-of-the-box. I personally have no immediate use case for uploading bottles to Amazon S3, so I'm going to pass on doing this implementation myself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far, nice work!
Library/Homebrew/archive.rb
Outdated
require "digest/md5" | ||
require "utils/curl" | ||
|
||
# Archive API client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Archive API client. | |
# The Internet Archive API client. |
Library/Homebrew/archive.rb
Outdated
|
||
raise UsageError, "Must set the Archive item!" unless @archive_item | ||
|
||
ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] = "1" if @archive_item == "homebrew" && !OS.mac? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is here on the foundational software engineering principles of cargo cult engineering and Chesterton's Fence, cribbed from
brew/Library/Homebrew/bintray.rb
Line 32 in 3efab3e
ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] = "1" if @bintray_org == "homebrew" && !OS.mac? |
I'm not sure of its purpose, so I sadly cannot comment it. I'm happy deleting this line, and we can add it back if we find that we need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I were to guess, it was a hack for uploading and verifying (more likely the verifying step) macOS bottles running on a Linux CI runner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've deleted this line. We can crib it from bintray.rb
if needed.
Library/Homebrew/archive.rb
Outdated
warn_on_error: T.nilable(T::Boolean)).void | ||
} | ||
def upload(local_file, directory:, remote_file:, warn_on_error: false) | ||
unless File.exist? local_file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make local_file
a Pathname
and then you can use local_file.exist?
here and local_file.read
below.
|
||
sig { returns(String) } | ||
def inspect | ||
"#<Archive: item=#{@archive_item}>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to get some tests for this class.
Library/Homebrew/archive.rb
Outdated
|
||
sig { params(url: String).returns(T::Boolean) } | ||
def stable_mirrored?(url) | ||
headers, = curl_output("--connect-timeout", "15", "--location", "--head", url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 15? Would be good to have a comment or shared constant if this is copied from elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷♂️ Cribbed from bintray.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted this method stable_mirrored?
Library/Homebrew/archive.rb
Outdated
directory = bottle_hash["bintray"]["repository"] | ||
bottle_count = bottle_hash["bottle"]["tags"].length | ||
|
||
bottle_hash["bottle"]["tags"].each do |_tag, tag_hash| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bottle_hash["bottle"]["tags"].each do |_tag, tag_hash| | |
bottle_hash["bottle"]["tags"].each_value do |tag_hash| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. Rubocop should have an audit for this case.
Library/Homebrew/dev-cmd/pr-pull.rb
Outdated
@@ -49,6 +49,8 @@ def pr_pull_args | |||
description: "Message to include when autosquashing revision bumps, deletions, and rebuilds." | |||
flag "--artifact=", | |||
description: "Download artifacts with the specified name (default: `bottles`)." | |||
flag "--archive-item=", | |||
description: "Upload to the specified Archive item (default: `homebrew`)." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: "Upload to the specified Archive item (default: `homebrew`)." | |
description: "Upload to the specified Internet Archive item (default: `homebrew`)." |
@@ -27,6 +28,8 @@ def pr_upload_args | |||
switch "--warn-on-upload-failure", | |||
description: "Warn instead of raising an error if the bottle upload fails. "\ | |||
"Useful for repairing bottle uploads that previously failed." | |||
flag "--archive-item=", | |||
description: "Upload to the specified Archive item (default: `homebrew`)." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: "Upload to the specified Archive item (default: `homebrew`)." | |
description: "Upload to the specified Internet Archive item (default: `homebrew`)." |
Library/Homebrew/env_config.rb
Outdated
@@ -15,6 +15,10 @@ module EnvConfig | |||
description: "Linux only: Pass this value to a type name representing the compiler's `-march` option.", | |||
default: "native", | |||
}, | |||
HOMEBREW_ARCHIVE_KEY: { | |||
description: "Use this API key when accessing the Archive.org API (where bottles are stored). " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: "Use this API key when accessing the Archive.org API (where bottles are stored). " \ | |
description: "Use this API key when accessing the Internet Archive API (where bottles are stored). " \ |
Library/Homebrew/env_config.rb
Outdated
@@ -15,6 +15,10 @@ module EnvConfig | |||
description: "Linux only: Pass this value to a type name representing the compiler's `-march` option.", | |||
default: "native", | |||
}, | |||
HOMEBREW_ARCHIVE_KEY: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HOMEBREW_ARCHIVE_KEY: { | |
HOMEBREW_INTERNET_ARCHIVE_KEY: { |
Review period ended. |
BrewTestBot approved my PR, and it automerged. That wasn't exactly intentional, but I'm happy with this PR. Happy to follow up with another PR if tweaks are needed. |
@sjackman pulling out some constants and adding any tests would be nice if possible! |
--archive-item=…
specifies the item identifier.HOMEBREW_INTERNET_ARCHIVE_KEY=access:secret
specifies the S3-like key. See https://archive.org/account/s3.phpbrew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?brew man
locally and committed any changes?