mirror of
https://github.com/Noratrieb/stuff.git
synced 2026-01-14 16:35:08 +01:00
add CI
This commit is contained in:
parent
22ca118481
commit
583b3c3a86
3 changed files with 197 additions and 15 deletions
206
.github/workflows/rust.yml
vendored
206
.github/workflows/rust.yml
vendored
|
|
@ -1,22 +1,204 @@
|
||||||
name: Rust
|
# adapted from https://github.com/thomcc/arcstr/blob/main/.github/workflows/ci.yml
|
||||||
|
|
||||||
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches:
|
||||||
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
RUST_BACKTRACE: 1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
|
name: Test Rust - ${{ matrix.build }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
CARGO: cargo
|
||||||
|
TARGET: ""
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
build:
|
||||||
|
- macos
|
||||||
|
- linux
|
||||||
|
- linux32
|
||||||
|
- win64-msvc
|
||||||
|
- win64-gnu
|
||||||
|
- win32-msvc
|
||||||
|
- win32-gnu
|
||||||
|
- msrv
|
||||||
|
- beta
|
||||||
|
- nightly
|
||||||
|
- arm32
|
||||||
|
- arm64
|
||||||
|
- mips32
|
||||||
|
- mips64
|
||||||
|
include:
|
||||||
|
- build: linux
|
||||||
|
os: ubuntu-latest
|
||||||
|
rust: stable
|
||||||
|
- build: macos
|
||||||
|
os: macos-latest
|
||||||
|
rust: stable
|
||||||
|
- build: win64-msvc
|
||||||
|
os: windows-2019
|
||||||
|
rust: stable
|
||||||
|
- build: win64-gnu
|
||||||
|
os: windows-2019
|
||||||
|
rust: stable-x86_64-gnu
|
||||||
|
- build: win32-msvc
|
||||||
|
os: windows-2019
|
||||||
|
rust: stable-i686-msvc
|
||||||
|
- build: win32-gnu
|
||||||
|
os: windows-2019
|
||||||
|
rust: stable-i686-gnu
|
||||||
|
- build: beta
|
||||||
|
os: ubuntu-latest
|
||||||
|
rust: beta
|
||||||
|
- build: nightly
|
||||||
|
os: ubuntu-latest
|
||||||
|
rust: nightly
|
||||||
|
- build: linux32
|
||||||
|
os: ubuntu-latest
|
||||||
|
rust: stable
|
||||||
|
target: i686-unknown-linux-gnu
|
||||||
|
- build: arm32
|
||||||
|
os: ubuntu-latest
|
||||||
|
rust: stable
|
||||||
|
target: armv7-linux-androideabi
|
||||||
|
- build: arm64
|
||||||
|
os: ubuntu-latest
|
||||||
|
rust: stable
|
||||||
|
target: aarch64-linux-android
|
||||||
|
# Mips is big endian.
|
||||||
|
- build: mips32
|
||||||
|
os: ubuntu-latest
|
||||||
|
rust: stable
|
||||||
|
target: mips-unknown-linux-gnu
|
||||||
|
- build: mips64
|
||||||
|
os: ubuntu-latest
|
||||||
|
rust: stable
|
||||||
|
target: mips64-unknown-linux-gnuabi64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v2
|
||||||
- name: Build
|
- name: Install Rust
|
||||||
run: cargo check --verbose
|
uses: actions-rs/toolchain@v1
|
||||||
- name: Run tests
|
with:
|
||||||
run: cargo test --verbose
|
toolchain: ${{ matrix.rust }}
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Setup cross if needed
|
||||||
|
if: matrix.target != ''
|
||||||
|
run: |
|
||||||
|
cargo install cross
|
||||||
|
echo "CARGO=cross" >> $GITHUB_ENV
|
||||||
|
echo "TARGET=--target ${{ matrix.target }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Show command used for Cargo
|
||||||
|
run: |
|
||||||
|
echo "cargo command is: ${{ env.CARGO }}"
|
||||||
|
echo "target flag is: ${{ env.TARGET }}"
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: ${{ env.CARGO }} test --verbose ${{ env.TARGET }}
|
||||||
|
|
||||||
|
miri:
|
||||||
|
name: Miri
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
RUSTFLAGS: "-Zrandomize-layout"
|
||||||
|
MIRIFLAGS: "-Zmiri-symbolic-alignment-check -Zmiri-check-number-validity -Zmiri-tag-raw-pointers"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
- uses: hecrj/setup-rust-action@v1
|
||||||
|
with:
|
||||||
|
rust-version: nightly
|
||||||
|
components: miri
|
||||||
|
- name: Run tests
|
||||||
|
run: cargo miri test
|
||||||
|
|
||||||
|
cargo-clippy:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
RUSTFLAGS: -Dwarnings
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
- uses: hecrj/setup-rust-action@v1
|
||||||
|
with:
|
||||||
|
rust-version: stable
|
||||||
|
- name: Run cargo clippy (default features)
|
||||||
|
run: cargo clippy --all-targets --verbose -- -D clippy::all
|
||||||
|
|
||||||
|
# Ensure patch is formatted.
|
||||||
|
fmt:
|
||||||
|
name: Format
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
- uses: hecrj/setup-rust-action@v1
|
||||||
|
with:
|
||||||
|
rust-version: stable
|
||||||
|
components: rustfmt
|
||||||
|
- name: Check formatting
|
||||||
|
run: cargo fmt --all -- --check
|
||||||
|
|
||||||
|
# Check doc reference links are all valid.
|
||||||
|
doc:
|
||||||
|
name: Doc check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
- uses: hecrj/setup-rust-action@v1
|
||||||
|
with:
|
||||||
|
rust-version: nightly
|
||||||
|
- name: Check docs
|
||||||
|
# Note: needs cargo rustdoc, not cargo doc.
|
||||||
|
run: cargo rustdoc --all-features -- -D warnings
|
||||||
|
|
||||||
|
sanitizers:
|
||||||
|
name: Test sanitizer ${{ matrix.sanitizer }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
RUST_BACKTRACE: 0
|
||||||
|
# only used by asan, but we set it for all of them cuz its easy
|
||||||
|
ASAN_OPTIONS: detect_stack_use_after_return=1
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
sanitizer: [address, memory]
|
||||||
|
include:
|
||||||
|
- sanitizer: memory
|
||||||
|
extra_rustflags: "-Zsanitizer-memory-track-origins"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: nightly
|
||||||
|
override: true
|
||||||
|
components: rust-src
|
||||||
|
|
||||||
|
- name: Test with sanitizer
|
||||||
|
env:
|
||||||
|
RUSTFLAGS: -Zsanitizer=${{ matrix.sanitizer }} ${{ matrix.extra_rustflags }}
|
||||||
|
RUSTDOCFLAGS: -Zsanitizer=${{ matrix.sanitizer }} ${{ matrix.extra_rustflags }}
|
||||||
|
run: |
|
||||||
|
echo "note: RUSTFLAGS='$RUSTFLAGS'"
|
||||||
|
cargo -Zbuild-std test --target=x86_64-unknown-linux-gnu
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::redundant_clone)]
|
||||||
fn clone() {
|
fn clone() {
|
||||||
let mut unit = ();
|
let mut unit = ();
|
||||||
let stuffed_ptr1: StuffedPtr<(), PanicsInDrop> = StuffedPtr::new_ptr(&mut unit);
|
let stuffed_ptr1: StuffedPtr<(), PanicsInDrop> = StuffedPtr::new_ptr(&mut unit);
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,7 @@ unsafe impl StuffingStrategy for () {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn extract_extra(_data: usize) -> Self::Extra {
|
unsafe fn extract_extra(_data: usize) -> Self::Extra {}
|
||||||
()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
@ -35,6 +33,7 @@ pub(crate) mod test_strategies {
|
||||||
data == usize::MAX
|
data == usize::MAX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::forget_copy)]
|
||||||
fn stuff_extra(inner: Self::Extra) -> usize {
|
fn stuff_extra(inner: Self::Extra) -> usize {
|
||||||
std::mem::forget(inner);
|
std::mem::forget(inner);
|
||||||
usize::MAX
|
usize::MAX
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue