Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions bin/download-python-runtime
Original file line number Diff line number Diff line change
Expand Up @@ -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)" \
Expand Down
52 changes: 42 additions & 10 deletions spec/local_buildcurl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading