Skip to content
Open
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
91 changes: 44 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.documentation == 'true'
needs: ["files-changed", "yaml-lint", "python-lint"]
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
Expand All @@ -145,10 +145,18 @@ jobs:
cache-dependency-path: docs/package-lock.json
- name: "Install dependencies"
run: npm install
- name: "Setup Python environment"
run: "pip install invoke"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install UV
uses: astral-sh/setup-uv@v4
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
- name: Install dependencies
run: uv sync --all-groups --all-extras
- name: "Build docs website"
run: "invoke docs"
run: "uv run invoke docs"

validate-generated-documentation:
if: |
Expand All @@ -168,17 +176,14 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: "Setup Python environment"
run: |
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
poetry config virtualenvs.create true --local
poetry env use 3.12
- name: "Install dependencies"
run: "poetry install --no-interaction --no-ansi --extras ctl"
- name: "Setup environment"
run: "poetry run pip install invoke"
- name: "Validate generated documentation"
run: "poetry run invoke docs-validate"
- name: Install UV
uses: astral-sh/setup-uv@v4
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
- name: Install dependencies
run: uv sync --all-groups --all-extras
- name: Validate generated documentation
run: uv run invoke docs-validate

validate-documentation-style:
if: |
Expand Down Expand Up @@ -232,24 +237,19 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: "Setup environment"
run: |
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }} --python python${{ matrix.python-version }}
poetry config virtualenvs.create true --local
pip install invoke codecov
- name: "Install tomli for Python < 3.11"
if: matrix.python-version == '3.9' || matrix.python-version == '3.10'
run: |
pip install tomli
- name: "Install Package"
run: "poetry install --all-extras"
- name: "Mypy Tests"
run: "poetry run mypy --show-error-codes infrahub_sdk/"
- name: "Unit Tests"
run: "poetry run pytest --cov infrahub_sdk tests/unit/"
- name: Install UV
uses: astral-sh/setup-uv@v4
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
- name: Install dependencies
run: uv sync --all-groups --all-extras
- name: Mypy Tests
run: uv run mypy --show-error-codes infrahub_sdk/
- name: Unit Tests
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 @@ -259,11 +259,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 All @@ -289,19 +288,17 @@ jobs:
run: |
RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/')
echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
- name: "Setup environment"
run: |
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
poetry config virtualenvs.create true --local
pip install invoke codecov
- name: "Install Package"
run: "poetry install --all-extras"
- name: "Integration Tests"
run: |
poetry run pytest --cov infrahub_sdk tests/integration/
- name: Install UV
uses: astral-sh/setup-uv@v4
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
- name: Install dependencies
run: uv sync --all-groups --all-extras
- name: Integration Tests
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 }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/define-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name: "Define versions"
on:
workflow_call:
outputs:
POETRY_VERSION:
value: "2.1.3"
UV_VERSION:
value: "0.9.8"

jobs:
prepare:
Expand Down
41 changes: 19 additions & 22 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,36 @@ jobs:
with:
python-version: "3.12"

- name: "Install Poetry"
uses: "snok/install-poetry@v1"
- name: Install UV
uses: astral-sh/setup-uv@v4
with:
version: ${{ needs.prepare-environment.outputs.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
version: ${{ needs.prepare-environment.outputs.UV_VERSION }}

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

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

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

- name: "Add PyPI secret"
run: "poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}"
- name: Add PyPI secret
run: uv config token pypi ${{ secrets.PYPI_TOKEN }}

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

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

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

- name: "Install Poetry"
uses: "snok/install-poetry@v1"
- name: Install UV
uses: astral-sh/setup-uv@v4
with:
version: ${{ needs.prepare-environment.outputs.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"

- name: "Setup Python environment"
run: |
poetry config virtualenvs.create true --local
poetry env use 3.12
- name: "Install dependencies"
run: "poetry install --no-interaction --no-ansi"
- name: Install dependencies
run: uv sync --all-groups --all-extras

- name: "Check prerelease type"
- 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"
VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo is_prerelease=$(uv run python -c "from packaging.version import Version; print(int(Version('$VERSION').is_prerelease))") >> "$GITHUB_OUTPUT"
echo is_devrelease=$(uv run python -c "from packaging.version import Version; print(int(Version('$VERSION').is_devrelease))") >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo major_minor_version=$(uv run python -c "from packaging.version import Version; v = Version('$VERSION'); print(f'{v.major}.{v.minor}')") >> "$GITHUB_OUTPUT"
echo latest_tag=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
Expand All @@ -60,10 +54,14 @@ jobs:
| jq -r '.tag_name') >> "$GITHUB_OUTPUT"

- name: Check tag version
if: github.event.release.tag_name != format('v{0}', steps.release.outputs.version)
run: |
echo "Tag version does not match python project version"
exit 1
EXPECTED_TAG="v${{ steps.release.outputs.version }}"
if [ "${{ github.event.release.tag_name }}" != "$EXPECTED_TAG" ]; then
echo "Tag version does not match python project version"
echo "Expected: $EXPECTED_TAG"
echo "Got: ${{ github.event.release.tag_name }}"
exit 1
fi

- name: Check prerelease and project version
if: github.event.release.prerelease == true && steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ script.py
.vscode/settings.json
.DS_Store
.python-version
.venv/
.venv
.ruff_cache
**/.ruff_cache
**/.idea/**
Expand Down
4 changes: 4 additions & 0 deletions .vale/styles/spelling-exceptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ Containerlab
content_type
convert_query_response
coroutine
callouts
cypher
Dagster
datastore
Diataxis
default_branch
default_filter
deserialized
Expand All @@ -42,6 +44,7 @@ eslint
excalidraw
fanout
file_path
frontmatter
generator_definition
generator_definitions
github
Expand Down Expand Up @@ -114,6 +117,7 @@ template_path
toml
Towncrier
towncrier
Typer
uncheck
uniqueness_constraints
userinfo
Expand Down
Loading