From 9d8f2e6d153192e83087b62071cbfcc6550ba07f Mon Sep 17 00:00:00 2001 From: Bennett Goble Date: Fri, 24 Mar 2023 10:03:23 -0700 Subject: [PATCH 1/2] Fix github private package downloads Github private repository asset URLs will return an API response in JSON by default. Set the Accept header to `application/octet-stream` to download an actual file. --- autobuild/autobuild_tool_install.py | 4 ++++ tests/test_install.py | 1 + 2 files changed, 5 insertions(+) diff --git a/autobuild/autobuild_tool_install.py b/autobuild/autobuild_tool_install.py index bb14d5b..fdce205 100644 --- a/autobuild/autobuild_tool_install.py +++ b/autobuild/autobuild_tool_install.py @@ -202,6 +202,10 @@ def download_package(package_url: str, timeout=120, creds=None, package_name="") token_var = CREDENTIAL_ENVVARS[creds] except KeyError: logger.warning(f"Unrecognized creds={creds} value") + + if creds == "github": + # Request octet-stream if creds=github, or else we'll get a JSON response back + req.add_unredirected_header("Accept", "application/octet-stream") token = os.environ.get(token_var) if token: diff --git a/tests/test_install.py b/tests/test_install.py index ae83478..3e869c4 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -762,6 +762,7 @@ def test_download_github(self, mock_urlopen: MagicMock): mock_urlopen.assert_called() got_req = mock_urlopen.mock_calls[0].args[0] self.assertEqual(got_req.unredirected_hdrs["Authorization"], "Bearer token-123") + self.assertEqual(got_req.unredirected_hdrs["Accept"], "application/octet-stream") @patch("urllib.request.urlopen") def test_download_gitlab(self, mock_urlopen: MagicMock): From e4052d4dba5f7897c262953e2ca0c9e2469e308e Mon Sep 17 00:00:00 2001 From: Bennett Goble Date: Fri, 24 Mar 2023 12:38:39 -0700 Subject: [PATCH 2/2] Only upload code coverage on linux Limit codecov coverage upload to runs on ubuntu-latest so that it is not confused by coverage differences between platforms. --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e3fc95e..8e216ac 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -40,6 +40,7 @@ jobs: - name: Upload coverage uses: codecov/codecov-action@v3 + if: matrix.os == 'ubuntu-latest' with: env_vars: OS