Skip to content

Commit

Permalink
Improve CI: Rm use of deprecated actions
Browse files Browse the repository at this point in the history
also:
 - 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`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Jul 22, 2023
1 parent 913ad3a commit e7ad4b6
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 547 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: bench

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

- name: Benchmark
run: cargo bench
251 changes: 51 additions & 200 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,78 +19,36 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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

- 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@v2
- 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

test-nightly:
name: cargo test nightly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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
Expand All @@ -100,24 +58,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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

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

- name: Run Miri
run: |
cargo miri test --all-features --manifest-path=compact_str/Cargo.toml
Expand All @@ -129,132 +76,36 @@ jobs:
RUSTFLAGS: -Zrandomize-layout
steps:
- uses: actions/checkout@v2
- 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

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

- name: Run Tests with Randomized Layout
run: |
cargo test --all-features --manifest-path=compact_str/Cargo.toml
example-bytes:
example:
strategy:
fail-fast: false
matrix:
include:
- path: bytes
- path: macros
- path: serde
- path: traits
name: example - bytes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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-bytes
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-example
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly
- uses: actions-rs/cargo@v1
with:
command: run
args: --manifest-path examples/bytes/Cargo.toml

example-macros:
name: example - macros
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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-macros
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-example
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly
- uses: actions-rs/cargo@v1
with:
command: run
args: --manifest-path examples/macros/Cargo.toml

example-serde:
name: example - serde
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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-serde
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-example
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly
- uses: actions-rs/cargo@v1
with:
command: run
args: --manifest-path examples/serde/Cargo.toml

example-traits:
name: example - traits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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-traits
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly-example
${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-nightly
- uses: actions-rs/cargo@v1
with:
command: run
args: --manifest-path examples/traits/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 example-bytes
run: cargo run --manifest-path examples/${{ matrix.path }}/Cargo.toml
64 changes: 26 additions & 38 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,30 @@ jobs:
steps:
- uses: actions/checkout@v2
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
with:
command: fmt
args: --all -- --check

- name: Install toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal --component rustfmt
rustup override set nightly
- name: Run rustfmt
run: cargo fmt --all -- --check

clippy:
name: cargo clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
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
with:
command: clippy

- 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
run: cargo clippy --no-deps

doc:
name: cargo doc
Expand All @@ -60,15 +51,12 @@ jobs:
steps:
- uses: actions/checkout@v2
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 e7ad4b6

Please sign in to comment.