Skip to content

Commit

Permalink
apply pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarriba committed Jan 4, 2023
1 parent 2a29bb6 commit 2c9bd25
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 20 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Test Suite
runs-on: ubuntu-latest
steps:
-
-
name: Checkout the repository
uses: actions/checkout@v3
-
Expand All @@ -27,7 +27,7 @@ jobs:
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Compile and Run the tests
run: ./run_tests.sh
Expand All @@ -36,7 +36,7 @@ jobs:
name: Rustfmt
runs-on: ubuntu-latest
steps:
-
-
name: Checkout the repository
uses: actions/checkout@v3
-
Expand All @@ -49,12 +49,12 @@ jobs:
-
name: Compile and Run the tests
run: ./run_fmt.sh

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
-
-
name: Checkout the repository
uses: actions/checkout@v3
-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/devel_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push Docker image
uses: docker/build-push-action@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: messense/maturin-action@v1
with:
container: ghcr.io/kornia/kornia-rs/release:latest
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target: [x64, x86]
steps:
steps:
- uses: ilammy/setup-nasm@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push Docker image
uses: docker/build-push-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ docs/_build/
.vscode/

# Pyenv
.python-version
.python-version
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
hooks:
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pre-commit
rev: v2.5.1
hooks:
- id: validate_manifest
22 changes: 22 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- id: fmt
name: fmt
description: Format files with cargo fmt.
entry: cargo fmt
language: system
types: [rust]
args: ["--"]
- id: cargo-check
name: cargo check
description: Check the package for errors.
entry: cargo check
language: system
types: [rust]
pass_filenames: false
- id: clippy
name: clippy
description: Lint rust sources
entry: cargo clippy
language: system
args: ["--", "-D", "warnings"]
types: [rust]
pass_filenames: false
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ harness = false

[features]
default = []
viz = ["dep:vviz"]
viz = ["dep:vviz"]
2 changes: 1 addition & 1 deletion devel.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
$DIR/docker/devel.sh $@
$DIR/docker/devel.sh $@
5 changes: 5 additions & 0 deletions docker/devel.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ RUN apt-get update --fix-missing && \
apt-get clean

RUN pip3 install maturin[patchelf]
RUN pip3 install pre-commit

# add rust tools
RUN rustup component add rustfmt
RUN rustup component add clippy

WORKDIR /workspace
2 changes: 1 addition & 1 deletion kornia-rs.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"path": "."
}
]
}
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ dev = [
[project.urls]
homepage = "https://www.kornia.org"
documentation = "https://kornia.readthedocs.io"
repository = "https://github.com/kornia/kornia-rs"
repository = "https://github.com/kornia/kornia-rs"
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
$DIR/docker/release.sh $@
$DIR/docker/release.sh $@
2 changes: 1 addition & 1 deletion run_clippy.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash -e
./devel.sh "rustup component add clippy; cargo clippy -- -D warnings"
./devel.sh "rustup component add clippy; cargo clippy -- -D warnings"
2 changes: 1 addition & 1 deletion run_fmt.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash -e
./devel.sh "rustup component add rustfmt; cargo fmt --all -- --check"
./devel.sh "rustup component add rustfmt; cargo fmt --all -- --check"
2 changes: 1 addition & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash -e
./devel.sh "python3 -m venv .venv; source .venv/bin/activate; maturin develop --extras dev --all-features; pytest test/"
./devel.sh "python3 -m venv .venv; source .venv/bin/activate; maturin develop --extras dev --all-features; pytest test/"
Binary file added test/data/dog_rs.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ def test_decompress():
assert image_size.height == 195

decoded_tensor: K.cvTensor = image_decoder.decode(bytes(image_encoded))
decoded_image = np.from_dlpack(decoded_tensor)
decoded_image = np.from_dlpack(decoded_tensor)
2 changes: 1 addition & 1 deletion test/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def test_conversions2():
# to dlpack / torch / numpy
th_tensor = torch.utils.dlpack.from_dlpack(cv_tensor)
np_array = np.from_dlpack(cv_tensor)
np.testing.assert_array_equal(np_array, th_tensor.numpy())
np.testing.assert_array_equal(np_array, th_tensor.numpy())

0 comments on commit 2c9bd25

Please sign in to comment.