Skip to content

Commit 3a820f3

Browse files
authored
Merge pull request #40 from Mimoja/master
Fix CI/CD by fixing clippy errors
2 parents a484d2e + 874471c commit 3a820f3

6 files changed

Lines changed: 56 additions & 52 deletions

File tree

.github/workflows/cicd.yml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ name: CICD
44

55
env:
66
PROJECT_NAME: sqlite_zstd
7-
#PROJECT_DESC: "sqlite ♥ zstd"
8-
#PROJECT_AUTH: "bootandy"
9-
#RUST_MIN_SRV: "1.31.0"
10-
11-
on: [push, pull_request]
7+
on:
8+
push:
9+
branches:
10+
- main
11+
- master
12+
pull_request:
1213

1314
jobs:
1415
style:
@@ -65,21 +66,15 @@ jobs:
6566
# { os, target, cargo-options, features, use-cross, toolchain }
6667
- {
6768
os: ubuntu-latest,
68-
target: arm-unknown-linux-gnueabihf,
69-
use-cross: use-cross,
69+
target: x86_64-unknown-linux-gnu,
7070
features: build_extension,
7171
}
7272
- {
73-
os: ubuntu-18.04,
74-
target: x86_64-unknown-linux-gnu,
73+
os: ubuntu-latest,
74+
target: arm-unknown-linux-gnueabihf,
7575
use-cross: use-cross,
7676
features: build_extension,
7777
}
78-
#- {
79-
# os: ubuntu-18.04,
80-
# target: x86_64-unknown-linux-musl,
81-
# use-cross: use-cross,
82-
# }
8378
- {
8479
os: macos-latest,
8580
target: x86_64-apple-darwin,
@@ -171,9 +166,11 @@ jobs:
171166
echo set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS:-<empty>/false}
172167
echo ::set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS}
173168
# * strip executable?
174-
STRIP="strip" ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; *-pc-windows-msvc) STRIP="" ;; esac;
169+
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;
175170
echo set-output name=STRIP::${STRIP}
176171
echo ::set-output name=STRIP::${STRIP}
172+
echo set-output name=STRIP_PARAMS::${STRIP_PARAMS}
173+
echo ::set-output name=STRIP_PARAMS::${STRIP_PARAMS}
177174
- name: Create all needed build/work directories
178175
shell: bash
179176
run: |
@@ -212,7 +209,7 @@ jobs:
212209
# binary
213210
cp 'target/${{ matrix.job.target }}/release/${{ steps.vars.outputs.LIB_FNAME }}' '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
214211
# `strip` binary (if needed)
215-
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
212+
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
216213
# README and LICENSE
217214
cp README.md '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
218215
cp LICENSE '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'

.github/workflows/pypi_release.yml

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,44 @@
11
name: Publish to PyPI
22

33
on:
4-
push:
4+
workflow_dispatch:
55

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

1919
steps:
2020
- uses: actions/checkout@v4
2121

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

2828
- name: Build wheels
2929
uses: pypa/cibuildwheel@v2.16.2
30+
env:
31+
CIBW_BUILD_VERBOSITY: 1
32+
CIBW_BUILD: ${{ matrix.cibw_python }}
33+
CIBW_ARCHS: ${{ matrix.cibw_arch }}
34+
CIBW_TEST_SKIP: "*universal2:arm64"
3035
with:
3136
package-dir: ./python
3237
output-dir: ./python/wheelhouse
3338

3439
- uses: actions/upload-artifact@v3
3540
with:
36-
name: wheel-${{ runner.os }}
41+
name: dist
3742
path: ./python/wheelhouse/*.whl
3843

3944
build_sdist:
@@ -51,7 +56,7 @@ jobs:
5156
- uses: actions/setup-python@v2
5257
name: Install Python
5358
with:
54-
python-version: "3.9"
59+
python-version: "3.12"
5560

5661
- name: Build sdist
5762
run: |
@@ -61,20 +66,21 @@ jobs:
6166
6267
- uses: actions/upload-artifact@v2
6368
with:
64-
name: sdist-${{ runner.os }}
65-
path: python/dist/*.tar.gz
69+
name: dist
70+
path: python/dist/*.tar.*
6671

67-
# release:
68-
# needs: [build_wheels, build_sdist]
69-
# runs-on: ubuntu-latest
70-
# steps:
71-
# - uses: actions/download-artifact@v2
72-
# with:
73-
# name: artifact
74-
# path: python/dist
72+
release:
73+
needs: [build_wheels, build_sdist]
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/download-artifact@v3
77+
with:
78+
name: dist
79+
path: python/dist/
7580

76-
# - uses: pypa/gh-action-pypi-publish@release/v1
77-
# with:
78-
# packages-dir: python/dist/
79-
# user: __token__
80-
# password: ${{ secrets.PYPI_API_TOKEN }}
81+
- uses: pypa/gh-action-pypi-publish@v1.8.10
82+
with:
83+
repository-url: https://pypi.org/project/sqlite-zstd-build
84+
user: __token__
85+
password: ${{ secrets.PYPI_API_TOKEN }}
86+
packages-dir: python/dist

clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
allow-print-in-tests = true

src/add_functions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub mod tests {
5858
use super::*;
5959
use anyhow::Context;
6060
use chrono::TimeZone;
61-
pub use pretty_assertions::{assert_eq, assert_ne};
61+
pub use pretty_assertions::assert_eq;
6262

6363
use rusqlite::{params, Connection};
6464
use serde::{Deserialize, Serialize};
@@ -148,7 +148,7 @@ pub mod tests {
148148
];
149149

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

200200
fn test_strings() -> anyhow::Result<Vec<String>> {
201-
let data = vec![
201+
let data = [
202202
"hello this is a test",
203203
"foobar",
204204
"looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",

src/bin/benchmark.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ impl Bench for SelectBench {
7676
}
7777
fn execute(&self, conn: &Connection) -> Result<i64> {
7878
let mut stmt = conn.prepare("select data from title_basics where id = ?")?;
79-
let mut total_len = 0;
79+
let mut _total_len = 0;
8080
for id in &self.ids {
8181
let data: String = stmt.query_row(params![id], |r| r.get(0))?;
82-
total_len += data.len();
82+
_total_len += data.len();
8383
}
8484

85-
// eprintln!("total bytes got: {}", total_len);
85+
// eprintln!("total bytes got: {}", _total_len);
8686
Ok(self.ids.len() as i64)
8787
}
8888
}
@@ -213,7 +213,7 @@ fn main() -> Result<()> {
213213
.map(|preparer| {
214214
eprintln!("running preparer {its_per_bench} times");
215215
(0..its_per_bench)
216-
.map(|i| preparer(&db1))
216+
.map(|_i| preparer(&db1))
217217
.collect::<Result<_, _>>()
218218
.context("preparing benches")
219219
})
@@ -237,7 +237,7 @@ fn main() -> Result<()> {
237237
let db_path = Path::new(&location).join(file_name);
238238
if !db_path.exists() {
239239
eprintln!("copying {} -> {}", input_db, db_path.to_string_lossy());
240-
std::fs::copy(&input_db, &db_path)?;
240+
std::fs::copy(input_db, &db_path)?;
241241
} else {
242242
eprintln!(
243243
"{} already exists, assuming it's the same",

src/dict_management.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use zstd::dict::{DecoderDictionary, EncoderDictionary};
77

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

51-
pub fn decoder_dict_from_ctx<'a>(
52-
ctx: &'a Context,
51+
pub fn decoder_dict_from_ctx(
52+
ctx: &Context,
5353
arg_index: usize,
5454
) -> anyhow::Result<Arc<DecoderDictionary<'static>>> {
5555
use lru_time_cache::LruCache;

0 commit comments

Comments
 (0)