Skip to content

Commit af6fef3

Browse files
ci fixes - formatting, pre-commit, license (#26)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent bfc3c8e commit af6fef3

File tree

9 files changed

+109
-26
lines changed

9 files changed

+109
-26
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
- package-ecosystem: cargo
9+
directory: "/"
10+
schedule:
11+
interval: daily
12+
time: "02:00"
13+
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ name: Build
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ main ]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: [ main ]
88
release:
99
types: [ published ]
1010
workflow_dispatch:
1111

12+
defaults:
13+
run:
14+
shell: bash
15+
1216
jobs:
1317
test:
1418
runs-on: ubuntu-latest
@@ -42,10 +46,10 @@ jobs:
4246
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
4347
- name: Read crate metadata
4448
id: metadata
45-
run: echo "rust-version=$(sed -ne 's/rust-version *= *\"\(.*\)\"/\1/p' Cargo.toml)" >> $GITHUB_OUTPUT
49+
run: echo "value=$(sed -ne 's/rust-version *= *\"\(.*\)\"/\1/p' Cargo.toml)" >> $GITHUB_OUTPUT
4650
- name: Install Rust
4751
uses: dtolnay/rust-toolchain@stable
4852
with:
49-
toolchain: ${{ steps.metadata.outputs.rust-version }}
53+
toolchain: ${{ steps.metadata.outputs.value }}
5054
components: rustfmt
5155
- run: just -v ci-test-msrv

.github/workflows/dependabot.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Dependabot auto-merge
2+
on: pull_request
3+
4+
permissions: write-all
5+
6+
jobs:
7+
dependabot:
8+
runs-on: ubuntu-latest
9+
if: github.actor == 'dependabot[bot]'
10+
steps:
11+
- name: Dependabot metadata
12+
id: metadata
13+
uses: dependabot/[email protected]
14+
with:
15+
github-token: "${{ secrets.GITHUB_TOKEN }}"
16+
- name: Approve Dependabot PRs
17+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
18+
run: gh pr review --approve "$PR_URL"
19+
env:
20+
PR_URL: ${{github.event.pull_request.html_url}}
21+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
22+
- name: Enable auto-merge for Dependabot PRs
23+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
24+
run: gh pr merge --auto --squash "$PR_URL"
25+
env:
26+
PR_URL: ${{github.event.pull_request.html_url}}
27+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
# will have compiled files and executables
2-
**/target/
3-
4-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
5-
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
1+
.ccache
62
Cargo.lock
7-
8-
# These are backup files generated by rustfmt
9-
**/*.rs.bk
10-
11-
# coverage reports
12-
**/*.profraw
3+
cache.sqlite
4+
out.png
5+
target/

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-executables-have-shebangs
9+
- id: check-json
10+
- id: check-shebang-scripts-are-executable
11+
exclude: '.+\.rs' # would be triggered by #![some_attribute]
12+
- id: check-symlinks
13+
- id: check-toml
14+
- id: check-yaml
15+
args: [ --allow-multiple-documents ]
16+
- id: destroyed-symlinks
17+
- id: end-of-file-fixer
18+
- id: mixed-line-ending
19+
args: [ --fix=lf ]
20+
- id: trailing-whitespace
21+
22+
- repo: local
23+
hooks:
24+
- id: cargo-fmt
25+
name: Rust Format
26+
description: "Automatically format Rust code with cargo fmt"
27+
entry: sh -c "cargo fmt --all"
28+
language: rust
29+
pass_filenames: false

LICENSE-APACHE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@ Unless required by applicable law or agreed to in writing, software
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

LICENSE-MIT

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

3-
Copyright (c) 2024 Francisco Jimenez <[email protected]>
3+
Copyright (c) 2024-2025 Francisco Jimenez <[email protected]>
4+
Copyright (c) 2025 Yuri Astrakhan
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
This is a Rust wrapper for the [C++ FastPFor library](https://github.com/fast-pack/FastPFor), as well as a pure Rust re-implementation (work in progress). Supports 32-bit and 64-bit integers, and SIMD-optimized codecs for 128-bit and 256-bit vectors. Based on the [Decoding billions of integers per second through vectorization, 2012](https://arxiv.org/abs/1209.2137) paper.
1010

1111
### Supported algorithms
12-
Unless otherwise specified, all codecs support `&[u32]` only.
12+
Unless otherwise specified, all codecs support `&[u32]` only.
1313
* BP32
1414
* Copy
1515
* FastBinaryPacking8

justfile

100644100755
Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,42 @@ clean:
88
cargo clean
99
rm -f Cargo.lock
1010

11-
# Update dependencies, including breaking changes
11+
# Update all dependencies, including the breaking changes. Requires nightly toolchain (install with `rustup install nightly`)
1212
update:
1313
cargo +nightly -Z unstable-options update --breaking
1414
cargo update
1515

16-
# Run cargo clippy
16+
# Run cargo clippy to lint the code
1717
clippy:
1818
cargo clippy --all-targets --workspace --all-features -- -D warnings
1919

2020
# Test code formatting
2121
test-fmt:
2222
cargo fmt --all -- --check
2323

24-
# Run cargo fmt
24+
# Reformat all code `cargo fmt`. If nightly is available, use it for better results
2525
fmt:
26-
cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate
26+
#!/usr/bin/env bash
27+
set -euo pipefail
28+
if command -v cargo +nightly &> /dev/null; then
29+
echo 'Reformatting Rust code using nightly Rust fmt to sort imports'
30+
cargo +nightly fmt --all -- --config imports_granularity=Module,group_imports=StdExternalCrate
31+
else
32+
echo 'Reformatting Rust with the stable cargo fmt. Install nightly with `rustup install nightly` for better results'
33+
cargo fmt --all
34+
fi
2735

2836
# Build and open code documentation
2937
docs:
3038
cargo doc --no-deps --all-features --open
3139

32-
# Quick compile
40+
# Quick compile without building a binary
3341
check:
34-
cargo check --all-targets --workspace --all-features
42+
RUSTFLAGS='-D warnings' cargo check cargo check --workspace --all-targets --all-features
3543

3644
# Default build
3745
build *ARGS:
38-
cargo build --all-targets --workspace --all-features {{ARGS}}
46+
RUSTFLAGS='-D warnings' cargo build --all-targets --workspace --all-features {{ARGS}}
3947

4048
# Run all tests
4149
test *ARGS: build
@@ -90,7 +98,7 @@ ci-test: rust-info test-fmt clippy test test-doc
9098
ci-test-msrv: rust-info test
9199

92100
# Verify that the current version of the crate is not the same as the one published on crates.io
93-
check-if-published:
101+
check-if-published: (assert "jq")
94102
#!/usr/bin/env bash
95103
set -euo pipefail
96104
LOCAL_VERSION="$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]*)".*/\1/')"
@@ -105,3 +113,11 @@ check-if-published:
105113
else
106114
echo "The current crate version has not yet been published."
107115
fi
116+
117+
# Ensure that a certain command is available
118+
[private]
119+
assert $COMMAND:
120+
@if ! type "{{COMMAND}}" > /dev/null; then \
121+
echo "Command '{{COMMAND}}' could not be found. Please make sure it has been installed on your computer." ;\
122+
exit 1 ;\
123+
fi

0 commit comments

Comments
 (0)