diff --git a/CHANGELOG.md b/CHANGELOG.md index bf3385992..155f44e99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Request locally compiled Python runtimes through `BUILDCURL_URL` instead of the hosted Barebuild SSH compiler. +- Default to `https://buildcurl.com` when no local compiler URL is provided, preserving compatibility with released pkgr actions. ## v221 (2022-10-12) diff --git a/bin/download-python-runtime b/bin/download-python-runtime index 4dd32cfc3..4d9db50c2 100755 --- a/bin/download-python-runtime +++ b/bin/download-python-runtime @@ -5,10 +5,10 @@ runtime="${1:?runtime is required}" destination="${2:?destination is required}" prefix="${3:?prefix is required}" -: "${BUILDCURL_URL:?BUILDCURL_URL is required}" +buildcurl_url="${BUILDCURL_URL:-https://buildcurl.com}" curl --get --fail --location --silent --show-error \ - "$BUILDCURL_URL" \ + "$buildcurl_url" \ --data-urlencode "recipe=python" \ --data-urlencode "version=${runtime#python-}" \ --data-urlencode "target=$(cat /etc/version)" \ diff --git a/spec/local_buildcurl_spec.rb b/spec/local_buildcurl_spec.rb index 840c17547..35d659efc 100644 --- a/spec/local_buildcurl_spec.rb +++ b/spec/local_buildcurl_spec.rb @@ -59,17 +59,49 @@ end end - it 'fails without BUILDCURL_URL' do - _stdout, stderr, status = Open3.capture3( - { 'BUILDCURL_URL' => nil }, - downloader, - 'python-3.10.8', - Dir.tmpdir, - '/app/.heroku/python' - ) + it 'uses the hosted compiler when BUILDCURL_URL is not set' do + Dir.mktmpdir do |directory| + fake_bin = File.join(directory, 'bin') + source = File.join(directory, 'source') + destination = File.join(directory, 'destination') + archive = File.join(directory, 'runtime.tgz') + arguments = File.join(directory, 'curl-arguments') + FileUtils.mkdir_p([fake_bin, source, destination]) + File.write(File.join(source, 'python'), 'hosted runtime') + system('tar', 'czf', archive, '-C', source, '.', exception: true) - expect(status).not_to be_success - expect(stderr).to include('BUILDCURL_URL is required') + File.write(File.join(fake_bin, 'curl'), <<~SH) + #!/usr/bin/env bash + printf '%s\n' "$@" > "$CURL_ARGUMENTS" + /bin/cat "$CURL_ARCHIVE" + SH + File.write(File.join(fake_bin, 'cat'), <<~SH) + #!/usr/bin/env bash + if [[ "$1" == "/etc/version" ]]; then + echo ubuntu:24.04 + else + exec /bin/cat "$@" + fi + SH + FileUtils.chmod(0o755, [File.join(fake_bin, 'curl'), File.join(fake_bin, 'cat')]) + + _stdout, stderr, status = Open3.capture3( + { + 'BUILDCURL_URL' => nil, + 'CURL_ARGUMENTS' => arguments, + 'CURL_ARCHIVE' => archive, + 'PATH' => "#{fake_bin}:#{ENV.fetch('PATH')}" + }, + downloader, + 'python-3.10.8', + destination, + '/app/.heroku/python' + ) + + expect(status).to be_success, stderr + expect(File.read(File.join(destination, 'python'))).to eq('hosted runtime') + expect(File.readlines(arguments, chomp: true)).to include('https://buildcurl.com') + end end it 'propagates download failures without retrying' do