repology: always use Homebrew curl.

This seems to be required even with TLSv1.3 support now.

Also, while we're here, improve the error handling/output.
This commit is contained in:
Mike McQuaid 2021-12-31 17:07:53 +00:00
parent 60afbd761a
commit b09f421027
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
6 changed files with 35 additions and 29 deletions

View File

@ -228,6 +228,9 @@ jobs:
key: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec-${{ github.sha }} key: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec- restore-keys: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec-
- name: Install brew tests dependencies
run: brew install curl
- name: Run brew tests - name: Run brew tests
run: | run: |
# brew tests doesn't like world writable directories # brew tests doesn't like world writable directories
@ -303,13 +306,7 @@ jobs:
run: brew readall --aliases run: brew readall --aliases
- name: Install brew tests dependencies - name: Install brew tests dependencies
run: | run: brew install subversion curl
brew install subversion
brew sh -c "svn --homebrew=print-path"
which svn
which svnadmin
brew install curl
which curl
- name: Create parallel test log directory - name: Create parallel test log directory
run: mkdir tests run: mkdir tests

View File

@ -56,14 +56,12 @@ module Homebrew
limit = args.limit.to_i if args.limit.present? limit = args.limit.to_i if args.limit.present?
unless Utils::Curl.curl_supports_tls13?
begin begin
unless Pathname.new(ENV["HOMEBREW_BREWED_CURL_PATH"]).exist? unless Pathname.new(ENV["HOMEBREW_BREWED_CURL_PATH"]).exist?
ensure_formula_installed!("curl", reason: "Repology queries") ensure_formula_installed!("curl", reason: "Repology queries")
end end
rescue FormulaUnavailableError rescue FormulaUnavailableError
opoo "A `curl` with TLS 1.3 support is required for Repology queries." opoo "A newer `curl` is required for Repology queries."
end
end end
if formulae_and_casks.present? if formulae_and_casks.present?

View File

@ -6,7 +6,7 @@ require "cmd/shared_examples/args_parse"
describe "brew bump" do describe "brew bump" do
it_behaves_like "parseable arguments" it_behaves_like "parseable arguments"
describe "formula", :integration_test, :needs_network, :needs_tls13 do describe "formula", :integration_test, :needs_network, :needs_homebrew_curl do
it "returns data for single valid specified formula" do it "returns data for single valid specified formula" do
install_test_formula "testball" install_test_formula "testball"

View File

@ -169,11 +169,9 @@ RSpec.configure do |config|
.append(svnadmin.dirname) .append(svnadmin.dirname)
end end
config.before(:each, :needs_tls13) do config.before(:each, :needs_homebrew_curl) do
unless curl_supports_tls13?
ENV["HOMEBREW_CURL"] = ENV["HOMEBREW_BREWED_CURL_PATH"] ENV["HOMEBREW_CURL"] = ENV["HOMEBREW_BREWED_CURL_PATH"]
skip "A `curl` with TLS 1.3 support is required." unless curl_supports_tls13? skip "A `curl` with TLS 1.3 support is required." unless curl_supports_tls13?
end
rescue FormulaUnavailableError rescue FormulaUnavailableError
skip "No `curl` formula is available." skip "No `curl` formula is available."
end end

View File

@ -4,7 +4,7 @@
require "utils/repology" require "utils/repology"
describe Repology do describe Repology do
describe "single_package_query", :needs_network, :needs_tls13 do describe "single_package_query", :needs_network, :needs_homebrew_curl do
it "returns nil for non-existent package" do it "returns nil for non-existent package" do
response = described_class.single_package_query("invalidName", repository: "homebrew") response = described_class.single_package_query("invalidName", repository: "homebrew")
@ -19,7 +19,7 @@ describe Repology do
end end
end end
describe "parse_api_response", :needs_network, :needs_tls13 do describe "parse_api_response", :needs_network, :needs_homebrew_curl do
it "returns a hash of data" do it "returns a hash of data" do
limit = 1 limit = 1
start_with = "x" start_with = "x"

View File

@ -19,22 +19,35 @@ module Repology
last_package_in_response += "/" if last_package_in_response.present? last_package_in_response += "/" if last_package_in_response.present?
url = "https://repology.org/api/v1/projects/#{last_package_in_response}?inrepo=#{repository}&outdated=1" url = "https://repology.org/api/v1/projects/#{last_package_in_response}?inrepo=#{repository}&outdated=1"
output, _errors, _status = curl_output(url.to_s, use_homebrew_curl: !curl_supports_tls13?) output, errors, = curl_output(url.to_s, "--silent", use_homebrew_curl: false)
JSON.parse(output) JSON.parse(output)
rescue
if Homebrew::EnvConfig.developer?
$stderr.puts errors
else
odebug errors
end
raise
end end
def single_package_query(name, repository:) def single_package_query(name, repository:)
url = "https://repology.org/tools/project-by?repo=#{repository}&" \ url = "https://repology.org/tools/project-by?repo=#{repository}&" \
"name_type=srcname&target_page=api_v1_project&name=#{name}" "name_type=srcname&target_page=api_v1_project&name=#{name}"
output, _errors, _status = curl_output("--location", url.to_s, use_homebrew_curl: !curl_supports_tls13?) output, errors, = curl_output("--location", "--silent", url.to_s, use_homebrew_curl: true)
begin
data = JSON.parse(output) data = JSON.parse(output)
{ name => data } { name => data }
rescue rescue => e
nil error_output = [errors, "#{e.class}: #{e}", e.backtrace].compact
if Homebrew::EnvConfig.developer?
$stderr.puts(*error_output)
else
odebug(*error_output)
end end
nil
end end
def parse_api_response(limit = nil, last_package = "", repository:) def parse_api_response(limit = nil, last_package = "", repository:)