Skip to content

Commit

Permalink
Improve CI: Rm use of deprecated actions
Browse files Browse the repository at this point in the history
also:
 - Bump `actions/checkout` to v4
 - use `taiki-e/install-action` to install any binary crates
 - use `Swatinem/rust-cache@v2` for caching
 - use `strategy` to avoid similar/duplicate jobs
 - pass `--no-deps` to `cargo-clippy`
 - Use `cargo-nextest` for `randomize-layout`
 - Run doc test in job `test`
 - Run `cross-check` instead of `cross-build` in `nostd.yml`
 - Use `cargo-nextest` to speedup `miri`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Oct 15, 2023
1 parent 34afd59 commit 0a3b914
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 351 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ jobs:
name: cargo bench
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: bench
- uses: actions/checkout@v4

- name: Install toolchain
run: rustup toolchain install stable --no-self-update --profile minimal
- uses: Swatinem/rust-cache@v2

- name: Benchmark
run: cargo bench
187 changes: 61 additions & 126 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,164 +18,99 @@ jobs:
name: cargo check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-stable-check
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-stable
- uses: actions-rs/cargo@v1
with:
command: check
args: --tests --all-features
- uses: actions/checkout@v4

- name: Install toolchain
run: rustup toolchain install stable --no-self-update --profile minimal
- uses: Swatinem/rust-cache@v2

- name: Check
run: cargo check --tests --all-features

test:
strategy:
fail-fast: false
matrix:
include:
- toolchain: stable
- toolchain: nightly

name: cargo test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-stable-test
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-stable
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: cargo test
run: |
cargo nextest run --release --all-features --manifest-path=compact_str/Cargo.toml --run-ignored=all
- uses: actions/checkout@v4

test-nightly:
name: cargo test nightly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-test
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly
- name: Install toolchain
run: |
rustup toolchain install ${{ matrix.toolchain }} --no-self-update --profile minimal
rustup override set ${{ matrix.toolchain }}
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
# Install nightly after cargo-nextest is installed, as cargo-nextest failed to compile on nightly
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- uses: Swatinem/rust-cache@v2

- name: cargo test
run: |
cargo nextest run --release --all-features --manifest-path=compact_str/Cargo.toml --run-ignored=all
cargo test --doc --release --all-features --manifest-path=compact_str/Cargo.toml -- --run-ignored=all
miri:
name: cargo miri test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: miri
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-test-miri
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-test
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly
- uses: actions/checkout@v4

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal --component miri
rustup override set nightly
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2

- name: Run Miri
run: |
cargo miri test --all-features --manifest-path=compact_str/Cargo.toml
cargo miri nextest run --all-features --manifest-path=compact_str/Cargo.toml
cargo miri test --doc --all-features --manifest-path=compact_str/Cargo.toml
randomize-layout:
name: cargo test -Zrandomize-layout
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Zrandomize-layout
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-test-randomize-layout
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-test
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly
- uses: actions/checkout@v4

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal
rustup override set nightly
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2

- name: Run Tests with Randomized Layout
run: |
cargo test --all-features --manifest-path=compact_str/Cargo.toml
cargo nextest run --all-features --manifest-path=compact_str/Cargo.toml
cargo test --doc --all-features --manifest-path=compact_str/Cargo.toml
examples:
name: example
name: example - ${{ matrix.ex }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ex: ["bytes", "macros", "serde", "traits"]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-example-${{ matrix.ex }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-example
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal
rustup override set nightly
- uses: Swatinem/rust-cache@v2
with:
command: run
args: --manifest-path examples/${{ matrix.ex }}/Cargo.toml
key: ${{ matrix.ex }}

- name: Run example-bytes
run: cargo run --manifest-path examples/${{ matrix.ex }}/Cargo.toml
86 changes: 34 additions & 52 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,70 +16,52 @@ jobs:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: Checkout compact_str
- uses: actions-rs/toolchain@v1
name: Install Rust
with:
profile: minimal
# We currently use some unstable features in rustfmt, hence the nightly toolchain
toolchain: nightly
override: true
- run: rustup component add rustfmt
name: Add rustfmt
- uses: actions-rs/cargo@v1
name: Run rustfmt Workspace
with:
command: fmt
args: --all -- --check
- uses: actions-rs/cargo@v1
name: Run rustfmt compact_str
with:
command: fmt
args: --all --manifest-path compact_str/Cargo.toml -- --check

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal --component rustfmt
rustup override set nightly
- name: Run rustfmt Workspace
run: cargo fmt --all -- --check
- name: Run rustfmt compact_str
run: cargo fmt --all --manifest-path compact_str/Cargo.toml -- --check

clippy:
name: cargo clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: Checkout compact_str
- uses: actions-rs/toolchain@v1
name: Install Rust
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
name: Add clippy
- uses: actions-rs/cargo@v1
name: Run clippy Workspace
with:
command: clippy
args: --tests
- uses: actions-rs/cargo@v1
name: Run clippy compact_str
with:
command: clippy
args: --tests --manifest-path compact_str/Cargo.toml

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

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

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

doc:
name: cargo doc
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: "-D warnings --cfg docsrs"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: Checkout compact_str
- uses: actions-rs/toolchain@v1
name: Install Rust
with:
profile: minimal
# docs.rs uses a nightly toolchain
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
name: Run rustdoc
with:
command: doc
args: --all-features --no-deps --manifest-path compact_str/Cargo.toml

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

- name: Run rustdoc
run: cargo doc --all-features --no-deps --manifest-path compact_str/Cargo.toml
Loading

0 comments on commit 0a3b914

Please sign in to comment.