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
142 changes: 10 additions & 132 deletions .github/workflows/check-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]

## Allow running workflow manually from the Actions tab
workflow_dispatch:
inputs:
verbose:
Expand All @@ -24,20 +23,14 @@ env:
VERBOSE: ${{ github.event.inputs.verbose }}

jobs:
# runs cargo fmt
cargo-fmt:
name: cargo fmt
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-check-rust') }}
env:
RUST_BACKTRACE: full
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
- name: Check-out repository
uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential

- name: Install Rust Nightly
run: |
rustup install nightly
Expand All @@ -49,15 +42,12 @@ jobs:
- name: cargo fmt
run: cargo +nightly fmt --check --all

cargo-clippy-default-features:
cargo-clippy:
name: cargo clippy
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-check-rust') }}
env:
RUST_BACKTRACE: full
SKIP_WASM_BUILD: 1
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
- name: Check-out repository
uses: actions/checkout@v4

- name: Install dependencies
Expand All @@ -68,45 +58,15 @@ jobs:
- name: Utilize Shared Rust Cache
uses: Swatinem/rust-cache@v2

- name: cargo clippy --workspace --all-targets -- -D warnings
- name: cargo clippy (default features)
run: cargo clippy --workspace --all-targets -- -D warnings

cargo-check-lints:
name: check custom lints
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-check-rust') }}
env:
RUSTFLAGS: -D warnings
RUST_BACKTRACE: full
SKIP_WASM_BUILD: 1
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler

- name: Utilize Shared Rust Cache
uses: Swatinem/rust-cache@v2

- name: check lints
run: |
set -o pipefail
cargo check 2>&1 | sed -r "s/\x1B\[[0-9;]*[mK]//g" | grep "warning:" && exit 1
echo "No warnings found."


cargo-clippy-all-features:
name: cargo clippy --all-features
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-check-rust') }}
env:
RUST_BACKTRACE: full
SKIP_WASM_BUILD: 1
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
- name: Check-out repository
uses: actions/checkout@v4

- name: Install dependencies
Expand All @@ -117,19 +77,15 @@ jobs:
- name: Utilize Shared Rust Cache
uses: Swatinem/rust-cache@v2

- name: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: cargo clippy --all-features
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

# runs cargo test --workspace --all-features
cargo-test:
name: cargo test
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-check-rust') }}
env:
RUST_BACKTRACE: full
SKIP_WASM_BUILD: 1
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
- name: Check-out repository
uses: actions/checkout@v4

- name: Install dependencies
Expand All @@ -140,74 +96,15 @@ jobs:
- name: Utilize Shared Rust Cache
uses: Swatinem/rust-cache@v2

- name: cargo test --workspace --all-features
run: cargo test --workspace --all-features

# ensures cargo fix has no trivial changes that can be applied
cargo-fix:
name: cargo fix
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-check-rust') }}
env:
RUST_BACKTRACE: full
SKIP_WASM_BUILD: 1
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler

- name: Utilize Shared Rust Cache
uses: Swatinem/rust-cache@v2

- name: cargo fix --workspace
run: |
# Run cargo fix on the project
cargo fix --workspace

# Check for local git changes
if ! git diff --exit-code; then
echo "There are local changes after running 'cargo fix --workspace' ❌"
exit 1
else
echo "No changes detected after running 'cargo fix --workspace' ✅"
fi

cargo-check-no-python:
name: cargo check (no python)
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-check-rust') }}
env:
RUST_BACKTRACE: full
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler

- name: Utilize Shared Rust Cache
uses: Swatinem/rust-cache@v2

- name: cargo check --no-default-features
run: cargo check --no-default-features

- name: cargo test --no-default-features --lib
run: cargo test --no-default-features --lib
- name: cargo test --all-features
run: cargo test --workspace --all-features --lib --tests

cargo-package-check:
name: cargo package (dry-run)
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-check-rust') }}
env:
RUST_BACKTRACE: full
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
- name: Check-out repository
uses: actions/checkout@v4

- name: Install dependencies
Expand All @@ -220,22 +117,3 @@ jobs:

- name: cargo package (dry-run)
run: cargo package --no-verify

check-feature-propagation:
name: zepter run check
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-check-rust') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Dont clone historic commits.

- name: Utilize Shared Rust Cache
uses: Swatinem/rust-cache@v2

- name: Install Zepter
run: cargo install --locked -q zepter && zepter --version

- name: Check features
run: zepter run check
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ cython_debug/
# These are backup files generated by rustfmt
**/*.rs.bk

.DS_Store
**/.DS_Store

# The cache for docker container dependency
.cargo
Expand Down
39 changes: 16 additions & 23 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ version = "0.9"
optional = true
features = ["vendored"]

[package.metadata.docs.rs]
features = ["vendored-openssl"]
targets = ["x86_64-unknown-linux-gnu"]

[features]
default = []
python-bindings = ["dep:pyo3"]
Expand Down
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.PHONY: fmt fmt-check clippy clippy-all test package check

# Auto-format code (nightly rustfmt)
fmt:
rustup run nightly cargo fmt --all

# Check formatting without changes
fmt-check:
rustup run nightly cargo fmt --check --all

# Lint with default features (no pyo3)
clippy:
cargo clippy --workspace --all-targets -- -D warnings

# Lint with all features (including pyo3)
clippy-all:
cargo clippy --workspace --all-targets --all-features -- -D warnings

# Run unit tests (skip doctests)
test:
cargo test --workspace --all-features --lib --tests

# Verify crate packaging
package:
cargo package --no-verify --allow-dirty

# Run all checks sequentially
check: fmt-check clippy clippy-all test package
Loading
Loading