Skip to content
This repository was archived by the owner on Jul 25, 2022. It is now read-only.

Commit eaf94da

Browse files
authored
ci: test against more compilers, setup clippy and fix clippy lints (#9)
* ci: add more variations to ci * Remove toolchain file job * Fix matrix references
1 parent 4a69119 commit eaf94da

File tree

4 files changed

+43
-27
lines changed

4 files changed

+43
-27
lines changed

.github/workflows/test.yaml

+34-21
Original file line numberDiff line numberDiff line change
@@ -22,50 +22,66 @@ on:
2222
pull_request:
2323
branches: [ main ]
2424

25+
concurrency:
26+
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
27+
cancel-in-progress: true
28+
2529
jobs:
26-
test:
30+
test-matrix:
2731
runs-on: ubuntu-latest
2832
strategy:
2933
fail-fast: false
3034
matrix:
3135
python-version:
3236
- "3.7"
3337
- "3.10"
38+
toolchain:
39+
- stable
40+
- beta
41+
- nightly
3442
steps:
3543
- uses: actions/checkout@v2
3644

37-
- name: Cache Cargo
38-
uses: actions/cache@v2
39-
with:
40-
path: /home/runner/.cargo
41-
key: cargo-maturin-cache-${{ hashFiles('Cargo.lock') }}
42-
4345
- name: Setup Rust Toolchain
4446
uses: actions-rs/toolchain@v1
47+
id: rust-toolchain
4548
with:
46-
toolchain: stable
47-
profile: default
49+
toolchain: ${{ matrix.toolchain }}
4850
override: true
4951

50-
- name: Cargo Clippy
51-
run: cargo clippy
52-
53-
- name: Cargo Check
54-
run: cargo check --all --frozen --locked
55-
56-
- name: Setup Python Toolchain
52+
- name: Setup Python
5753
uses: actions/setup-python@v2
5854
with:
5955
python-version: ${{ matrix.python-version }}
6056

57+
- name: Cache Cargo
58+
uses: actions/cache@v2
59+
with:
60+
path: ~/.cargo
61+
key: cargo-cache-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('Cargo.lock') }}
62+
63+
- name: Check Formatting
64+
uses: actions-rs/cargo@v1
65+
if: ${{ matrix.python-version == '3.10' && matrix.toolchain == 'stable' }}
66+
with:
67+
command: fmt
68+
args: -- --check
69+
70+
- name: Run Clippy
71+
uses: actions-rs/cargo@v1
72+
if: ${{ matrix.python-version == '3.10' && matrix.toolchain == 'stable' }}
73+
with:
74+
command: clippy
75+
args: --all-targets --all-features -- -D clippy::all
76+
6177
- name: Create Virtualenv
6278
run: |
6379
python -m venv venv
6480
source venv/bin/activate
6581
pip install -r requirements.txt
6682
67-
- name: Run Linters
68-
if: ${{ matrix.python-version == '3.10' }}
83+
- name: Run Python Linters
84+
if: ${{ matrix.python-version == '3.10' && matrix.toolchain == 'stable' }}
6985
run: |
7086
source venv/bin/activate
7187
flake8 --exclude venv --ignore=E501
@@ -76,6 +92,3 @@ jobs:
7692
source venv/bin/activate
7793
maturin develop --cargo-extra-args='--locked'
7894
RUST_BACKTRACE=1 pytest -v .
79-
env:
80-
CARGO_HOME: "/home/runner/.cargo"
81-
CARGO_TARGET_DIR: "/home/runner/target"

src/context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ impl PyExecutionContext {
9999
Ok(())
100100
}
101101

102+
#[allow(clippy::too_many_arguments)]
102103
#[args(
103104
schema = "None",
104105
has_header = "true",
@@ -119,7 +120,7 @@ impl PyExecutionContext {
119120
) -> PyResult<()> {
120121
let path = path
121122
.to_str()
122-
.ok_or(PyValueError::new_err("Unable to convert path to a string"))?;
123+
.ok_or_else(|| PyValueError::new_err("Unable to convert path to a string"))?;
123124
let delimiter = delimiter.as_bytes();
124125
if delimiter.len() != 1 {
125126
return Err(PyValueError::new_err(

src/expression.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ impl From<PyExpr> for Expr {
3737
}
3838
}
3939

40-
impl Into<PyExpr> for Expr {
41-
fn into(self) -> PyExpr {
42-
PyExpr { expr: self }
40+
impl From<Expr> for PyExpr {
41+
fn from(expr: Expr) -> PyExpr {
42+
PyExpr { expr }
4343
}
4444
}
4545

src/functions.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,13 @@ fn window(
119119
expr: datafusion::logical_plan::Expr::WindowFunction {
120120
fun,
121121
args: args.into_iter().map(|x| x.expr).collect::<Vec<_>>(),
122-
partition_by: partition_by.unwrap_or_default()
122+
partition_by: partition_by
123+
.unwrap_or_default()
123124
.into_iter()
124125
.map(|x| x.expr)
125126
.collect::<Vec<_>>(),
126-
order_by: order_by.unwrap_or_default()
127+
order_by: order_by
128+
.unwrap_or_default()
127129
.into_iter()
128130
.map(|x| x.expr)
129131
.collect::<Vec<_>>(),

0 commit comments

Comments
 (0)