Skip to content

Commit 830ce44

Browse files
authored
Merge pull request #186 from Peter554/add-clippy
Add clippy to lint rust code
2 parents 6076f49 + c12e5f1 commit 830ce44

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

.github/workflows/main.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12-
tests:
13-
name: Python ${{ matrix.python-version }}, ${{ matrix.os }}
12+
check_python:
13+
name: Check Python ${{ matrix.python-version }}, ${{ matrix.os }}
1414
runs-on: ${{ matrix.os }}
1515

1616
strategy:
@@ -22,14 +22,9 @@ jobs:
2222

2323
steps:
2424
- uses: actions/checkout@v4
25-
2625
- uses: actions-rs/toolchain@v1
2726
with:
2827
toolchain: stable
29-
30-
- run: cargo test --no-default-features
31-
working-directory: ./rust
32-
3328
- uses: actions/setup-python@v5
3429
with:
3530
python-version: ${{ matrix.python-version }}
@@ -43,6 +38,21 @@ jobs:
4338
- name: Run tox targets for ${{ matrix.python-version }}
4439
run: python -m tox
4540

41+
check_rust:
42+
name: Check Rust
43+
runs-on: ubuntu-22.04
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: actions-rs/toolchain@v1
47+
with:
48+
toolchain: stable
49+
- name: Run tests
50+
run: cargo test --no-default-features
51+
working-directory: ./rust
52+
- name: Run linter (clippy)
53+
run: cargo clippy --all-targets --all-features -- -D warnings
54+
working-directory: ./rust
55+
4656
benchmarks:
4757
runs-on: ubuntu-22.04
4858
steps:

CONTRIBUTING.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ To set up `grimp` for local development:
6161

6262
6. Submit a pull request through the GitHub website.
6363

64+
Rust code
65+
---------
66+
67+
When working with the rust code (in the ``rust/`` directory):
68+
69+
* Run tests with ``cargo test --no-default-features``.
70+
The ``--no-default-features`` flag is needed to due to `this PYO3 issue <https://pyo3.rs/main/faq#i-cant-run-cargo-test-or-i-cant-build-in-a-cargo-workspace-im-having-linker-issues-like-symbol-not-found-or-undefined-reference-to-_pyexc_systemerror>`_.
71+
* Run `clippy <https://doc.rust-lang.org/clippy/index.html>`_ (a linter for rust) with ``cargo clippy --all-targets --all-features -- -D warnings``.
72+
It's often possible to apply automatic fixes to clippy issues with the ``--fix`` flag e.g. ``cargo clippy --all-targets --all-features --fix --allow-staged``.
73+
6474
Pull Request Guidelines
6575
-----------------------
6676

0 commit comments

Comments
 (0)