Skip to content
Closed
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: 3 additions & 3 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ development_files: &development_files
- "development/**"
- "tasks/**"

poetry_files: &poetry_files
uv_files: &uv_files
- "pyproject.toml"
- "poetry.lock"
- "uv.lock"

doc_files: &doc_files
- "docs/**"

python_all: &python_all
- "**/*.py"
- *poetry_files
- *uv_files
- *ci_config
- *coverage_config

Expand Down
3 changes: 3 additions & 0 deletions .github/get-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import importlib.metadata

print(importlib.metadata.version("infrahub-sdk"))
41 changes: 20 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
helm: ${{ steps.changes.outputs.helm_all }}
python: ${{ steps.changes.outputs.python_all }}
yaml: ${{ steps.changes.outputs.yaml_all }}
poetry_files: ${{ steps.changes.outputs.poetry_files }}
uv_files: ${{ steps.changes.outputs.uv_files }}
github_workflows: ${{ steps.changes.outputs.github_workflows }}
steps:
- name: "Check out repository code"
Expand Down Expand Up @@ -138,24 +138,24 @@ jobs:
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: "Set up Python ${{ matrix.python-version }}"
uses: "actions/setup-python@v5"
with:
python-version: ${{ matrix.python-version }}
- name: "Setup environment"
run: |
pipx install poetry==1.8.5
poetry config virtualenvs.create true --local
pip install invoke toml codecov
pipx install uv
uv venv
uv pip install invoke toml codecov
- name: "Install Package"
run: "poetry install --all-extras"
run: "uv pip install --all-extras -r pyproject.toml"
- name: "Mypy Tests"
run: "poetry run mypy --show-error-codes infrahub_sdk/"
run: "uv run mypy --show-error-codes infrahub_sdk/"
- name: "Unit Tests"
run: "poetry run pytest --cov infrahub_sdk tests/unit/"
run: "uv run pytest --cov infrahub_sdk tests/unit/"
- name: "Upload coverage to Codecov"
run: |
codecov --flags python-${{ matrix.python-version }}
uv run codecov --flags python-${{ matrix.python-version }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -165,11 +165,10 @@ jobs:
- name: "Report coverage for pytest-plugin"
if: matrix.python-version == '3.12'
run: |
source $(poetry env info --path)/bin/activate
coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin
coverage report -m
coverage xml
codecov --flags python-filler-${{ matrix.python-version }}
uv run coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin
uv run coverage report -m
uv run coverage xml
uv run codecov --flags python-filler-${{ matrix.python-version }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down Expand Up @@ -197,15 +196,15 @@ jobs:
echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
- name: "Setup environment"
run: |
pipx install poetry==1.8.5
poetry config virtualenvs.create true --local
pip install invoke toml codecov
pipx install uv
uv venv
uv pip install invoke toml codecov
- name: "Install Package"
run: "poetry install --all-extras"
run: "uv pip install --all-extras -r pyproject.toml"
- name: "Integration Tests"
run: "poetry run pytest --cov infrahub_sdk tests/integration/"
run: "uv run pytest --cov infrahub_sdk tests/integration/"
- name: "Upload coverage to Codecov"
run: |
codecov --flags integration-tests
uv run codecov --flags integration-tests
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
31 changes: 12 additions & 19 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,32 @@ jobs:
with:
python-version: "3.12"

- name: "Install Poetry"
uses: "snok/install-poetry@v1"
with:
version: 1.8.5
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: "Install uv"
run: |
pipx install uv

- name: "Check out repository code"
uses: "actions/checkout@v4"
with:
submodules: true

- name: "Cache poetry venv"
- name: "Cache uv venv"
uses: "actions/cache@v4"
id: "cached-poetry-dependencies"
id: "cached-uv-dependencies"
with:
path: "./python_sdk/.venv"
key: "venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}"
key: "venv-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}"

- name: "Install Dependencies"
run: "poetry install"
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'

- name: "Add PyPI secret"
run: "poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}"
run: "uv pip install --all-extras -r pyproject.toml"
if: steps.cached-uv-dependencies.outputs.cache-hit != 'true'

- name: "Poetry build"
run: "poetry build"
- name: "Build package"
run: "uv build"

- name: "show output"
run: "ls -la dist/"

- name: "Poetry push PyPI"
- name: "Publish to PyPI"
if: ${{ inputs.publish }}
run: "poetry publish"
run: "uv publish --token ${{ secrets.PYPI_TOKEN }}"
38 changes: 18 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,32 @@ jobs:
with:
python-version: "3.12"

- name: "Install Poetry"
uses: "snok/install-poetry@v1"
with:
version: 1.8.5
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: "Install uv"
run: |
pipx install uv

- name: "Setup Python environment"
run: |
poetry config virtualenvs.create true --local
poetry env use 3.12
uv venv

- name: "Install dependencies"
run: "poetry install --no-interaction --no-ansi"
run: "uv pip install --no-deps ."

- name: "Check prerelease type"
id: release
run: |
echo is_prerelease=$(poetry run python -c "from packaging.version import Version; print(int(Version('$(poetry version -s)').is_prerelease))") >> "$GITHUB_OUTPUT"
echo is_devrelease=$(poetry run python -c "from packaging.version import Version; print(int(Version('$(poetry version -s)').is_devrelease))") >> "$GITHUB_OUTPUT"
echo "version=$(poetry version -s)" >> "$GITHUB_OUTPUT"
echo major_minor_version=$(poetry run python -c "from packaging.version import Version; print(f\"{Version('$(poetry version -s)').major}.{Version('$(poetry version -s)').minor}\")") >> "$GITHUB_OUTPUT"
echo latest_tag=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/latest \
| jq -r '.tag_name') >> "$GITHUB_OUTPUT"
VERSION=$(uv run .github/get-version.py)
IS_PRERELEASE=$(uv run python -c "from packaging.version import Version; print(int(Version('$VERSION').is_prerelease))")
IS_DEVRELEASE=$(uv run python -c "from packaging.version import Version; print(int(Version('$VERSION').is_devrelease))")
MAJOR_MINOR_VERSION=$(uv run python -c "from packaging.version import Version; v = Version('$VERSION'); print(f'{v.major}.{v.minor}')")
LATEST_TAG=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ github.token }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name')

echo "is_prerelease=$IS_PRERELEASE" >> "$GITHUB_OUTPUT"
echo "is_devrelease=$IS_DEVRELEASE" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "major_minor_version=$MAJOR_MINOR_VERSION" >> "$GITHUB_OUTPUT"
echo "latest_tag=$LATEST_TAG" >> "$GITHUB_OUTPUT"


- name: Check tag version
if: github.event.release.tag_name != format('v{0}', steps.release.outputs.version)
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
except ImportError as exc:
sys.exit(
f"Module {exc.name} is not available, install the 'ctl' extra of the infrahub-sdk package, `pip install 'infrahub-sdk[ctl]'` or enable the "
"Poetry shell and run `poetry install --extras ctl`."
"virtual environment and run `uv sync --extras ctl`."
)

__all__ = ["app"]
Loading
Loading