diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ce647d01..5aa9e2ded 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,12 @@ concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true +env: + # Default Python version for tooling jobs (lint, build, test-release) + DEFAULT_PYTHON_VERSION: "3.11" + # Matrix Python version that collects branch coverage and uploads to Codecov + COVERAGE_PYTHON_VERSION: "3.14" + jobs: # Make sure commit messages follow the conventional commits convention: # https://www.conventionalcommits.org @@ -27,16 +33,17 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: - python-version: "3.11" + python-version: ${{ env.DEFAULT_PYTHON_VERSION }} - uses: pre-commit/action@v3.0.1 test: strategy: fail-fast: false matrix: + # Keep COVERAGE_PYTHON_VERSION in sync with this matrix python-version: - - "3.11" - - "3.14" + - "3.11" # Minimum supported Python version + - "3.14" # Latest supported Python version (coverage) runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 @@ -45,11 +52,14 @@ jobs: with: python-version: ${{ matrix.python-version }} activate-environment: true - - run: uv pip install pip + enable-cache: true - name: Test with Pytest - run: uv run pytest --log-cli-level=DEBUG -vv -s --cov --cov-branch --cov-report=xml + run: >- + uv run pytest -n auto + ${{ matrix.python-version == env.COVERAGE_PYTHON_VERSION && '--cov --cov-branch --cov-report=xml' || '' }} shell: bash - name: Upload results to Codecov + if: matrix.python-version == env.COVERAGE_PYTHON_VERSION uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -59,9 +69,10 @@ jobs: strategy: fail-fast: false matrix: + # Keep COVERAGE_PYTHON_VERSION in sync with this matrix python-version: - - "3.11" - - "3.14" + - "3.11" # Minimum supported Python version + - "3.14" # Latest supported Python version (coverage) runs-on: ubuntu-latest services: emqx: @@ -70,9 +81,9 @@ jobs: - 1888:1883 options: >- --health-cmd "/opt/emqx/bin/emqx ctl status" - --health-interval 5s + --health-interval 1s --health-timeout 25s - --health-retries 5 + --health-retries 25 steps: - uses: actions/checkout@v6 - name: Set up uv @@ -80,9 +91,13 @@ jobs: with: python-version: ${{ matrix.python-version }} activate-environment: true + enable-cache: true - name: Test MQTT with Pytest - run: uv run pytest -m mqtt_broker --log-cli-level=DEBUG -vv -s --cov --cov-branch --cov-report=xml + run: >- + uv run pytest -m mqtt_broker + ${{ matrix.python-version == env.COVERAGE_PYTHON_VERSION && '--cov --cov-branch --cov-report=xml' || '' }} - name: Upload results to Codecov + if: matrix.python-version == env.COVERAGE_PYTHON_VERSION uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -97,8 +112,9 @@ jobs: - name: Set up uv uses: astral-sh/setup-uv@v7 with: - python-version: "3.11" + python-version: ${{ env.DEFAULT_PYTHON_VERSION }} activate-environment: true + enable-cache: true - name: Build package run: uv build @@ -111,6 +127,11 @@ jobs: - uses: actions/checkout@v6 with: fetch-depth: 0 + - name: Set up uv + uses: astral-sh/setup-uv@v7 + with: + python-version: ${{ env.DEFAULT_PYTHON_VERSION }} + enable-cache: true - name: Setup Git for Semantic Release Testing run: | # Setup a temp branch to test @@ -118,25 +139,13 @@ jobs: git merge ${{ github.event.pull_request.head.sha }} --no-edit git config user.name "GitHub Actions" git config user.email "actions@github.com" - - name: Test Semantic Release (No-op) - id: test-release - uses: python-semantic-release/python-semantic-release@v10.5.3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - changelog: true - # Use noop mode to test without making changes - no_operation_mode: true - name: Test Semantic Release (Dry Run) - id: test-release-dry - uses: python-semantic-release/python-semantic-release@v10.5.3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - changelog: true - # Use dry run mode to test without committing - commit: false - tag: false - push: false - vcs_release: false + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Keep version in sync with python-semantic-release action in the release job + run: >- + uv tool run --from python-semantic-release==10.5.3 + semantic-release version --changelog --no-commit --no-tag --no-push --no-vcs-release release: runs-on: ubuntu-latest needs: diff --git a/pyproject.toml b/pyproject.toml index 0537ff3c8..390ded195 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,6 +70,7 @@ dev = [ "syrupy>=4.9.1,<6", "pdoc>=15.0.4,<17", "pytest-cov>=7.0.0", + "pytest-xdist>=3.8.0", "zmqtt>=0.2.0,<0.3.0", "pytest-benchmark>=5.1.0", ] @@ -87,7 +88,7 @@ build-backend = "hatchling.build" [tool.semantic_release] branch = "main" version_toml = ["pyproject.toml:project.version"] -build_command = "pip install uv && uv lock --upgrade-package python-roborock && git add uv.lock && uv build" +build_command = "(command -v uv >/dev/null || pip install uv) && uv lock --upgrade-package python-roborock && git add uv.lock && uv build" changelog_file = 'CHANGELOG.md' commit = true diff --git a/uv.lock b/uv.lock index 33b99dde2..996eeebe9 100644 --- a/uv.lock +++ b/uv.lock @@ -330,6 +330,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/33/6b/e0547afaf41bf2c42e52430072fa5658766e3d65bd4b03a563d1b6336f57/distlib-0.4.0-py2.py3-none-any.whl", hash = "sha256:9659f7d87e46584a30b5780e43ac7a2143098441670ff0a49d5f9034c54a6c16", size = 469047, upload-time = "2025-07-17T16:51:58.613Z" }, ] +[[package]] +name = "execnet" +version = "2.1.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bf/89/780e11f9588d9e7128a3f87788354c7946a9cbb1401ad38a48c4db9a4f07/execnet-2.1.2.tar.gz", hash = "sha256:63d83bfdd9a23e35b9c6a3261412324f964c2ec8dcd8d3c6916ee9373e0befcd", size = 166622, upload-time = "2025-11-12T09:56:37.75Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ab/84/02fc1827e8cdded4aa65baef11296a9bbe595c474f0d6d758af082d849fd/execnet-2.1.2-py3-none-any.whl", hash = "sha256:67fba928dd5a544b783f6056f449e5e3931a5c378b128bc18501f7ea79e296ec", size = 40708, upload-time = "2025-11-12T09:56:36.333Z" }, +] + [[package]] name = "filelock" version = "3.20.0" @@ -1343,6 +1352,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/fa/b6/3127540ecdf1464a00e5a01ee60a1b09175f6913f0644ac748494d9c4b21/pytest_timeout-2.4.0-py3-none-any.whl", hash = "sha256:c42667e5cdadb151aeb5b26d114aff6bdf5a907f176a007a30b940d3d865b5c2", size = 14382, upload-time = "2025-05-05T19:44:33.502Z" }, ] +[[package]] +name = "pytest-xdist" +version = "3.8.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "execnet" }, + { name = "pytest" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/78/b4/439b179d1ff526791eb921115fca8e44e596a13efeda518b9d845a619450/pytest_xdist-3.8.0.tar.gz", hash = "sha256:7e578125ec9bc6050861aa93f2d59f1d8d085595d6551c2c90b6f4fad8d3a9f1", size = 88069, upload-time = "2025-07-01T13:30:59.346Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ca/31/d4e37e9e550c2b92a9cbc2e4d0b7420a27224968580b5a447f420847c975/pytest_xdist-3.8.0-py3-none-any.whl", hash = "sha256:202ca578cfeb7370784a8c33d6d05bc6e13b4f25b5053c30a152269fd10f0b88", size = 46396, upload-time = "2025-07-01T13:30:56.632Z" }, +] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -1393,6 +1415,7 @@ dev = [ { name = "pytest-benchmark" }, { name = "pytest-cov" }, { name = "pytest-timeout" }, + { name = "pytest-xdist" }, { name = "python-roborock", extra = ["cli"] }, { name = "ruff" }, { name = "syrupy" }, @@ -1434,6 +1457,7 @@ dev = [ { name = "pytest-benchmark", specifier = ">=5.1.0" }, { name = "pytest-cov", specifier = ">=7.0.0" }, { name = "pytest-timeout", specifier = ">=2.3.1,<3" }, + { name = "pytest-xdist", specifier = ">=3.8.0" }, { name = "python-roborock", extras = ["cli"] }, { name = "ruff", specifier = "==0.14.11" }, { name = "syrupy", specifier = ">=4.9.1,<6" },