Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ updates:
actions-deps:
patterns:
- "*"

- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "monthly"
commit-message:
prefix: "uv: "
labels: []
groups:
python-deps:
patterns:
- "*"
11 changes: 6 additions & 5 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ jobs:
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.13"
- name: Install Python dependencies
run: |
pip3 install build

- name: Install uv
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0

- name: Build a binary wheel and a source tarball
run: |
python -m build
run: uv build

- name: Store the distribution packages
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/test-distros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ jobs:
- name: Display Python version
run: python3 -c "import sys; print(sys.version); print(sys.platform)"

- name: Install tox
run: pip3 install tox --break-system-packages
- name: Install uv
run: pip3 install uv --break-system-packages
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GH runners are ephemeral so it does really matter but... just for better "role-modelling" maybe?

Suggested change
run: pip3 install uv --break-system-packages
run: pipx install uv

Only if pipx is available by default, otherwise forget it.


- name: Run tox
run: tox -- -W error
- name: Install Python dependencies
run: uv sync --frozen

- name: Run tasks
run: uv run poe all
14 changes: 8 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ jobs:
path: "./check out"
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
- name: Install uv
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
with:
python-version: ${{ matrix.python-version }}
working-directory: './check out/'
enable-cache: true

- name: Display Python version
run: python -c "import sys; print(sys.version); print(sys.platform)"

- name: Install tox
run: pip3 install tox
- name: Setup project
run: uv sync --frozen --directory "./check out/"

- name: Run tox
run: tox -c 'check out' -- -W error
- name: Run tasks
run: uv run --frozen --directory "./check out/" poe all
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you not run "all" here to provide finer-grained results? And durations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is close to what tox did, so I'll leave it for now. I think we should split indeed, but also reduce the matrix a bit. We don't need to run the linter task 15 times. Will follow-up!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


- name: Upload coverage reports
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
Expand Down
7 changes: 2 additions & 5 deletions MAINTAINERS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ Pre-release test plan

git checkout vX.Y-branch

1. Make tox happy on the following first-party non-Linux platforms:
1. Make testing happy on the following first-party non-Linux platforms:

- Windows 10
- the latest macOS

Do this by hand and check for any anomalous warnings in the output.
Do not just trust CI.

2. Make tox happy on other popular Linux distributions:
2. Make testing happy on other popular Linux distributions:

- Arch
- the latest Ubuntu development release
Expand All @@ -32,9 +32,6 @@ Pre-release test plan
Automated infrastructure for doing this using docker is in the
test-distros.yml workflow action on Github.

Make sure to check the tox.log files mentioned in the output for any
anomalous warnings.

3. Build alpha N (N=1 to start, then N=2 if you need more commits, etc.) and
upload to pypi. See "Building and uploading the release wheels" below for
a procedure.
Expand Down
44 changes: 27 additions & 17 deletions README.rst
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new version of the README.rst seems to hesitate between embracing the new uv and poe approaches for "advanced" developers and sticking to the old pip ways for more basic stuff... I feel like this could needs more review time but I don't have that now. As long as all the examples were tested and do work, then good enough for now! Can be polished later after merging this. The README.rst tail should not wag the uv dog and delay this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to keep options open for developers.

BTW, I intend to re-vamp the readme together with moving the docs from Zephyr to a West site, and create a dedicated page for testing west itself.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big doc move WIP in:

Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ You can create a wheel package and distribute it to others.

To build the west wheel file::

# Using uv
uv build

# Without uv
pip3 install --upgrade build
python -m build

Expand All @@ -134,33 +138,39 @@ version from PyPI, etc.
Running the Tests
~~~~~~~~~~~~~~~~~

First, install tox::
First, install the dependencies::

# macOS, Windows
pip3 install tox
# Using uv
uv sync --frozen

# Linux
pip3 install --user tox
# Using pip (requires v25.1 or newer)
# Recommended in an active virtual environment
pip3 install --group dev

Then, run the test suite locally from the top level directory::

tox
# Using uv
uv run poe all

# Using poe
# Recommended in an active virtual environment
poe all

# Manually
pytest

You can use ``--`` to tell tox to pass arguments to ``pytest``. This is
especially useful to focus on specific tests and save time. Examples::
The ``all`` target from ``poe`` runs multiple tasks sequentially. Run ``poe -h``
to get the list of configured tasks.
You can pass arguments to the task running ``poe``. This is especially useful
on specific tests and save time. Examples::

# Run a subset of tests
tox -- tests/test_project.py
poe test tests/test_project.py

# Debug the ``test_update_narrow()`` code with ``pdb`` (but _not_ the
# Run the ``test_update_narrow()`` code with ``pdb`` (but _not_ the
# west code which is running in subprocesses)
tox -- --verbose --exitfirst --trace -k test_update_narrow
poe test --exitfirst --trace -k test_update_narrow

# Run all tests with "import" in their name and let them log to the
# current terminal
tox -- -v -k import --capture=no

The tests cannot be run with ``pytest`` directly, they require the tox
environment.

See the tox configuration file, tox.ini, for more details.
poe test -k import --capture=no
43 changes: 39 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ classifiers = [
]
requires-python = ">=3.10"
dependencies = [
"colorama",
"PyYAML>=5.1",
"pykwalify",
"packaging",
"colorama~=0.4",
"packaging~=25.0",
"pykwalify~=1.8",
"pyyaml~=6.0",
]
license = "Apache-2.0"
license-files = ["LICENSE"]
Expand All @@ -36,6 +36,26 @@ Homepage = "https://github.com/zephyrproject-rtos/west"
[project.scripts]
west = "west.app.main:main"

[dependency-groups]
lint = [
"ruff~=0.13",
]
test = [
"coverage~=7.10",
"pytest~=8.4",
"pytest-cov~=7.0",
]
types = [
"mypy~=1.18",
"types-pyyaml~=6.0",
]
dev = [
"poethepoet~=0.37",
{include-group = "lint"},
{include-group = "test"},
{include-group = "types"},
]

[tool.setuptools]
package-dir = {"" = "src"}
zip-safe = false
Expand All @@ -55,6 +75,8 @@ omit = [
[tool.coverage.report]
omit = [
"*/tmp/*",
"net-tools/scripts/test.py",
"subdir/Kconfiglib/scripts/test.py",
]

[tool.coverage.paths]
Expand All @@ -80,3 +102,16 @@ extend-select = [
[tool.ruff.format]
quote-style = "preserve"
line-ending = "lf"

[tool.mypy]
mypy_path = "src"
ignore_missing_imports = true

[tool.poe.tasks.test]
cmd = "python -m pytest -v -W error --junitxml=junit.xml -o junit_family=xunit1 --cov-report=html --cov-config=pyproject.toml --cov=west"
env = {PYTHONIOENCODING = "utf-8"}

[tool.poe.tasks]
lint = "ruff check ."
types = "mypy --package west"
all = ["test", "lint", "types"]
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2019, 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -87,12 +87,12 @@
pass

@pytest.fixture(scope='session')
def _session_repos():
def _session_repos(tmp_path_factory):
'''Just a helper, do not use directly.'''

# It saves time to create repositories once at session scope, then
# clone the results as needed in per-test fixtures.
session_repos = os.path.join(os.environ['TOXTEMPDIR'], 'session_repos')
session_repos = str(tmp_path_factory.mktemp('session_repos'))
print('initializing session repositories in', session_repos)
shutil.rmtree(session_repos, ignore_errors=True)

Expand Down
3 changes: 0 additions & 3 deletions tests/test_alias.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Copyright (c) 2024, Basalte bv
#
# SPDX-License-Identifier: Apache-2.0

import os
import subprocess

import pytest
from conftest import cmd

assert 'TOXTEMPDIR' in os.environ, "you must run these tests using tox"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I'm finally understanding the "detox" pun :-)

This would be great: because of too many layers, so far my only solution to run a test in a debugger was PUDB_TTY. It worked... only most of the time!

Don't forget to update b7e091d

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless... the uv replacement merely substitutes another layer of indirection, still getting in the way and still making it hard to run a test in a debugger directly?

Sorry for thinking out loud. Hey it's just a draft PR ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to reduce the layering too, it should be possible to run pytest directly IMO. uv is an optional utility, but I do want to make it the default for running in CI.



@pytest.fixture(autouse=True)
def autouse_tmpdir(config_tmpdir, west_init_tmpdir):
Expand Down
4 changes: 0 additions & 4 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# Copyright (c) 2021, Nordic Semiconductor ASA

import os

import pytest

from west.commands import Verbosity, WestCommand

assert 'TOXTEMPDIR' in os.environ, "you must run these tests using tox"

gv = WestCommand._parse_git_version


Expand Down
2 changes: 0 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2019, Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
Expand All @@ -14,8 +14,6 @@
from west import configuration as config
from west.util import PathType

assert 'TOXTEMPDIR' in os.environ, "you must run these tests using tox"

SYSTEM = config.ConfigFile.SYSTEM
GLOBAL = config.ConfigFile.GLOBAL
LOCAL = config.ConfigFile.LOCAL
Expand Down
1 change: 0 additions & 1 deletion tests/test_help.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2020, Nordic Semiconductor ASA

import itertools
Expand All @@ -8,7 +8,6 @@

from west.app.main import BUILTIN_COMMAND_GROUPS

assert 'TOXTEMPDIR' in os.environ, "you must run these tests using tox"

def test_builtin_help_and_dash_h(west_init_tmpdir):
# Test "west help" and "west -h" are the same for built-in
Expand Down
2 changes: 0 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import os
import subprocess
import sys

import west.version

assert 'TOXTEMPDIR' in os.environ, "you must run these tests using tox"

def test_main():
# A quick check that the package can be executed as a module which
Expand Down
2 changes: 0 additions & 2 deletions tests/test_manifest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright 2018 Foundries.io Ltd
# Copyright (c) 2020, Nordic Semiconductor ASA
#
Expand Down Expand Up @@ -53,8 +53,6 @@
validate,
)

assert 'TOXTEMPDIR' in os.environ, "you must run these tests using tox"

FPI = ImportFlag.FORCE_PROJECTS # to force project imports to use the callback

if platform.system() == 'Windows':
Expand Down
2 changes: 0 additions & 2 deletions tests/test_project.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2020, Nordic Semiconductor ASA

import collections
Expand Down Expand Up @@ -28,8 +28,6 @@
from west.manifest import ImportFlag as MIF
from west.manifest import Manifest, ManifestImportFailed, ManifestProject, Project

assert 'TOXTEMPDIR' in os.environ, "you must run these tests using tox"

#
# Helpers
#
Expand Down
2 changes: 0 additions & 2 deletions tests/test_project_caching.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2020, Nordic Semiconductor ASA

import os
Expand All @@ -18,8 +18,6 @@
rev_parse,
)

assert 'TOXTEMPDIR' in os.environ, "you must run these tests using tox"

#
# Helpers
#
Expand Down
44 changes: 0 additions & 44 deletions tox.ini

This file was deleted.

Loading
Loading