Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
17 changes: 13 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,30 @@
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers-contrib/features/poetry:2": {}
"ghcr.io/va-h/devcontainers-features/uv:1": {}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "poetry config virtualenvs.in-project true && poetry install --with dev --no-interaction && . .venv/bin/activate && pre-commit install && pre-commit install-hooks",
"postCreateCommand": "uv sync --all-groups && uv run prek install -f",
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"yzhang.markdown-all-in-one"
Comment thread
iMicknl marked this conversation as resolved.
Outdated
],
"settings": {
"python.defaultInterpreterPath": "./.venv/bin/python"
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": "explicit"
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: 2
updates:
- package-ecosystem: pip
- package-ecosystem: uv
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
time: "08:00"
open-pull-requests-limit: 10

- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
time: "08:00"
open-pull-requests-limit: 10
20 changes: 11 additions & 9 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,25 @@ jobs:
with:
python-version: "${{ matrix.python-version }}"

- name: Set up Poetry
uses: Gr1N/setup-poetry@v9
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Cache venv
uses: actions/cache@v5
with:
path: .venv
key: venv-${{ hashFiles('**/poetry.lock') }}
key: venv-${{ hashFiles('**/uv.lock') }}

- name: Cache pre-commit
- name: Cache prek
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit/
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/.pre-commit-config.yaml') }} # yamllint disable-line
path: ~/.cache/prek/
key: ${{ runner.os }}-prek-${{ hashFiles('**/uv.lock') }}-${{ hashFiles('**/.pre-commit-config.yaml') }} # yamllint disable-line

- name: Install dependencies
run: poetry install
run: uv sync --all-groups

- name: Register problems matchers
run: |
Expand All @@ -50,5 +52,5 @@ jobs:
echo "::add-matcher::.github/workflows/matchers/mypy.json"
echo "::add-matcher::.github/workflows/matchers/python.json"

- name: Apply all pre-commit
run: poetry run pre-commit run -a
- name: Apply all prek hooks
run: uv run prek run -a
16 changes: 7 additions & 9 deletions .github/workflows/publish-pypi-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yamllint disable-file
# This workflows will upload a Python Package
# using Poetry when a release is created
# This workflow will upload a Python package
# using uv when a release is created

name: Publish Python Package (test)

Expand All @@ -18,13 +18,11 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Set up Poetry
uses: Gr1N/setup-poetry@v9
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Build and publish to PyPi
env:
POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.TEST_PYPI_API_TOKEN }}
UV_PUBLISH_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: |
poetry config http-basic.testpypi ${{ secrets.TEST_PYPI_API_TOKEN }} ""
poetry build
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish -r testpypi
uv build
uv publish --publish-url https://test.pypi.org/legacy/
59 changes: 37 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This workflow will upload a Python Package using
# Poetry when a release is published
# This workflow will upload the package to PyPi when a release is published

name: Publish Python Package (PyPi)

Expand All @@ -13,32 +12,48 @@ jobs:
environment: release

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
# IMPORTANT: this permission is mandatory for trusted publishing via PyPi
id-token: write
contents: write

steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Set up Poetry
uses: Gr1N/setup-poetry@v9
- name: Bump Poetry version
python-version: "3.x"

- name: Retrieve version from tag name
id: retrieve-version
run: |
tag=${{ github.event.release.tag_name }}
version_number=${tag#?}
poetry version $version_number
- name: Commit changes
uses: EndBug/add-and-commit@v4
with:
message: "Bump version to ${{ github.event.release.tag_name }}"
add: "pyproject.toml"
ref: "main"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build package distribution
tag="${{ github.event.release.tag_name }}"
version_number="${tag#?}"
echo "version: $version_number"
echo "version=$version_number" >> "$GITHUB_OUTPUT"

- name: Bump project version in pyproject.toml and commit changes to current branch and tag
run: |
VERSION=${{ steps.retrieve-version.outputs.version }}
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION

git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

git add pyproject.toml
git commit -m "Bump package version to ${{ steps.retrieve-version.outputs.version }}."

git tag -f -a ${{ github.event.release.tag_name }} -m "Release ${{ steps.retrieve-version.outputs.version }}."
git push origin HEAD:main
git push origin -f ${{ github.event.release.tag_name }}
Comment thread
iMicknl marked this conversation as resolved.

- name: Build package
run: |
uv build

- name: Publish package to PyPI
run: |
poetry build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uv publish
Comment thread
iMicknl marked this conversation as resolved.
14 changes: 7 additions & 7 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ The test suite uses `pytest` with async support to validate the client's behavio

```bash
# Run all tests
poetry run pytest
uv run pytest

# Run only unit tests
poetry run pytest tests/unit/
uv run pytest tests/unit/

# Run with coverage report
poetry run pytest --cov=sagemcom_api
uv run pytest --cov=sagemcom_api

# Run with coverage HTML report
poetry run pytest --cov=sagemcom_api --cov-report=html
uv run pytest --cov=sagemcom_api --cov-report=html

# Run specific test file
poetry run pytest tests/unit/test_client_basic.py
uv run pytest tests/unit/test_client_basic.py

# Run specific test
poetry run pytest tests/unit/test_client_basic.py::test_login_success
uv run pytest tests/unit/test_client_basic.py::test_login_success
```

## Test Structure
Expand Down Expand Up @@ -155,7 +155,7 @@ await client.logout() # Would raise StopIteration (no 3rd response)

Run coverage reports regularly:
```bash
poetry run pytest --cov=sagemcom_api --cov-report=term-missing
uv run pytest --cov=sagemcom_api --cov-report=term-missing
```

The `--cov-report=term-missing` shows which lines lack coverage.
Loading
Loading