Skip to content

ci

ci #1454

Workflow file for this run

name: ci
on:
pull_request:
branches:
- master
push:
branches:
- master
schedule:
- cron: '00 01 * * *'
jobs:
test:
name: test
env:
# For some builds, we use cross to test on 32-bit and big-endian
# systems.
CARGO: cargo
# When CARGO is set to CROSS, TARGET is set to `--target matrix.target`.
TARGET:
# Make quickcheck run more tests for hopefully better coverage.
QUICKCHECK_TESTS: 100000
runs-on: ${{ matrix.os }}
strategy:
matrix:
build:
- pinned
- stable
- stable-32
- stable-mips
- wasm
- beta
- nightly
- macos
- win-msvc
- win-gnu
include:
- build: pinned
os: ubuntu-latest
rust: 1.41.1
- build: stable
os: ubuntu-latest
rust: stable
- build: stable-32
os: ubuntu-latest
rust: stable
target: i686-unknown-linux-gnu
- build: stable-mips
os: ubuntu-latest
rust: stable
target: mips64-unknown-linux-gnuabi64
- build: beta
os: ubuntu-latest
rust: beta
- build: nightly
os: ubuntu-latest
rust: nightly
- build: macos
os: macos-latest
rust: stable
- build: win-msvc
os: windows-latest
rust: stable
- build: win-gnu
os: windows-latest
rust: stable-x86_64-gnu
- build: wasm
os: ubuntu-latest
rust: stable-x86_64-gnu
wasm: true
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Use Cross
if: matrix.target != ''
run: |
# We used to install 'cross' from master, but it kept failing. So now
# we build from a known-good version until 'cross' becomes more stable
# or we find an alternative. Notably, between v0.2.1 and current
# master (2022-06-14), the number of Cross's dependencies has doubled.
cargo install --bins --git https://github.com/rust-embedded/cross --tag v0.2.1
echo "CARGO=cross" >> $GITHUB_ENV
echo "TARGET=--target ${{ matrix.target }}" >> $GITHUB_ENV
- name: Download Wasmtime
if: matrix.wasm
run: |
rustup target add wasm32-wasi
echo "CARGO_BUILD_TARGET=wasm32-wasi" >> $GITHUB_ENV
echo "RUSTFLAGS=-Ctarget-feature=+simd128" >> $GITHUB_ENV
curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/v0.32.0/wasmtime-v0.32.0-x86_64-linux.tar.xz
tar xvf wasmtime-v0.32.0-x86_64-linux.tar.xz
echo `pwd`/wasmtime-v0.32.0-x86_64-linux >> $GITHUB_PATH
echo "CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime run --wasm-features simd --" >> $GITHUB_ENV
- name: Show command used for Cargo
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "target flag is: ${{ env.TARGET }}"
- name: Show CPU info for debugging
if: matrix.os == 'ubuntu-latest'
run: lscpu
- run: ${{ env.CARGO }} build --verbose $TARGET
- run: ${{ env.CARGO }} build --verbose $TARGET --no-default-features
- run: ${{ env.CARGO }} doc --verbose $TARGET
# Our dev dependencies evolve more rapidly than we'd like, so only run
# tests when we aren't pinning the Rust version.
- if: matrix.build != 'pinned'
name: Show byte order for debugging
run: ${{ env.CARGO }} test --verbose $TARGET byte_order -- --nocapture
- if: matrix.build != 'pinned'
name: Run tests under default configuration
run: ${{ env.CARGO }} test --verbose $TARGET
- if: matrix.build != 'pinned'
name: Run tests with just alloc feature
run: ${{ env.CARGO }} test --verbose --no-default-features --features alloc $TARGET
- if: matrix.build == 'stable'
name: Run under different SIMD configurations
run: |
set -x
# Enable libc while using SIMD, libc won't be used.
# (This is to ensure valid logic in the picking process.)
cargo test --verbose --features libc
preamble="--cfg memchr_disable_auto_simd"
# Force use of fallback without libc.
RUSTFLAGS="$preamble" cargo test --verbose
# Force use of libc.
RUSTFLAGS="$preamble" cargo test --verbose --features libc
preamble="$preamble --cfg memchr_runtime_simd"
# Force use of fallback even when SIMD is enabled.
RUSTFLAGS="$preamble" cargo test --verbose
# For some reason, cargo seems to get confused which results in
# link errors. So wipe the slate clean.
cargo clean
# Force use of sse2 only
RUSTFLAGS="$preamble --cfg memchr_runtime_sse2" cargo test --verbose
# ... and wipe it again. So weird.
cargo clean
# Force use of avx only
RUSTFLAGS="$preamble --cfg memchr_runtime_avx" cargo test --verbose
- if: matrix.build == 'nightly'
name: Run benchmarks as tests
run: cargo bench --manifest-path bench/Cargo.toml --verbose -- --test
build-for-non_sse-target:
name: build for non-SSE target
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rust-src
- run: cargo build -Z build-std=core --target=src/tests/x86_64-soft_float.json --verbose --no-default-features
test-with-miri:
name: test with miri
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: miri
- name: Show CPU info for debugging
run: lscpu
- run: cargo miri test --verbose
- run: cargo miri test --verbose --no-default-features
- run: cargo miri test --verbose --features libc
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt
- name: Check formatting
run: |
cargo fmt -- --check
- name: Check formatting on benchmarks
run: |
cargo fmt --manifest-path bench/Cargo.toml -- --check