Skip to content

Conversation

@Guust-Franssens
Copy link
Contributor

@Guust-Franssens Guust-Franssens commented Dec 11, 2025

📥 Pull Request

✨ Description of new changes

Implements automatic update notifications that inform users when a new version of the Fabric CLI is available on PyPI. The check runs on login (fab auth login) and displays a friendly notification if an update is available.

Changes Made

New Files:

  • src/fabric_cli/utils/fab_version_check.py - Core version checking module with PyPI integration
  • tests/test_utils/test_fab_version_check.py - 100% coverage on fab_version_check.py

Modified Files:

  • src/fabric_cli/core/fab_constant.py - Added constants for update checking configuration
  • src/fabric_cli/commands/auth/fab_auth.py - Integrated version check on successful login
  • docs/essentials/settings.md - Documented the new check_updates setting

Implementation Details

  • Once per session: version check is ran whenever a user logs in using fab auth login
  • User Control: Can be disabled via fab config set check_updates false
  • Silent Failures: Doesn't interrupt user experience if PyPI is unreachable
  • Conservative Version Comparison: Uses tuple-based semantic versioning without external dependencies
  • Debug Logging: Integrated with existing fab_logger for troubleshooting

Configuration

New config key check_updates (default: true) stored in ~/.config/fab/config.json. This setting enables/disables update notifications.

User Experience

When a user logs in and a new version is available:

$ fab auth login -u "$CLIENT_ID" -p "$CLIENT_SECRET" --tenant "$TENANT_ID"

[notice] A new release of fab is available: 1.1.0 → 1.2.0
[notice] To update, run: pip install --upgrade ms-fabric-cli



class TestFetchLatestVersionFromPyPI:
"""Test _fetch_latest_version_from_pypi logic."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please combine the classes to one TestVersionCheck

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave out the use of test classes entirely. I see that other test files also do not use them unless there is a reason for it (shared fixtures or setup/teardown). In my case I did more of a logical grouping of different parts but I think it makes less sense now especially since the caching part is removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 8e3e69e

"""Test _fetch_latest_version_from_pypi logic."""

@patch("fabric_cli.utils.fab_version_check.requests.get")
def test_fetch_success(self, mock_get):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use more meaningfull name such as: test_cli_version_fetch_success / test_cli_version_fetch_failure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 8e3e69e


@patch("fabric_cli.utils.fab_version_check.requests.get")
def test_fetch_failure_http_error(self, mock_get):
"""Should return None when PyPI returns non-200 status code."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please align to the naming convention and use failure/success as suffix.

In other tests as well

@Guust-Franssens
Copy link
Contributor Author

Guust-Franssens commented Dec 23, 2025

Thanks for the review @aviatco. Your points are valid and I will keep them in mind in my potential future PRs.

I left some of the remarks open (like proper naming and the class one) as these warrant a second review by you to verify if my changes are meeting your request.

@Guust-Franssens Guust-Franssens force-pushed the feat/inform-about-user-about-cli-updates branch from ccf89bf to f506576 Compare December 24, 2025 07:46
@Guust-Franssens Guust-Franssens force-pushed the feat/inform-about-user-about-cli-updates branch from f4b4c4e to 13acee7 Compare December 24, 2025 10:00
@Guust-Franssens
Copy link
Contributor Author

Guust-Franssens commented Dec 24, 2025

@aviatco @ayeshurun in f4b4c4e I made a change to ignore pypi.org in the VCR playback. This was causing issues in the tests/test_commands/test_auth.py.

This passes the tests however now during testing of the fab auth login, actual requests to PyPI are being made. I think it would be cleaner to either:

  • Re-record the requests made to include PyPI (preferable by one of you as I don't have the full setup)
  • I mock the function making the call to PyPI for all tests to auth login. Here I would just make it the mock return value equal to the current __version__

Could you provide some guidance here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Help me keep my fabric-cli updated

3 participants