Skip to content
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

Fix dbt deps failing on tarballs #9068

Merged
merged 7 commits into from
Nov 14, 2023
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
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20231113-114956.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix formatting of tarball information in packages-lock.yml
time: 2023-11-13T11:49:56.437007-08:00
custom:
Author: ChenyuLInx QMalcolm
Issue: "9062"
3 changes: 1 addition & 2 deletions core/dbt/deps/tarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def name(self):
def to_dict(self) -> Dict[str, str]:
return {
"tarball": self.tarball,
"version": self.version,
"package": self.package,
"name": self.package,
}

def get_version(self):
Expand Down
41 changes: 41 additions & 0 deletions tests/functional/dependencies/test_simple_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

from pathlib import Path

from dbt.exceptions import DbtProjectError
from dbt.tests.util import (
check_relations_equal,
run_dbt,
write_config_file,
)


Expand Down Expand Up @@ -374,3 +376,42 @@ def test_deps_bad_profile(self, project):
del os.environ["PROFILE_TEST_HOST"]
run_dbt(["deps"])
run_dbt(["clean"])


class TestSimpleDependcyTarball(object):
@pytest.fixture(scope="class")
def packages(self):
return {
"packages": [
{
"tarball": "https://codeload.github.com/dbt-labs/dbt-utils/tar.gz/0.9.6",
"name": "dbt_utils",
}
]
}

def test_deps_simple_tarball_doesnt_error_out(self, project):
run_dbt(["deps"])
assert len(os.listdir("dbt_packages")) == 1


class TestBadTarballDependency(object):
def test_malformed_tarball_package_causes_exception(self, project):
# We have to specify the bad formatted package here because if we do it
# in a `packages` fixture, the test will blow up in the setup phase, meaning
# we can't appropriately catch it with a `pytest.raises`
bad_tarball_package_spec = {
"packages": [
{
"tarball": "https://codeload.github.com/dbt-labs/dbt-utils/tar.gz/0.9.6",
"version": "dbt_utils",
}
]
}
write_config_file(bad_tarball_package_spec, "packages.yml")

with pytest.raises(
DbtProjectError, match=r"The packages.yml file in this project is malformed"
) as e:
run_dbt(["deps"])
assert e is not None
Loading