Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Sep 8, 2024
1 parent 857f64b commit f2a98ab
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 35 deletions.
66 changes: 52 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Apply clippy lints
run: cargo hack clippy --each-feature
run: cargo hack clippy --each-feature --exclude-no-default-features

# Run tests on some extra platforms
cross:
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
path: ~/.cargo
key: ${{ runner.os }}-coverage-dotcargo
- name: Run build
run: cargo hack build --feature-powerset
run: cargo hack build --feature-powerset --exclude-no-default-features

test:
name: test
Expand Down Expand Up @@ -183,16 +183,16 @@ jobs:
path: ~/.cargo
key: ${{ runner.os }}-coverage-dotcargo
- name: Run test
run: cargo hack test --feature-powerset
run: cargo hack test --feature-powerset --exclude-no-default-features --exclude-features loom

sanitizer:
name: sanitizer
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
# - macos-latest
# - windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -212,11 +212,45 @@ jobs:
run: rustup component add rust-src
- name: Install cargo-hack
run: cargo install cargo-hack
- name: ASAN / LSAN / TSAN
- name: ASAN / LSAN / TSAN (Linux)
run: ci/sanitizer.sh
if: matrix.os == 'ubuntu-latest'
- name: ASAN / LSAN / TSAN
run: ci/sanitizer_generic.sh
if: matrix.os != 'ubuntu-latest'

miri-tb:
name: miri-tb
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Cache cargo build and registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-miri-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-miri-
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Miri (Linux)
run: ci/miri_tb.sh
if: matrix.os == 'ubuntu-latest'
- name: Miri
run: ci/miri_tb_generic.sh
if: matrix.os != 'ubuntu-latest'

miri:
name: miri
miri-sb:
name: miri-sb
strategy:
matrix:
os:
Expand All @@ -238,8 +272,13 @@ jobs:
${{ runner.os }}-miri-
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Miri (Linux)
run: ci/miri_sb.sh
if: matrix.os == 'ubuntu-latest'
- name: Miri
run: ci/miri.sh
run: ci/miri_sb_generic.sh
if: matrix.os != 'ubuntu-latest'

loom:
name: loom
strategy:
Expand All @@ -263,11 +302,9 @@ jobs:
${{ runner.os }}-loom-
- name: Install Rust
run: rustup update $nightly && rustup default $nightly
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Loom tests
run: RUSTFLAGS="--cfg loom -Dwarnings" cargo hack test --test loom
run: cargo test --tests --features loom

# valgrind
valgrind:
name: valgrind
Expand Down Expand Up @@ -342,7 +379,8 @@ jobs:
command: tarpaulin
args: --all-features --run-types tests --run-types doctests --workspace --out xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v3.1.1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}
fail_ci_if_error: true
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "template-rs"
version = "0.1.6"
version = "0.0.0"
edition = "2021"
repository = "https://github.com/al8n/template-rs"
homepage = "https://github.com/al8n/template-rs"
documentation = "https://docs.rs/template-rs"
description = "A template for creating Rust open-source repo on GitHub"
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
rust-version = "1.73"

[[bench]]
Expand Down
13 changes: 0 additions & 13 deletions ci/miri.sh

This file was deleted.

13 changes: 13 additions & 0 deletions ci/miri_sb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup

export MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-symbolic-alignment-check"

cargo miri test --tests --target x86_64-unknown-linux-gnu --all-features
# cargo miri test --tests --target aarch64-unknown-linux-gnu #crossbeam_utils has problem on this platform
cargo miri test --tests --target i686-unknown-linux-gnu --all-features
cargo miri test --tests --target powerpc64-unknown-linux-gnu --all-features
10 changes: 10 additions & 0 deletions ci/miri_sb_generic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup

export MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-symbolic-alignment-check"

cargo miri test --tests --all-features
13 changes: 13 additions & 0 deletions ci/miri_tb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup

export MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-symbolic-alignment-check -Zmiri-tree-borrows"

cargo miri test --tests --target x86_64-unknown-linux-gnu --all-features
# cargo miri test --tests --target aarch64-unknown-linux-gnu #crossbeam_utils has problem on this platform
cargo miri test --tests --target i686-unknown-linux-gnu --all-features
cargo miri test --tests --target powerpc64-unknown-linux-gnu --all-features
10 changes: 10 additions & 0 deletions ci/miri_tb_generic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup

export MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-symbolic-alignment-check -Zmiri-tree-borrows"

cargo miri test --tests --all-features
6 changes: 3 additions & 3 deletions ci/sanitizer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0"

# Run address sanitizer
RUSTFLAGS="-Z sanitizer=address" \
cargo test --tests --target x86_64-unknown-linux-gnu
cargo test --tests --target x86_64-unknown-linux-gnu --all-features

# Run leak sanitizer
RUSTFLAGS="-Z sanitizer=leak" \
cargo test --tests --target x86_64-unknown-linux-gnu
cargo test --tests --target x86_64-unknown-linux-gnu --all-features

# Run thread sanitizer
RUSTFLAGS="-Z sanitizer=thread" \
cargo -Zbuild-std test --tests --target x86_64-unknown-linux-gnu
cargo -Zbuild-std test --tests --target x86_64-unknown-linux-gnu --all-features
14 changes: 14 additions & 0 deletions ci/sanitizer_generic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -ex

export ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0"

# Run address sanitizer
RUSTFLAGS="-Z sanitizer=address" \
cargo test --tests --all-features

# Run leak sanitizer
RUSTFLAGS="-Z sanitizer=leak" \
cargo test --tests --all-features

3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ extern crate alloc as std;
#[cfg(all(feature = "std", not(feature = "alloc")))]
extern crate std;

#[cfg(all(feature = "std", feature = "alloc"))]
extern crate std;

/// template
pub fn it_works() -> usize {
4
Expand Down

0 comments on commit f2a98ab

Please sign in to comment.