Skip to content
Draft
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
21 changes: 17 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,44 @@

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
include:
- os: macos-latest
python-version: "3.10"
- os: macos-latest
python-version: "3.14"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install Pango for the PDF reports (macOS)
if: runner.os == 'macOS'
run: brew install pango
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Linting
run: |
poetry run flake8
- name: Testing
run: |
# WeasyPrint finds Homebrew's libraries only through this path on Apple Silicon.
# It is exported here because macOS drops DYLD_* variables passed to /bin/bash.
if [ "$RUNNER_OS" = "macOS" ]; then export DYLD_FALLBACK_LIBRARY_PATH="$(brew --prefix)/lib"; fi
poetry run pytest -v
sonar:
needs: [test]
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions connect/cli/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
"""

PYPI_JSON_API_URL = 'https://pypi.org/pypi/connect-cli/json'

VERSION_CHECK_TIMEOUT = 5 # seconds
19 changes: 6 additions & 13 deletions connect/cli/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import os
from collections import OrderedDict
from importlib.metadata import entry_points
from distutils.version import StrictVersion

import click
import requests
from packaging.version import InvalidVersion, Version

from connect.cli import get_version
from connect.cli.core.constants import DEFAULT_ENDPOINT, PYPI_JSON_API_URL
from connect.cli.core.constants import DEFAULT_ENDPOINT, PYPI_JSON_API_URL, VERSION_CHECK_TIMEOUT
from connect.cli.core.terminal import console


Expand Down Expand Up @@ -52,7 +51,7 @@ def get_last_version_by_major(tags, major):

def get_last_cli_version():
try:
res = requests.get(PYPI_JSON_API_URL)
res = requests.get(PYPI_JSON_API_URL, timeout=VERSION_CHECK_TIMEOUT)
if res.status_code == 200:
data = res.json()
return data['info']['version']
Expand All @@ -62,7 +61,7 @@ def get_last_cli_version():

def get_connect_version():
try:
response = requests.get(DEFAULT_ENDPOINT)
response = requests.get(DEFAULT_ENDPOINT, timeout=VERSION_CHECK_TIMEOUT)
return response.headers.get('Connect-Version')
except requests.RequestException:
return
Expand All @@ -76,7 +75,7 @@ def check_for_updates(*args):
current = get_version()
last_version = None
try:
res = requests.get(PYPI_JSON_API_URL)
res = requests.get(PYPI_JSON_API_URL, timeout=VERSION_CHECK_TIMEOUT)
if res.status_code == 200:
data = res.json()
last_version = get_last_version_by_major(
Expand Down Expand Up @@ -141,12 +140,6 @@ def field_to_check_mark(predicate, false_value=''):


def iter_entry_points(group, name=None):
group_entrypoints = entry_points().get(group)
if not group_entrypoints:
return
for ep in group_entrypoints:
if name:
if ep.name == name:
yield ep
else:
for ep in entry_points(group=group):
if not name or ep.name == name:
yield ep
36 changes: 12 additions & 24 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Utilities"
]
keywords = [
Expand Down Expand Up @@ -89,13 +86,12 @@ flake8-black = "0.*"
flake8-bugbear = ">=24"
flake8-cognitive-complexity = "^0.1"
flake8-commas = "~4"
flake8-future-import = "~0.4"
flake8-isort = "^6.0"
flake8-broken-line = ">=1.0"
flake8-comprehensions = "^3.10"
flake8-debugger = "^4.0.0"
flake8-eradicate = "^1.3.0"
flake8-string-format = "^0.3.0"
flake8-string-format = "^0.4.0"
flake8-pyproject = "^1.2.2"
ipython = "^8.10"
isort = "5.*"
Expand Down
8 changes: 7 additions & 1 deletion tests/core/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,15 @@ def test_iter_entry_points(mocker):
ep2.name = 'ep2'
mocker.patch(
'connect.cli.core.utils.entry_points',
return_value={'ep.group': [ep1, ep2]},
side_effect=lambda group: {'ep.group': (ep1, ep2)}.get(group, ()),
)

assert list(iter_entry_points('ep.group', name='ep1')) == [ep1]
assert list(iter_entry_points('ep.group')) == [ep1, ep2]
assert list(iter_entry_points('ep.other_group')) == []


def test_iter_entry_points_finds_the_installed_plugins():
names = {ep.name for ep in iter_entry_points('connect.cli.plugins')}

assert {'customer', 'product', 'project', 'report'} <= names