Skip to content

Commit

Permalink
CI: Make continuous integration more reasonable
Browse files Browse the repository at this point in the history
Co-authored-by: YanWQ-monad <YanWQmonad@gmail.com>
  • Loading branch information
GZTimeWalker and YanWQ-monad committed Dec 9, 2024
1 parent 1a5fb43 commit 6acf158
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 44 deletions.
144 changes: 102 additions & 42 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
name: Continuous integration

jobs:
ci:
build:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -21,72 +21,132 @@ jobs:
- 1.71.1
env:
RUSTFLAGS: "-C target-cpu=native -C opt-level=3"
ROARINGRS_BENCH_OFFLINE: "true"

steps:
- name: Checkout roaring-rs
uses: actions/checkout@v2

- name: Checkout benchmark datasets
uses: actions/checkout@v2
with:
repository: "RoaringBitmap/real-roaring-datasets"
path: "benchmarks/real-roaring-datasets"
uses: actions/checkout@v4

- name: Initialize rust toolchain
uses: dtolnay/rust-toolchain@master
if: matrix.rust != 'nightly'
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
if: matrix.rust == 'nightly'
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy, miri

- name: Setup miri
- name: Check
working-directory: roaring
# clippy will also do a build check
# so we don't need to run `cargo check` or `cargo build`
# use different features to check if everything is fine
# the incremental compilation will make this faster
run: |
cargo clippy --all-targets --no-default-features -- -D warnings
cargo clippy --all-targets --features serde -- -D warnings
- name: Check SIMD
if: matrix.rust == 'nightly'
run: cargo miri setup
working-directory: roaring
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Fetch
run: cargo fetch
- name: Check formatting
run: cargo fmt --all -- --check

- name: Build
run: cargo build --all-targets
test:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
rust:
- stable
- beta
- nightly
- 1.71.1
features:
- default
- no-std
include:
- rust: nightly
features: simd
env:
RUSTFLAGS: "-C target-cpu=native -C opt-level=3"

- name: Check
run: cargo clippy --all-targets -- -D warnings
steps:
- name: Checkout roaring-rs
uses: actions/checkout@v4

- name: Check formatting
run: cargo fmt --all -- --check
- name: Initialize rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

- name: Test
if: matrix.features == 'default'
working-directory: roaring
run: cargo test --features serde

- name: Test bit endian
if: matrix.rust == 'nightly'
run:
cargo miri test --target s390x-unknown-linux-gnu --package roaring \
--lib -- bitmap::serialization::test::test_from_lsb0_bytes

- name: Test no default features
if: matrix.features == 'no-std'
working-directory: roaring
run: cargo test --no-default-features

- name: Test benchmarks
working-directory: roaring
run: cargo bench

- name: SIMD test
if: matrix.rust == 'nightly'
if: matrix.rust == 'nightly' && matrix.features == 'simd'
working-directory: roaring
run: cargo +nightly test --features simd

- name: SIMD test benchmarks
if: matrix.rust == 'nightly'
working-directory: roaring
run: cargo +nightly bench --features simd
miri:
runs-on: ubuntu-latest
needs: build
env:
# warning: Miri does not support optimizations: the opt-level is ignored.
RUSTFLAGS: "-C target-cpu=native"

steps:
- name: Checkout roaring-rs
uses: actions/checkout@v4

- name: Initialize rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: miri

- name: Setup miri
run: cargo miri setup

- name: Test bit endian
run: cargo miri test --target s390x-unknown-linux-gnu --package roaring --lib -- bitmap::serialization::test::test_from_lsb0_bytes

bench:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
rust:
- stable
- nightly
features:
- default
include:
- rust: nightly
features: simd
env:
RUSTFLAGS: "-C target-cpu=native -C opt-level=3"
ROARINGRS_BENCH_OFFLINE: "true"

steps:
- name: Checkout roaring-rs
uses: actions/checkout@v4

- name: Checkout benchmark datasets
uses: actions/checkout@v4
with:
repository: "RoaringBitmap/real-roaring-datasets"
path: "benchmarks/real-roaring-datasets"

- name: Initialize rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

- name: Bench
run: cargo bench --features "${{ matrix.features }}"
4 changes: 2 additions & 2 deletions roaring/src/bitmap/store/array_store/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub fn or(lhs: &[u16], rhs: &[u16], visitor: &mut impl BinaryOperationVisitor) {
if rem == 0 {
visitor.visit_slice(tail_b)
} else {
buffer[..rem as usize].sort_unstable();
buffer[..rem].sort_unstable();
rem = dedup(&mut buffer[..rem]);
scalar::or(&buffer[..rem], tail_b, visitor);
}
Expand Down Expand Up @@ -267,7 +267,7 @@ pub fn xor(lhs: &[u16], rhs: &[u16], visitor: &mut impl BinaryOperationVisitor)
if rem == 0 {
visitor.visit_slice(tail_b)
} else {
buffer[..rem as usize].sort_unstable();
buffer[..rem].sort_unstable();
rem = xor_slice(&mut buffer[..rem]);
scalar::xor(&buffer[..rem], tail_b, visitor);
}
Expand Down

0 comments on commit 6acf158

Please sign in to comment.