Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI/CD by fixing clippy errors #40

Merged
merged 11 commits into from
Jul 6, 2024
Merged
29 changes: 13 additions & 16 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ name: CICD

env:
PROJECT_NAME: sqlite_zstd
#PROJECT_DESC: "sqlite ♥ zstd"
#PROJECT_AUTH: "bootandy"
#RUST_MIN_SRV: "1.31.0"

on: [push, pull_request]
on:
push:
branches:
- main
- master
pull_request:

jobs:
style:
Expand Down Expand Up @@ -65,21 +66,15 @@ jobs:
# { os, target, cargo-options, features, use-cross, toolchain }
- {
os: ubuntu-latest,
target: arm-unknown-linux-gnueabihf,
use-cross: use-cross,
target: x86_64-unknown-linux-gnu,
features: build_extension,
}
- {
os: ubuntu-18.04,
target: x86_64-unknown-linux-gnu,
os: ubuntu-latest,
target: arm-unknown-linux-gnueabihf,
use-cross: use-cross,
features: build_extension,
}
#- {
# os: ubuntu-18.04,
# target: x86_64-unknown-linux-musl,
# use-cross: use-cross,
# }
- {
os: macos-latest,
target: x86_64-apple-darwin,
Expand Down Expand Up @@ -171,9 +166,11 @@ jobs:
echo set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS:-<empty>/false}
echo ::set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS}
# * strip executable?
STRIP="strip" ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; *-pc-windows-msvc) STRIP="" ;; esac;
STRIP="strip" ; STRIP_PARAMS="" ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; *-pc-windows-msvc) STRIP="" ;; *-apple-darwin) STRIP_PARAMS="-x" ;; esac;
echo set-output name=STRIP::${STRIP}
echo ::set-output name=STRIP::${STRIP}
echo set-output name=STRIP_PARAMS::${STRIP_PARAMS}
echo ::set-output name=STRIP_PARAMS::${STRIP_PARAMS}
- name: Create all needed build/work directories
shell: bash
run: |
Expand Down Expand Up @@ -212,7 +209,7 @@ jobs:
# binary
cp 'target/${{ matrix.job.target }}/release/${{ steps.vars.outputs.LIB_FNAME }}' '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
# `strip` binary (if needed)
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/${{ steps.vars.outputs.LIB_FNAME }}' ; fi
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" ${{ steps.vars.outputs.STRIP_PARAMS }} '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/${{ steps.vars.outputs.LIB_FNAME }}' ; fi
# README and LICENSE
cp README.md '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
cp LICENSE '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
Expand Down
54 changes: 30 additions & 24 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
name: Publish to PyPI

on:
push:
workflow_dispatch:

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
name: Build wheels on ${{ matrix.os }} for ${{ matrix.cibw_python }} on ${{ matrix.cibw_arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
os: [ubuntu-latest]
cibw_arch: ["x86_64", "aarch64"]
env:
CIBW_BEFORE_ALL_LINUX: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y"
CIBW_BUILD_VERBOSITY: "1"
CIBW_SKIP: cp39-musllinux_i686 cp310-musllinux_i686 cp311-musllinux_i686 cp312-musllinux_i686 # Can't install Rust on musl based Linux systems
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"'

steps:
- uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v1
if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64'
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
with:
platforms: all
platforms: arm64

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: ${{ matrix.cibw_python }}
CIBW_ARCHS: ${{ matrix.cibw_arch }}
CIBW_TEST_SKIP: "*universal2:arm64"
with:
package-dir: ./python
output-dir: ./python/wheelhouse

- uses: actions/upload-artifact@v3
with:
name: wheel-${{ runner.os }}
name: dist
path: ./python/wheelhouse/*.whl

build_sdist:
Expand All @@ -51,7 +56,7 @@ jobs:
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: "3.9"
python-version: "3.12"

- name: Build sdist
run: |
Expand All @@ -61,20 +66,21 @@ jobs:

- uses: actions/upload-artifact@v2
with:
name: sdist-${{ runner.os }}
path: python/dist/*.tar.gz
name: dist
path: python/dist/*.tar.*

# release:
# needs: [build_wheels, build_sdist]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/download-artifact@v2
# with:
# name: artifact
# path: python/dist
release:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: python/dist/

# - uses: pypa/gh-action-pypi-publish@release/v1
# with:
# packages-dir: python/dist/
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
- uses: pypa/[email protected]
with:
repository-url: https://pypi.org/project/sqlite-zstd-build
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: python/dist
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allow-print-in-tests = true
6 changes: 3 additions & 3 deletions src/add_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub mod tests {
use super::*;
use anyhow::Context;
use chrono::TimeZone;
pub use pretty_assertions::{assert_eq, assert_ne};
pub use pretty_assertions::assert_eq;

use rusqlite::{params, Connection};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -148,7 +148,7 @@ pub mod tests {
];

let mut rng = rand::rngs::StdRng::seed_from_u64(seed);
let event_type_dist = WeightedIndex::new(&[10, 10, 1])?;
let event_type_dist = WeightedIndex::new([10, 10, 1])?;
let window_properties_dist = WeightedIndex::new(window_properties.iter().map(|e| e.0))?;
let app_id_dist = rand::distributions::Uniform::from(0..100);
let data = (0..eles).map(|_| match event_type_dist.sample(&mut rng) {
Expand Down Expand Up @@ -198,7 +198,7 @@ pub mod tests {
}

fn test_strings() -> anyhow::Result<Vec<String>> {
let data = vec![
let data = [
"hello this is a test",
"foobar",
"looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
Expand Down
10 changes: 5 additions & 5 deletions src/bin/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ impl Bench for SelectBench {
}
fn execute(&self, conn: &Connection) -> Result<i64> {
let mut stmt = conn.prepare("select data from title_basics where id = ?")?;
let mut total_len = 0;
let mut _total_len = 0;
for id in &self.ids {
let data: String = stmt.query_row(params![id], |r| r.get(0))?;
total_len += data.len();
_total_len += data.len();
}

// eprintln!("total bytes got: {}", total_len);
// eprintln!("total bytes got: {}", _total_len);
Ok(self.ids.len() as i64)
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ fn main() -> Result<()> {
.map(|preparer| {
eprintln!("running preparer {its_per_bench} times");
(0..its_per_bench)
.map(|i| preparer(&db1))
.map(|_i| preparer(&db1))
.collect::<Result<_, _>>()
.context("preparing benches")
})
Expand All @@ -237,7 +237,7 @@ fn main() -> Result<()> {
let db_path = Path::new(&location).join(file_name);
if !db_path.exists() {
eprintln!("copying {} -> {}", input_db, db_path.to_string_lossy());
std::fs::copy(&input_db, &db_path)?;
std::fs::copy(input_db, &db_path)?;
} else {
eprintln!(
"{} already exists, assuming it's the same",
Expand Down
8 changes: 4 additions & 4 deletions src/dict_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use zstd::dict::{DecoderDictionary, EncoderDictionary};

// TODO: the rust interface currently requires a level when preparing a dictionary, but the zstd interface (ZSTD_CCtx_loadDictionary) does not.
// TODO: Using LruCache here isn't very smart
pub fn encoder_dict_from_ctx<'a>(
ctx: &'a Context,
pub fn encoder_dict_from_ctx(
ctx: &Context,
arg_index: usize,
level: i32,
) -> anyhow::Result<Arc<EncoderDictionary<'static>>> {
Expand Down Expand Up @@ -48,8 +48,8 @@ pub fn encoder_dict_from_ctx<'a>(
Ok(res)
}

pub fn decoder_dict_from_ctx<'a>(
ctx: &'a Context,
pub fn decoder_dict_from_ctx(
ctx: &Context,
arg_index: usize,
) -> anyhow::Result<Arc<DecoderDictionary<'static>>> {
use lru_time_cache::LruCache;
Expand Down
Loading