Skip to content

Commit

Permalink
Merge pull request #110 from Alexhuszagh/ci
Browse files Browse the repository at this point in the history
Update CI and benchmark/test features.
  • Loading branch information
Alexhuszagh committed Sep 9, 2024
2 parents 27ab657 + 6c11441 commit 04c758d
Show file tree
Hide file tree
Showing 48 changed files with 205 additions and 168 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/Comprehensive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- run: ci/comprehensive.sh
- run: ALL_FEATURES=1 ci/comprehensive.sh
69 changes: 37 additions & 32 deletions .github/workflows/Cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Cross
on:
[pull_request, workflow_dispatch]

# NOTE: Use older toolchains since there's bugs cross-compiling
# for some more recent architectures.
jobs:
cross:
name: Rust ${{matrix.target}}
Expand All @@ -24,41 +26,35 @@ jobs:
- armv7-unknown-linux-gnueabihf
- i686-unknown-linux-gnu
- i686-unknown-linux-musl
- mips-unknown-linux-gnu
- mips64-unknown-linux-gnuabi64
- mips64el-unknown-linux-gnuabi64
- mipsel-unknown-linux-gnu
# NOTE: This fails on cross v0.2.1, which is unusual since
# manually invoking the failing tests with qemu-5.1.0 passes.
#- powerpc64le-unknown-linux-gnu
- x86_64-unknown-linux-gnu
# NOTE: This has glibc linker issues. Restore later.
#- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl

# Windows
- x86_64-pc-windows-gnu

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{matrix.target}}
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: check
args: --target ${{matrix.target}}
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: test
args: --target ${{matrix.target}}
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: test
args: --target ${{matrix.target}} --features=radix,format,compact
- name: Install Cross
run: |
cargo install cross@0.2.5
rustup toolchain add 1.65.0
- name: Run Check
run: |
cross +1.65.0 check --target ${{matrix.target}}
- name: Run Simple Test
run: |
cross +1.65.0 test --target ${{matrix.target}}
- name: Run Feature Test
run: |
cross +1.65.0 test --target ${{matrix.target}} --features=radix,format,compact
notest:
name: Rust ${{matrix.target}}
Expand All @@ -76,15 +72,24 @@ jobs:
- x86_64-unknown-freebsd
- x86_64-unknown-netbsd

# MIPS
# These targets have been removed from Tier 2
# support, so we're using an older compiler and
# just checking they can be checked.
- mips-unknown-linux-gnu
- mips64-unknown-linux-gnuabi64
- mips64el-unknown-linux-gnuabi64
- mipsel-unknown-linux-gnu
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{matrix.target}}
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: check
args: --target ${{matrix.target}}
- name: Install Cross
run: |
cargo install cross@0.2.5
rustup toolchain add 1.65.0
rustup toolchain install 1.65.0 --target ${{matrix.target}} --profile minimal --no-self-update
- name: Run check
run: |
cross +1.65.0 check --target ${{matrix.target}}
5 changes: 2 additions & 3 deletions .github/workflows/Features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- run: ci/test.sh
- run: NIGHTLY=1 NO_STD=1 ci/test.sh
33 changes: 6 additions & 27 deletions .github/workflows/OSX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,13 @@ on:

jobs:
cross:
name: Rust ${{matrix.target}}
name: Rust MacOS
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
target:
# iOS targets don't work, since rust-embedded doesn't provide images.
- x86_64-apple-darwin

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{matrix.target}}
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: check
args: --target ${{matrix.target}}
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: test
args: --target ${{matrix.target}}
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: test
args: --target ${{matrix.target}} --features=radix,format,compact
- run: cargo check
- run: cargo test
- run: cargo test --features=radix,format,compact
28 changes: 22 additions & 6 deletions .github/workflows/Simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,35 @@ on:
[push, pull_request, workflow_dispatch]

jobs:
build:
name: Rust ${{matrix.rust}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [1.63.0]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{matrix.rust}}
- run: cargo check
- run: cargo build

test:
name: Rust ${{matrix.rust}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [1.51.0, stable, beta, nightly]
rust: [1.65.0, stable, beta, nightly]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@master
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{matrix.rust}}
- run: cargo check
Expand All @@ -28,11 +45,10 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- run: ci/check.sh
5 changes: 2 additions & 3 deletions .github/workflows/Valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
- run: sudo apt-get update
- run: sudo apt-get install valgrind
- run: cargo +nightly install cargo-valgrind
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Updated the MSRV to 1.63.0 (1.65.0 for development).

### Removed
- Support for mips (MIPS), mipsel (MIPS LE), mips64 (MIPS64 BE), and mips64el (MIPS64 LE) on Linux.

## [0.8.5] 2022-06-06
### Changed
- Fixed the partial integer parser to correctly return negative values if parsing partial input.
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,6 @@ lexical-core is tested on a wide variety of platforms, including big and small-e
- aarch64 (ARM8v8-A) Linux, Android, and iOS.
- armv7 (ARMv7-A) Linux, Android, and iOS.
- arm (ARMv6) Linux, and Android.
- mips (MIPS) Linux.
- mipsel (MIPS LE) Linux.
- mips64 (MIPS64 BE) Linux.
- mips64el (MIPS64 LE) Linux.
- powerpc (PowerPC) Linux.
- powerpc64 (PPC64) Linux.
- powerpc64le (PPC64LE) Linux.
Expand Down
2 changes: 1 addition & 1 deletion ci/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -ex

# Change to our project home.
script_dir=`dirname "${BASH_SOURCE[0]}"`
script_dir=$(dirname "${BASH_SOURCE[0]}")
cd "$script_dir"/..

scripts/check.sh
Expand Down
5 changes: 3 additions & 2 deletions ci/comprehensive.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# shellcheck disable=SC2086,SC2236
# Run a small subset of our comprehensive test suite.

set -ex
Expand All @@ -7,8 +8,8 @@ set -ex
cargo --version

# Change to our project home.
script_dir=`dirname "${BASH_SOURCE[0]}"`
script_home=`realpath "$script_dir"`
script_dir=$(dirname "${BASH_SOURCE[0]}")
script_home=$(realpath "$script_dir")
cd "$script_home"/..

FEATURES=
Expand Down
3 changes: 2 additions & 1 deletion ci/test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
# shellcheck disable=SC2086,SC2236
# Run main test suite.

set -ex

# Change to our project home.
script_dir=`dirname "${BASH_SOURCE[0]}"`
script_dir=$(dirname "${BASH_SOURCE[0]}")
cd "$script_dir"/..

# Print our cargo version, for debugging.
Expand Down
4 changes: 2 additions & 2 deletions docs/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ In addition, the following non-Rust dependencies must be installed:

# Development Process

The [scripts](https://github.com/Alexhuszagh/rust-lexical/tree/main/scripts) directory contains numerous scripts for testing, fuzzing, analyzing, and formatting code. Since many development features are nightly-only, this ensures the proper compiler features are used. This requires a recent version of a nightly compiler (1.51.0+) installed via Rustup, which can be invoked as `cargo +nightly`.
The [scripts](https://github.com/Alexhuszagh/rust-lexical/tree/main/scripts) directory contains numerous scripts for testing, fuzzing, analyzing, and formatting code. Since many development features are nightly-only, this ensures the proper compiler features are used. This requires a recent version of a nightly compiler (1.65.0+) installed via Rustup, which can be invoked as `cargo +nightly`.

- [asm.sh](https://github.com/Alexhuszagh/rust-lexical/blob/main/scripts/asm.sh): Emit assembly for numeric conversion routines, to identify performance regression.
- [bench.sh](https://github.com/Alexhuszagh/rust-lexical/blob/main/scripts/bench.sh): Check the benchmarks compile and run.
Expand All @@ -82,7 +82,7 @@ All PRs must pass the following checks:
RUSTFLAGS="--deny warnings" cargo +nightly build --features=lint
# Ensure all rustfmt and clippy checks pass.
scripts/check.sh
# Ensure all tests pass with common feature combinations.
# Ensure all tests pass with common feature combinations.
# Miri is too slow, so skip those tests for most commits.
SKIP_MIRI=1 scripts/test.sh
```
Expand Down
1 change: 1 addition & 0 deletions lexical-asm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub struct ParseIntError {
pub kind: IntErrorKind,
}

#[allow(dead_code)]
trait FromStrRadixHelper: PartialOrd + Copy {
fn min_value() -> Self;
fn max_value() -> Self;
Expand Down
12 changes: 8 additions & 4 deletions lexical-benchmark/algorithm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ default-features = false
features = []

[dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"] }
fastrand = "1.4"
criterion = { version = "0.5.0", features = ["html_reports"] }
fastrand = "2.1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[features]
default = ["std", "integers"]
default = ["std", "integers", "floats", "json"]
std = ["lexical-util/std", "lexical-parse-float/std"]
integers = []
integers = ["lexical-util/integers"]
floats = ["lexical-util/floats"]
json = []

[[bench]]
name = "bigint"
Expand Down
12 changes: 6 additions & 6 deletions lexical-benchmark/algorithm/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ fn karatsuba_mul_algo(big: &mut bigint::Bigint, y: &[bigint::Limb]) {
// GENERATOR

#[inline(always)]
fn new_limb(rng: &Rng) -> bigint::Limb {
fn new_limb(rng: &mut Rng) -> bigint::Limb {
if bigint::LIMB_BITS == 32 {
rng.u32(..) as bigint::Limb
} else {
Expand All @@ -200,10 +200,10 @@ macro_rules! generator {
$group.bench_function($name, |bench| {
let mut big = bigint::Bigint::new();
let seed = fastrand::u64(..);
let rng = Rng::with_seed(seed);
let mut rng = Rng::with_seed(seed);
bench.iter(|| {
unsafe { big.data.set_len(0) };
big.data.try_push(new_limb(&rng)).unwrap();
big.data.try_push(new_limb(&mut rng)).unwrap();
// Don't go any higher than 300.
$cb(&mut big, rng.u32(1..300));
black_box(&big);
Expand All @@ -220,18 +220,18 @@ macro_rules! generator {
$group.bench_function($name, |bench| {
let mut big = bigint::Bigint::new();
let seed = fastrand::u64(..);
let rng = Rng::with_seed(seed);
let mut rng = Rng::with_seed(seed);
bench.iter(|| {
unsafe { big.data.set_len(0) };
// Don't go higher than 20, since we a minimum of 60 limbs.
let count = rng.usize(1..20);
for _ in 0..count {
big.data.try_push(new_limb(&rng)).unwrap();
big.data.try_push(new_limb(&mut rng)).unwrap();
}
let count = rng.usize(1..20);
let mut vec: Vec<bigint::Limb> = Vec::new();
for _ in 0..count {
vec.push(new_limb(&rng));
vec.push(new_limb(&mut rng));
}

// Don't go any higher than 300.
Expand Down
Loading

0 comments on commit 04c758d

Please sign in to comment.