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
2 changes: 1 addition & 1 deletion .github/alpine-vm/start-alpine-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ VM_BUILD_DIR="$REPO_ROOT/.alpine-vm-build"
VM_IMAGE="$VM_BUILD_DIR/alpine.qcow2"
VM_SSH_PORT="2222"
VM_CONSOLE_LOG="vm-console.log"
VM_PACKAGES="bluez poetry openssh uv"
VM_PACKAGES="bluez openssh uv"

# Colors for output
GREEN='\033[0;32m'
Expand Down
2 changes: 1 addition & 1 deletion .github/alpine-vm/vm-ssh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ssh -o StrictHostKeyChecking=no \
-o LogLevel=ERROR \
-p 2222 \
builder@localhost \
"cd ~/repo && $*"
"sh -l -c 'cd ~/repo && $*'"
37 changes: 20 additions & 17 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,45 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
env:
FORCE_COLOR: "1"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
id: py

- name: Install uv and set up Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Create virtual environment
run: pipx run poetry env use '${{ steps.py.outputs.python-path }}'

- name: Install dependencies
# work around https://github.com/python-poetry/poetry/issues/7161
env:
SYSTEM_VERSION_COMPAT: 0
run: pipx run poetry install --only main,test
run: |
uv tool install tox --with tox-uv
uv tool install poetry

- name: Test with pytest
run: pipx run poetry run pytest -v --cov-report=xml --junitxml=junit.xml -o junit_family=legacy
run: tox -m py${{ matrix.python-version }} -- -v --cov-report=xml --junitxml=junit.xml -o junit_family=legacy

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
report_type: coverage
flags: ${{ matrix.os }}-py${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
report_type: test_results
flags: ${{ matrix.os }}-py${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}

- name: Type checking
# We don't do this in the lint job because we have conditionals
# on both the platform and the Python version in the code, so we
# need to check each matrix combination.
run: |
pipx run poetry run pip install pyright
pipx run poetry run pyright
pipx run poetry run pip install mypy
pipx run poetry run mypy -p bleak -p tests -p examples
tox -m typecheck


integration_tests_bluez:
Expand All @@ -82,10 +83,12 @@ jobs:
run: |
./.github/alpine-vm/vm-ssh.sh '
bluetoothctl --version
echo "export PATH=\"\$HOME/.local/bin:\$PATH\"" >> ~/.profile
source ~/.profile
uv python install ${{ matrix.python-version }}
uv python pin ${{ matrix.python-version }}
poetry env use ${{ matrix.python-version }}
poetry install --only main,test
uv tool install tox --with tox-uv
uv tool install poetry
'

- name: Run pytest in VM
Expand All @@ -94,7 +97,7 @@ jobs:
export FORCE_COLOR=1
export CI=true
export GITHUB_ACTIONS=true
poetry run pytest -v tests --bleak-bluez-vhci -v --cov-report=xml --junitxml=junit.xml -o junit_family=legacy
tox -e py -- --bleak-bluez-vhci -v --cov-report=xml --junitxml=junit.xml -o junit_family=legacy
'

- name: Upload coverage reports to Codecov
Expand Down
25 changes: 16 additions & 9 deletions .github/workflows/format_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install development dependencies
run: pipx run poetry install --only docs,lint
- name: Check import sort with isort
run: pipx run poetry run isort {.,docs} --check --diff
- name: Check code formatting with black
run: pipx run poetry run black . --check --diff
- name: Lint with flake8
run: pipx run poetry run flake8 . --count --show-source --statistics

- name: Install uv and set up Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
uv tool install tox --with tox-uv
uv tool install poetry

- name: Check import sort with isort, code formatting with black, and lint with flake8
run: tox -e lint-checkonly

- name: Build docs
run: pipx run poetry run make -C docs html
run: tox -e docs

24 changes: 16 additions & 8 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ Get Started!

Ready to contribute? Here's how to set up ``bleak`` for local development.

You will need `Git <https://git-scm.com>`_ and `Poetry <https://python-poetry.org>`_
and your favorite text editor. And Python of course.
You will need `Git <https://git-scm.com>`_, `Poetry <https://python-poetry.org>`_,
`Tox <https://tox.wiki>`_ and your favorite text editor. And Python of course.

1. Fork the ``bleak`` repo on GitHub.
2. Clone your fork locally::
Expand All @@ -79,17 +79,25 @@ and your favorite text editor. And Python of course.

Now you can make your changes locally.

5. When you're done making changes, check that your changes pass linting and the tests::
5. When you're done making changes, check that your changes pass linting, type checking and the tests::

$ tox

$ poetry run isort .
$ poetry run black .
$ poetry run flake8
$ poetry run pytest
Alternatively, you can run the checks manually::

$ tox -e typecheck
$ tox -e lint
$ tox -e py310 # or any other supported Python version

6. Additionally, you can run integration tests by adding the ``--bleak-hci-transport`` argument to ``pytest``.
For more information, see `tests/integration/README.rst <tests/integration/README.rst>`_.

$ poetry run pytest --bleak-hci-transport=serial:/dev/tty.usbmodem1101
$ tox -- --bleak-hci-transport=serial:/dev/tty.usbmodem1101

Alternatively, you can run the checks only for one Python version, because integration tests are slow::

$ tox -e py310 -- --bleak-hci-transport=serial:/dev/tty.usbmodem1101


7. Commit your changes and push your branch to GitHub::

Expand Down
Loading