Skip to content

Commit 2e6c1fa

Browse files
authored
Merge pull request #12 from larsks/feature/pre-commit
Add pre-commit configuration and github workflows
2 parents 6c132de + 764e42b commit 2e6c1fa

File tree

18 files changed

+726
-18
lines changed

18 files changed

+726
-18
lines changed

.github/dependabot.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Set update schedule for GitHub Actions
2+
3+
version: 2
4+
updates:
5+
6+
- package-ecosystem: "github-actions"
7+
directory: "/"
8+
schedule:
9+
# Check for updates to GitHub Actions every week
10+
interval: "weekly"

.github/workflows/precommit.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Run pre-commit checks
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-python@v5
13+
with:
14+
python-version: "3.10"
15+
- name: Set up uv
16+
uses: astral-sh/setup-uv@v5
17+
- name: Install dependencies
18+
run: |
19+
uv sync --all-groups
20+
- uses: pre-commit/[email protected]

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ check
22
__pycache__
33
.pytest_cache
44
.coverage
5-
htmlcov
5+
htmlcov

.pre-commit-config.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
repos:
2+
- repo: https://github.com/Lucas-C/pre-commit-hooks
3+
rev: v1.5.5
4+
hooks:
5+
- id: remove-tabs
6+
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v6.0.0
9+
hooks:
10+
- id: trailing-whitespace
11+
- id: check-merge-conflict
12+
- id: end-of-file-fixer
13+
- id: check-added-large-files
14+
- id: check-case-conflict
15+
- id: check-json
16+
- id: check-symlinks
17+
- id: detect-private-key
18+
19+
- repo: https://github.com/adrienverge/yamllint.git
20+
rev: v1.37.1
21+
hooks:
22+
- id: yamllint
23+
24+
- repo: https://github.com/astral-sh/ruff-pre-commit
25+
rev: v0.14.2
26+
hooks:
27+
- id: ruff-check
28+
- id: ruff-format
29+
30+
- repo: local
31+
hooks:
32+
- id: unit-tests
33+
name: Run unit tests
34+
entry: uv run pytest
35+
language: python
36+
types:
37+
- python
38+
pass_filenames: false

.yamllint.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
extends: default
2+
rules:
3+
line-length: disable
4+
document-start: disable
5+
indentation:
6+
indent-sequences: whatever
7+
hyphens:
8+
max-spaces-after: 4
9+
truthy:
10+
check-keys: false

README.md

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,66 @@
11
# python-batchtools
22

3-
## Setting up your development environment
3+
## Set up your development environment
44

5-
Install [uv](https://github.com/astral-sh/uv), then run:
5+
### Install tools
6+
7+
1. Start by installing `uv`. Depending on your distribution, this may be as simple as:
8+
9+
```sh
10+
sudo dnf -y install uv
11+
```
12+
13+
If you would like to run the latest version, you can install the command using `pipx`. First, install `pipx`:
14+
15+
```
16+
sudo dnf -y install pipx
17+
```
18+
19+
And then use `pipx` to install `uv`:
20+
21+
```
22+
pipx install uv
23+
```
24+
25+
2. Next, install `pre-commit`. As with `uv`, you can install this using your system package manager:
26+
27+
```
28+
sudo dnf -y install pre-commit
29+
```
30+
31+
Or you can install a possibly more recent version using `pipx`:
32+
33+
```
34+
pipx install pre-commit
35+
```
36+
37+
38+
### Activate pre-commit
39+
40+
Activate `pre-commit` for your working copy of this repository by running:
41+
42+
```
43+
pre-commit install
44+
```
45+
46+
This will configure `.git/hooks/pre-commit` to run the `pre-commit` tool every time you make a commit. Running these tests locally ensures that your code is clean and that tests are passing before you share your code with others. To manually run all the checks:
47+
48+
```
49+
pre-commit run --all-files
50+
```
51+
52+
53+
### Install dependencies
54+
55+
To install the project dependencies, run:
656
757
```
858
uv sync --all-extras
959
```
1060
11-
## Running tests
61+
### Run tests
1262
13-
To run the unit tests:
63+
To run just the unit tests:
1464
1565
```
1666
uv run pytest

bd.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from typing import cast
2-
import typing_extensions
32
from typing_extensions import override
43

54
import argparse

bj.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import typing_extensions
21
from typing_extensions import override
32

43
import argparse

bl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import typing_extensions
21
from typing_extensions import override
32
from typing import cast
43

bp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from typing import cast
2-
import typing_extensions
32
from typing_extensions import override
43

54
import argparse

0 commit comments

Comments
 (0)