Skip to content

Commit

Permalink
Added unreleased version fallback (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
nfx authored Dec 27, 2023
1 parent 42aa410 commit 5f5c818
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Unshallow
run: git fetch --prune --unshallow

- name: Install Python
uses: actions/setup-python@v4
with:
Expand Down
17 changes: 8 additions & 9 deletions src/databricks/labs/blueprint/wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def __init__(
project_root_finder = find_project_root
self._ws = ws
self._install_state = install_state
self._this_file = Path(__file__)
self._github_org = github_org
self._verbose = verbose
self._version_file_name = version_file_name
Expand Down Expand Up @@ -70,14 +69,14 @@ def version(self):
try:
self.__version = self._pep0440_version_from_git()
return self.__version
except Exception as err:
product = self._install_state.product()
raise OSError(
f"Cannot determine unreleased version. Please report this error "
f"message that you see on https://github.com/{self._github_org}/{product}/issues/new. "
f"Meanwhile, download, unpack, and install the latest released version from "
f"https://github.com/{self._github_org}/{product}/releases. Original error is: {err!s}"
) from None
except subprocess.CalledProcessError as err:
logger.error(
"Cannot determine unreleased version. This can be fixed by adding "
" `git fetch --prune --unshallow` to your CI configuration.",
exc_info=err,
)
self.__version = self.released_version()
return self.__version

@staticmethod
def _pep0440_version_from_git():
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_wheels.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os
from unittest.mock import create_autospec

import pytest
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.workspace import ImportFormat

from databricks.labs.blueprint.__about__ import __version__
from databricks.labs.blueprint.entrypoint import is_in_debug
from databricks.labs.blueprint.installer import InstallState
from databricks.labs.blueprint.wheels import Wheels

Expand Down Expand Up @@ -36,6 +38,8 @@ def test_build_and_upload_wheel():


def test_unreleased_version(tmp_path):
if not is_in_debug():
pytest.skip("fails without `git fetch --prune --unshallow` configured")
ws = create_autospec(WorkspaceClient)
state = create_autospec(InstallState)
state.product.return_value = "blueprint"
Expand Down

0 comments on commit 5f5c818

Please sign in to comment.