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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
e2e
- name: Run isort
uses: isort/isort-action@v1
- name: Formatting hint
if: failure()
run: |
echo "::notice::PROTIP: You can install pre-commit hooks to automatically format your code before each commit. Run 'uv run pre-commit install' and never have to resubmit a PR because of formatting errors! See CONTRIBUTING.md for more details."
typing:
Expand Down
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.6
hooks:
- id: ruff
args: [--fix]
files: ^(pystemd|examples|tests|e2e)/
- id: ruff-format
files: ^(pystemd|examples|tests|e2e)/
- repo: https://github.com/pycqa/isort
rev: 6.0.0
hooks:
- id: isort
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,61 @@ possible.
We use GitHub issues to track public bugs. Please ensure your description is
clear and has sufficient instructions to be able to reproduce the issue.

## Development setup

### Prerequisites
Install [uv](https://docs.astral.sh/uv/getting-started/installation/) if you don't have it already:


### Installing dependencies
After cloning the repository, install the development dependencies:

```bash
uv sync --all-extras
```

### Running tests
Run the unit tests with:

```bash
uv run pytest tests
```

Or with coverage:

```bash
uv run pytest --cov=pystemd tests
```

### Running E2E tests
The E2E tests run in a systemd container using mkosi and are primarily designed
for CI. To run them locally, you need `mkosi` and `systemd-container` installed.
See `.github/workflows/e2e-tests.yml` for the full setup. For most contributions,
unit tests are sufficient.

### Formatting code
Format your code before submitting a pull request:

```bash
uv run ruff check --fix pystemd examples tests e2e
uv run ruff format pystemd examples tests e2e
uv run isort .
```

### Type checking
We use [pyrefly](https://github.com/facebook/pyrefly) for type checking. Run it with:

```bash
uv run pyrefly check pystemd examples tests
```

Optionally, you can install pre-commit hooks to automatically format code on
each commit:

```bash
uv run pre-commit install
```

## Sending a pull request
Have a fix or feature? Awesome! When you send the pull request we suggest you
include a build output.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ lint = [
"ruff",
"pyrefly",
"isort",
"pre-commit",
]

[project.urls]
Expand Down