Skip to content

Commit

Permalink
ci: Pin Rust Version, don't use Nightly rustfmt features, fix Fuzz …
Browse files Browse the repository at this point in the history
…workflow (#414)

* start

* pin Rust version for clippy, doc, and fmt to 1.83.0
* change rustfmt settings to not use nightly

* cargo fmt --all

* clippy

* pin Rust version for ci.yml

* pin a Nightly version in CI, fix test, maybe fix fuzzing

* use Nightly for cargo doc, use pinned Nightly for fuzzing

* fix fuzzer to account for change in #379
  • Loading branch information
ParkMyCar authored Dec 29, 2024
1 parent 193d13e commit 6c40a03
Show file tree
Hide file tree
Showing 34 changed files with 144 additions and 379 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ env:
RUSTFLAGS: "-D warnings"
PROPTEST_CASES: 10000
MIRIFLAGS: "-Zmiri-strict-provenance"
RUST_VERSION: 1.83.0
RUST_NIGHTLY_VERSION: "nightly-2024-12-20"

jobs:
check:
Expand All @@ -21,7 +23,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install toolchain
run: rustup toolchain install stable --no-self-update --profile minimal
run: rustup toolchain install ${{ env.RUST_VERSION }} --no-self-update --profile minimal
- uses: Swatinem/rust-cache@v2

- name: Check
Expand All @@ -32,8 +34,8 @@ jobs:
fail-fast: false
matrix:
include:
- toolchain: stable
- toolchain: nightly
- toolchain: ${{ env.RUST_VERSION }}
- toolchain: ${{ env.RUST_NIGHTLY_VERSION }}

name: cargo test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -62,8 +64,8 @@ jobs:

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal --component miri
rustup override set nightly
rustup toolchain install ${{ env.RUST_NIGHTLYVERSION }} --no-self-update --profile minimal --component miri
rustup override set ${{ env.RUST_NIGHTLYVERSION }}
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
Expand All @@ -83,8 +85,8 @@ jobs:

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal
rustup override set nightly
rustup toolchain install ${{ env.RUST_NIGHTLYVERSION }} --no-self-update --profile minimal
rustup override set ${{ env.RUST_NIGHTLYVERSION }}
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
Expand All @@ -106,8 +108,8 @@ jobs:

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal
rustup override set nightly
rustup toolchain install ${{ env.RUST_VERSION }} --no-self-update --profile minimal
rustup override set ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.ex }}
Expand All @@ -127,8 +129,8 @@ jobs:

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal
rustup override set nightly
rustup toolchain install ${{ env.RUST_VERSION }} --no-self-update --profile minimal
rustup override set ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.ex }}-test
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ name: Clippy
env:
CARGO_TERM_COLOR: "always"
RUSTFLAGS: "-D warnings"
RUST_VERSION: 1.83.0
RUST_NIGHTLY_VERSION: "nightly-2024-12-20"

jobs:
fmt:
Expand All @@ -21,8 +23,8 @@ jobs:

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal --component rustfmt
rustup override set nightly
rustup toolchain install ${{ env.RUST_VERSION }} --no-self-update --profile minimal --component rustfmt
rustup override set ${{ env.RUST_VERSION }}
- name: Run rustfmt Workspace
run: cargo fmt --all -- --check
Expand All @@ -38,15 +40,14 @@ jobs:

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal --component clippy
rustup override set nightly
rustup toolchain install ${{ env.RUST_VERSION }} --no-self-update --profile minimal --component clippy
rustup override set ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2

- name: Run clippy Workspace
run: cargo clippy --no-deps --tests
run: cargo clippy --no-deps --tests --all-features

- name: Run clippy compact_str
run: cargo clippy --no-deps --tests --manifest-path compact_str/Cargo.toml
run: cargo clippy --no-deps --tests --all-features --manifest-path compact_str/Cargo.toml

doc:
name: cargo doc
Expand All @@ -59,9 +60,8 @@ jobs:

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal
rustup override set nightly
rustup toolchain install ${{ env.RUST_NIGHTLY_VERSION }} --no-self-update --profile minimal
rustup override set ${{ env.RUST_NIGHTLY_VERSION }}
- uses: Swatinem/rust-cache@v2

- name: Run rustdoc
run: cargo doc --all-features --no-deps --manifest-path compact_str/Cargo.toml
5 changes: 3 additions & 2 deletions .github/workflows/cross_platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
PROPTEST_CASES: 1000
RUSTFLAGS: "-D warnings"
MIRIFAGS: "-Zmiri-tag-raw-pointers -Zmiri-check-number-validity"
RUST_NIGHTLY_VERSION: "nightly-2024-12-20"

jobs:
cross-test:
Expand Down Expand Up @@ -67,8 +68,8 @@ jobs:

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal --component miri --target ${{ matrix.target }}
rustup override set nightly
rustup toolchain install ${{ env.RUST_NIGHTLY_VERSION }} --no-self-update --profile minimal --component miri --target ${{ matrix.target }}
rustup override set ${{ env.RUST_NIGHTLY_VERSION }}
- name: Install cross
if: "matrix.cross"
uses: taiki-e/install-action@cross
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
- main
pull_request:
paths:
- 'compact_str/**'
- 'fuzz/**'
- '.github/workflows/fuzz.yml'
- '!CHANGELOG.md'
- '!**/README.md'
- "compact_str/**"
- "fuzz/**"
- ".github/workflows/fuzz.yml"
- "!CHANGELOG.md"
- "!**/README.md"
workflow_dispatch:
# schedule:
# - cron: '0 01,13 * * *'
Expand All @@ -18,6 +18,7 @@ name: Fuzz
env:
CARGO_TERM_COLOR: "always"
RUSTFLAGS: "-D warnings -Zrandomize-layout"
RUST_NIGHTLY_VERSION: "nightly-2024-12-20"

jobs:
libFuzzer_x86_64:
Expand All @@ -26,17 +27,16 @@ jobs:
steps:
- uses: actions/checkout@v4
name: Checkout compact_str

- name: Install toolchain
run: |
rustup toolchain install nightly-2024-06-01 --no-self-update --profile minimal
rustup override set nightly-2024-06-01
rustup toolchain install ${{ env.RUST_NIGHTLY_VERSION }} --no-self-update
rustup override set ${{ env.RUST_NIGHTLY_VERSION }}
- name: Install cargo-fuzz
uses: taiki-e/install-action@v2
with:
tool: cargo-fuzz
- uses: Swatinem/rust-cache@v2
run: |
cargo install cargo-fuzz
- uses: Swatinem/rust-cache@v2

- name: Set Fuzz Time
run: |
Expand Down
8 changes: 0 additions & 8 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
group_imports = "StdExternalCrate"
imports_granularity = "Module"
imports_layout = "Vertical"
reorder_modules = true

max_width = 100

comment_width = 100
wrap_comments = true

7 changes: 1 addition & 6 deletions bench/benches/apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
use std::time::Instant;

use compact_str::CompactString;
use criterion::{
black_box,
criterion_group,
criterion_main,
Criterion,
};
use criterion::{black_box, criterion_group, criterion_main, Criterion};

static VERY_LONG_STR: &str = include_str!("../data/moby10b.txt");

Expand Down
12 changes: 2 additions & 10 deletions bench/benches/compact_str.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
use compact_str::{
CompactString,
ToCompactString,
};
use compact_str::{CompactString, ToCompactString};
use compact_str_6::CompactString as CompactString6;
use criterion::{
criterion_group,
criterion_main,
BenchmarkId,
Criterion,
};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};

fn bench_new(c: &mut Criterion) {
c.bench_with_input(
Expand Down
7 changes: 1 addition & 6 deletions bench/benches/comparison.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
use compact_str::CompactString;
use criterion::{
criterion_group,
criterion_main,
BenchmarkId,
Criterion,
};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use smartstring::alias::String as SmartString;
use smol_str::SmolStr;

Expand Down
8 changes: 1 addition & 7 deletions bench/benches/random.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
//! Random benchmarks to determine if one bit of code is faster than another
use criterion::{
black_box,
criterion_group,
criterion_main,
BenchmarkId,
Criterion,
};
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};

fn if_statement_min(c: &mut Criterion) {
let mask = 192;
Expand Down
11 changes: 2 additions & 9 deletions compact_str/src/features/arbitrary.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
//! Implements the [`arbitrary::Arbitrary`] trait for [`CompactString`]
use arbitrary::{
Arbitrary,
Result,
Unstructured,
};
use arbitrary::{Arbitrary, Result, Unstructured};

use crate::CompactString;

Expand All @@ -26,10 +22,7 @@ impl<'a> Arbitrary<'a> for CompactString {

#[cfg(test)]
mod test {
use arbitrary::{
Arbitrary,
Unstructured,
};
use arbitrary::{Arbitrary, Unstructured};

use crate::CompactString;

Expand Down
18 changes: 3 additions & 15 deletions compact_str/src/features/borsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@ use alloc::string::String;
use alloc::vec::Vec;
use core::str;

use borsh::io::{
Error,
ErrorKind,
Read,
Result,
Write,
};
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use borsh::io::{Error, ErrorKind, Read, Result, Write};
use borsh::{BorshDeserialize, BorshSerialize};

use crate::repr::MAX_SIZE;
use crate::CompactString;
Expand Down Expand Up @@ -80,10 +71,7 @@ mod tests {

use test_strategy::proptest;

use crate::repr::{
HEAP_MASK,
MAX_SIZE,
};
use crate::repr::{HEAP_MASK, MAX_SIZE};
use crate::CompactString;

fn assert_roundtrip(s: &str) {
Expand Down
10 changes: 2 additions & 8 deletions compact_str/src/features/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use core::str::Utf8Error;

use bytes::Buf;

use crate::{
CompactString,
Repr,
};
use crate::{CompactString, Repr};

impl CompactString {
/// Converts a buffer of bytes to a [`CompactString`]
Expand Down Expand Up @@ -77,10 +74,7 @@ mod test {
use proptest::prelude::*;
use test_strategy::proptest;

use crate::tests::{
rand_bytes,
rand_unicode,
};
use crate::tests::{rand_bytes, rand_unicode};
use crate::CompactString;

const MAX_SIZE: usize = core::mem::size_of::<String>();
Expand Down
8 changes: 1 addition & 7 deletions compact_str/src/features/diesel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
// Copied and adapted from
// <https://github.com/diesel-rs/diesel/blob/ab70dd5ed1f96926a3e8d98ab42636eaac1e1594/diesel/src/type_impls/primitives.rs>

use diesel::{
backend,
deserialize,
expression,
serialize,
sql_types,
};
use diesel::{backend, deserialize, expression, serialize, sql_types};

use crate::CompactString;

Expand Down
5 changes: 1 addition & 4 deletions compact_str/src/features/quickcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
use alloc::boxed::Box;
use alloc::vec::Vec;

use quickcheck::{
Arbitrary,
Gen,
};
use quickcheck::{Arbitrary, Gen};

use crate::CompactString;

Expand Down
14 changes: 2 additions & 12 deletions compact_str/src/features/rkyv.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#![cfg_attr(docsrs, doc(cfg(feature = "rkyv")))]

use rkyv::string::{
ArchivedString,
StringResolver,
};
use rkyv::{
Archive,
Deserialize,
DeserializeUnsized,
Fallible,
Serialize,
SerializeUnsized,
};
use rkyv::string::{ArchivedString, StringResolver};
use rkyv::{Archive, Deserialize, DeserializeUnsized, Fallible, Serialize, SerializeUnsized};

use crate::CompactString;

Expand Down
Loading

0 comments on commit 6c40a03

Please sign in to comment.