Skip to content

Commit

Permalink
Added nox for testing, hatch as build backend
Browse files Browse the repository at this point in the history
- Also removed flake8, covered by ruff
- Testing major Python versions 3.10-3.13

Signed-off-by: Sebastian Schleemilch <[email protected]>
  • Loading branch information
sschleemilch authored and erikbosch committed Nov 19, 2024
1 parent c1eac3a commit eae6f36
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 55 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/buildcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ jobs:
uses: astral-sh/setup-uv@v3
- name: Mypy
run: uv run mypy src
- name: flake8
run: |
uv run flake8 src tests contrib
- name: Run tests
run: |
uv run pytest --cov=vss_tools --cov-report=term-missing --cov-fail-under=88
run: uv run nox
- name: Test Binary Go Parser
run: |
cd binary/go_parser
Expand Down
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ See [usage](#usage) for how to start using it.

## Usage

General CLI help should be used for up to date info of how to use the tools.
General CLI help should be used for up-to-date info of how to use the tools.

```bash
# Help for toplevel options and lists sub commands
Expand Down Expand Up @@ -108,7 +108,6 @@ uv sync
```

It will create a `.venv` in the root of the project.

You can use the `venv` like you would without the usage of `uv`:

```bash
Expand All @@ -122,16 +121,30 @@ Alternatively you can use `uv` to run the `vspec` tool:
uv run vspec --help
```

If you have a working setup of [direnv](https://direnv.net/), just navigating into the directory
if enough (after an initial `uv sync`)
If you have a working setup of [direnv](https://direnv.net/), navigating into the directory
activates the `venv` (after an initial `uv sync` and `direnv allow`)

```bash
vspec --help
```

`uv` can manage independent python versions.
If you would like to use a specific python version (e.g. `python3.12`):

```bash
# Python 3.12
uv sync -p python3.12
# From the activated env:
python --version # --> Python 3.12.7

# Python 3.13
uv sync -p python3.13
python --version # --> Python 3.13.0
```

### Pre-commit

This project uses [pre-commit](https://pre-commit.com/) which helps formatting the source code in a streamlined way.
This project uses [pre-commit](https://pre-commit.com/) which helps to format the source code in a streamlined way.
It is very recommended to use it.
To install hooks you can do `pre-commit install` from an [activated environment](#uv).
Hooks will then run every time you do a `git commit` on changed files.
Expand Down
21 changes: 21 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import nox

PYTHON_VERSIONS = ["3.10", "3.13"]

nox.options.default_venv_backend = "uv"


@nox.session(python=PYTHON_VERSIONS)
def tests(session):
session.run_install(
"uv",
"sync",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run(
"pytest",
"--cov=vss_tools",
"--cov-report=term-missing",
"--cov-fail-under=88",
*session.posargs,
)
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ authors = [
license = {text = "Mozilla Public License 2.0"}

[project.urls]
homepage="https://github.com/COVESA/vss-tools"
Homepage="https://github.com/COVESA/vss-tools"
Issues = "https://github.com/COVESA/vss-tools/issues"
Changelog = "https://github.com/COVESA/vss-tools/blob/master/CHANGELOG.md"

[project.scripts]
vspec = "vss_tools.cli:cli"


[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.mypy]
disable_error_code = "import-untyped"

Expand All @@ -44,8 +51,8 @@ select = ["E", "F", "I"]

[dependency-groups]
dev = [
"flake8>=7.1.1",
"mypy>=1.13.0",
"nox>=2024.10.9",
"pre-commit>=4.0.1",
"pytest-cov>=6.0.0",
"pytest>=8.3.3",
Expand Down
120 changes: 77 additions & 43 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eae6f36

Please sign in to comment.