Skip to content

Commit f949619

Browse files
committed
More rework of CI and justfiles
1 parent 94847f4 commit f949619

File tree

3 files changed

+51
-45
lines changed

3 files changed

+51
-45
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ jobs:
196196
# This approach also allows some jobs to be skipped if they are not needed.
197197
ci-passed:
198198
if: always()
199-
needs: [ test, test-msrv, coverage, build, cross-build ]
199+
needs: [ test, test-msrv, build, cross-build ]
200200
runs-on: ubuntu-latest
201201
steps:
202202
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}

justfile

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
#!/usr/bin/env just --justfile
22

33
main_crate := 'sqlite-hashes'
4-
bin_name := 'sqlite_hashes'
4+
features_flag := '--all-features'
5+
bin_name := snakecase(main_crate)
56
sqlite3 := 'sqlite3'
67

78
# if running in CI, treat warnings as errors by setting RUSTFLAGS and RUSTDOCFLAGS to '-D warnings' unless they are already set
89
# Use `CI=true just ci-test` to run the same tests as in GitHub CI.
910
# Use `just env-info` to see the current values of RUSTFLAGS and RUSTDOCFLAGS
10-
ci_mode := if env('CI', '') != '' { '1' } else { '' }
11+
ci_mode := if env('CI', '') != '' {'1'} else {''}
1112
export RUSTFLAGS := env('RUSTFLAGS', if ci_mode == '1' {'-D warnings'} else {''})
1213
export RUSTDOCFLAGS := env('RUSTDOCFLAGS', if ci_mode == '1' {'-D warnings'} else {''})
1314
export RUST_BACKTRACE := env('RUST_BACKTRACE', if ci_mode == '1' {'1'} else {''})
1415

1516
@_default:
16-
just --list
17+
{{just_executable()}} --list
1718

1819
# Run benchmarks
1920
bench:
@@ -26,21 +27,22 @@ bless *args: (cargo-install 'cargo-insta')
2627

2728
# Build the project
2829
build: build-lib build-ext
30+
cargo check --workspace --all-targets {{features_flag}}
2931

3032
# Build extension binary
3133
build-ext *args:
3234
cargo build --example {{bin_name}} --no-default-features --features default_loadable_extension {{args}}
3335

3436
# Build the lib
3537
build-lib:
36-
cargo build --workspace --all-targets
38+
cargo build --workspace
3739

3840
# Quick compile without building a binary
3941
check:
40-
cargo check --workspace --all-targets
42+
cargo check --workspace --all-targets {{features_flag}}
4143

4244
# Verify that the current version of the crate is not the same as the one published on crates.io
43-
check-if-published: (assert 'jq')
45+
check-if-published: (assert-cmd 'jq')
4446
#!/usr/bin/env bash
4547
set -euo pipefail
4648
LOCAL_VERSION="$({{just_executable()}} get-crate-field version)"
@@ -61,21 +63,13 @@ check-lib:
6163
cargo check --workspace
6264

6365
# Generate code coverage report to upload to codecov.io
64-
ci-coverage: && \
66+
ci-coverage: env-info && \
6567
(coverage '--codecov --output-path target/llvm-cov/codecov.info')
6668
# ATTENTION: the full file path above is used in the CI workflow
6769
mkdir -p target/llvm-cov
6870

6971
# Run all tests as expected by CI
70-
ci-test: env-info test-fmt check clippy test test-ext test-doc
71-
#!/usr/bin/env bash
72-
set -euo pipefail
73-
if [ -n "$(git status --untracked-files --porcelain)" ]; then
74-
>&2 echo 'ERROR: git repo is no longer clean. Make sure compilation and tests artifacts are in the .gitignore, and no repo files are modified.'
75-
>&2 echo '######### git status ##########'
76-
git status
77-
exit 1
78-
fi
72+
ci-test: env-info test-fmt check clippy test test-ext test-doc && assert-git-is-clean
7973

8074
# Run minimal subset of tests to ensure compatibility with MSRV
8175
ci-test-msrv: env-info check-lib test
@@ -86,7 +80,7 @@ clean:
8680

8781
# Run cargo clippy to lint the code
8882
clippy *args:
89-
cargo clippy --workspace --all-targets {{args}}
83+
cargo clippy --workspace --all-targets {{features_flag}} {{args}}
9084
cargo clippy --no-default-features --features default_loadable_extension {{args}}
9185

9286
# Generate code coverage report. Will install `cargo llvm-cov` if missing.
@@ -150,10 +144,10 @@ msrv: (cargo-install 'cargo-msrv')
150144

151145
# Check semver compatibility with prior published version. Install it with `cargo install cargo-semver-checks`
152146
semver *args: (cargo-install 'cargo-semver-checks')
153-
cargo semver-checks {{args}}
147+
cargo semver-checks {{features_flag}} {{args}}
154148

155149
# Switch to the minimum rusqlite version
156-
set-min-rusqlite-version: (assert "jq")
150+
set-min-rusqlite-version: (assert-cmd 'jq')
157151
#!/usr/bin/env bash
158152
set -euo pipefail
159153
MIN_RUSQL_VER="$(grep '^rusqlite =.*version = ">=' Cargo.toml | sed -E 's/.*version = "[^"0-9]*([0-9.-]+).*/\1/')"
@@ -162,27 +156,27 @@ set-min-rusqlite-version: (assert "jq")
162156
163157
# Run all unit and integration tests
164158
test: \
165-
( test-one-lib "--no-default-features" "--features" "trace,hex,md5" ) \
166-
( test-one-lib "--no-default-features" "--features" "trace,hex,sha1" ) \
167-
( test-one-lib "--no-default-features" "--features" "trace,hex,sha224" ) \
168-
( test-one-lib "--no-default-features" "--features" "trace,hex,sha256" ) \
169-
( test-one-lib "--no-default-features" "--features" "trace,hex,sha384" ) \
170-
( test-one-lib "--no-default-features" "--features" "trace,hex,sha512" ) \
171-
( test-one-lib "--no-default-features" "--features" "trace,hex,blake3" ) \
172-
( test-one-lib "--no-default-features" "--features" "trace,hex,fnv" ) \
173-
( test-one-lib "--no-default-features" "--features" "trace,hex,xxhash" ) \
159+
( test-one-lib '--no-default-features' '--features' 'trace,hex,md5' ) \
160+
( test-one-lib '--no-default-features' '--features' 'trace,hex,sha1' ) \
161+
( test-one-lib '--no-default-features' '--features' 'trace,hex,sha224' ) \
162+
( test-one-lib '--no-default-features' '--features' 'trace,hex,sha256' ) \
163+
( test-one-lib '--no-default-features' '--features' 'trace,hex,sha384' ) \
164+
( test-one-lib '--no-default-features' '--features' 'trace,hex,sha512' ) \
165+
( test-one-lib '--no-default-features' '--features' 'trace,hex,blake3' ) \
166+
( test-one-lib '--no-default-features' '--features' 'trace,hex,fnv' ) \
167+
( test-one-lib '--no-default-features' '--features' 'trace,hex,xxhash' ) \
174168
\
175-
( test-one-lib "--no-default-features" "--features" "md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash" ) \
176-
( test-one-lib "--no-default-features" "--features" "md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,aggregate" ) \
169+
( test-one-lib '--no-default-features' '--features' 'md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash' ) \
170+
( test-one-lib '--no-default-features' '--features' 'md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,aggregate' ) \
177171
\
178-
( test-one-lib "--no-default-features" "--features" "md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,hex" ) \
179-
( test-one-lib "--no-default-features" "--features" "md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,hex,aggregate" ) \
172+
( test-one-lib '--no-default-features' '--features' 'md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,hex' ) \
173+
( test-one-lib '--no-default-features' '--features' 'md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,hex,aggregate' ) \
180174
\
181-
( test-one-lib "--no-default-features" "--features" "md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,trace" ) \
182-
( test-one-lib "--no-default-features" "--features" "md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,trace,aggregate" ) \
175+
( test-one-lib '--no-default-features' '--features' 'md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,trace' ) \
176+
( test-one-lib '--no-default-features' '--features' 'md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,trace,aggregate' ) \
183177
\
184-
( test-one-lib "--no-default-features" "--features" "md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,hex,trace" ) \
185-
( test-one-lib "--no-default-features" "--features" "md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,hex,trace,aggregate" )
178+
( test-one-lib '--no-default-features' '--features' 'md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,hex,trace' ) \
179+
( test-one-lib '--no-default-features' '--features' 'md5,sha1,sha224,sha256,sha384,sha512,blake3,fnv,xxhash,hex,trace,aggregate' )
186180
187181
# Test documentation
188182
test-doc:
@@ -199,7 +193,7 @@ test-fmt:
199193
200194
# Find unused dependencies. Install it with `cargo install cargo-udeps`
201195
udeps: (cargo-install 'cargo-udeps')
202-
cargo +nightly udeps --all-targets --workspace --all-features
196+
cargo +nightly udeps --workspace --all-targets {{features_flag}}
203197
204198
# Update all dependencies, including breaking changes. Requires nightly toolchain (install with `rustup install nightly`)
205199
update:
@@ -208,12 +202,22 @@ update:
208202
209203
# Ensure that a certain command is available
210204
[private]
211-
assert command:
205+
assert-cmd command:
212206
@if ! type {{command}} > /dev/null; then \
213207
echo "Command '{{command}}' could not be found. Please make sure it has been installed on your computer." ;\
214208
exit 1 ;\
215209
fi
216210
211+
# Make sure the git repo has no uncommitted changes
212+
[private]
213+
assert-git-is-clean:
214+
@if [ -n "$(git status --untracked-files --porcelain)" ]; then \
215+
>&2 echo "ERROR: git repo is no longer clean. Make sure compilation and tests artifacts are in the .gitignore, and no repo files are modified." ;\
216+
>&2 echo "######### git status ##########" ;\
217+
git status ;\
218+
exit 1 ;\
219+
fi
220+
217221
# Check if a certain Cargo command is installed, and install it if needed
218222
[private]
219223
cargo-install $COMMAND $INSTALL_CMD='' *args='':
@@ -231,11 +235,9 @@ cargo-install $COMMAND $INSTALL_CMD='' *args='':
231235
232236
[private]
233237
is-sqlite3-available:
234-
#!/usr/bin/env bash
235-
set -euo pipefail
236-
if ! command -v {{sqlite3}} > /dev/null; then
237-
echo "{{sqlite3}} executable could not be found"
238-
exit 1
238+
if ! command -v {{sqlite3}} > /dev/null; then \
239+
echo "{{sqlite3}} executable could not be found" ;\
240+
exit 1 ;\
239241
fi
240242
echo "Found {{sqlite3}} executable:"
241243
{{sqlite3}} --version

src/cdylib/cdylib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ use rusqlite::ffi::SQLITE_NOTICE;
44
use rusqlite::trace::log;
55
use rusqlite::{ffi, Connection, Result};
66

7-
#[allow(clippy::not_unsafe_ptr_arg_deref)]
7+
/// This is the entry point for the `SQLite` extension.
8+
///
9+
/// # Safety
10+
/// This function is unsafe because it interacts with raw pointers and the `SQLite` C API.
811
#[no_mangle]
912
pub unsafe extern "C" fn sqlite3_extension_init(
1013
db: *mut ffi::sqlite3,
@@ -14,6 +17,7 @@ pub unsafe extern "C" fn sqlite3_extension_init(
1417
Connection::extension_init2(db, pz_err_msg, p_api, extension_init)
1518
}
1619

20+
#[expect(clippy::needless_pass_by_value)]
1721
fn extension_init(db: Connection) -> Result<bool> {
1822
sqlite_hashes::register_hash_functions(&db)?;
1923
log(SQLITE_NOTICE, "Loaded sqlite_hashes extension");

0 commit comments

Comments
 (0)