Skip to content

Commit

Permalink
ci: improve stability and caching
Browse files Browse the repository at this point in the history
Make a number of improvements to ci similar to what were done here:
MystenLabs/sui#1164
  • Loading branch information
bmwill committed Apr 4, 2022
1 parent 8d93f11 commit 6d5fd7a
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 51 deletions.
10 changes: 10 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[alias]
# Collection of project wide clippy lints. This is done via an alias because
# clippy doesn't currently allow for specifiying project-wide lints in a
# configuration file. This is a similar workaround to the ones presented here:
# <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
xclippy = [
"clippy", "--all-targets", "--",
"-Wclippy::all",
"-Wclippy::disallowed_methods",
]
24 changes: 15 additions & 9 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,27 @@ jobs:
strategy:
fail-fast: true
steps:
- name: install toolchain according to rust-toolchain
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: beta
profile: default
override: true
components: llvm-tools-preview
- name: Checkout sources
uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
# Enable caching of the 'librocksdb-sys' crate by additionally caching the
# 'librocksdb-sys' src directory which is managed by cargo
- uses: bmwill/rust-cache@v1 # Fork of 'Swatinem/rust-cache' which allows caching additional paths
with:
path: ~/.cargo/registry/src/**/librocksdb-sys-*
- name: Install grcov, and cache the binary
uses: baptiste0928/cargo-install@v1
with:
crate: grcov
locked: true
# Normally generating code coverage requires use of a nightly compiler
# In order to have a more stable and less noisy experience, lets instead
# opt to use the stable toolchain specified via the 'rust-toolchain' file
# and instead enable nightly features via 'RUSTC_BOOTSTRAP'
- name: Build
uses: actions-rs/cargo@v1
with:
Expand All @@ -41,9 +48,8 @@ jobs:
RUSTFLAGS: '-Cinstrument-coverage'
RUSTDOCFLAGS: '-Cinstrument-coverage'
LLVM_PROFILE_FILE: 'codecov-instrumentation-%p-%m.profraw'
run: |
cargo test
run: cargo test
- name: Run grcov
run: grcov . --binary-path target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov
- name: Upload to codecov.io
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v1
48 changes: 48 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: nightly

on:
schedule:
- cron: '0 0 * * *' # every day at midnight

env:
CARGO_TERM_COLOR: always
# Disable incremental compilation.
#
# Incremental compilation is useful as part of an edit-build-test-edit cycle,
# as it lets the compiler avoid recompiling code that hasn't changed. However,
# on CI, we're not making small edits; we're almost always building the entire
# project from scratch. Thus, incremental compilation on CI actually
# introduces *additional* overhead to support making future builds
# faster...but no future builds will ever occur in any given CI environment.
#
# See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
# for details.
CARGO_INCREMENTAL: 0
# Allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). This should help to reduce flaky CI failures
# from transient network timeouts or other issues.
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short

jobs:
beta:
name: Run test on the beta channel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install beta toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: beta
components: clippy
override: true
# See '.cargo/config' for list of enabled/disappled clippy lints
- name: cargo clippy
run: cargo xclippy -D warnings
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
78 changes: 36 additions & 42 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,68 +30,59 @@ env:
RUST_BACKTRACE: short

jobs:
license-check:
name: license-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: scripts/license_check.sh

test:
name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}}
runs-on: ${{matrix.os}}-latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable, nightly]
os: [ubuntu]
steps:
- uses: actions/checkout@v2
- name: Install rust
uses: actions-rs/toolchain@v1
- uses: actions-rs/toolchain@v1
# Enable caching of the 'librocksdb-sys' crate by additionally caching the
# 'librocksdb-sys' src directory which is managed by cargo
- uses: bmwill/rust-cache@v1 # Fork of 'Swatinem/rust-cache' which allows caching additional paths
with:
toolchain: ${{matrix.toolchain}}
profile: minimal
override: true
- uses: Swatinem/rust-cache@v1
- name: Test
path: ~/.cargo/registry/src/**/librocksdb-sys-*
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install minimal nightly with clippy
uses: actions-rs/toolchain@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: clippy
override: true
- uses: Swatinem/rust-cache@v1
- name: Clippy
uses: actions-rs/cargo@v1
# Enable caching of the 'librocksdb-sys' crate by additionally caching the
# 'librocksdb-sys' src directory which is managed by cargo
- uses: bmwill/rust-cache@v1 # Fork of 'Swatinem/rust-cache' which allows caching additional paths
with:
command: clippy
args: --all --tests -- -D clippy::all -D warnings -D clippy::disallowed_method
path: ~/.cargo/registry/src/**/librocksdb-sys-*
# See '.cargo/config' for list of enabled/disappled clippy lints
- name: cargo clippy
run: cargo xclippy -D warnings

rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install minimal nightly with rustfmt
uses: actions-rs/toolchain@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt
override: true
- uses: Swatinem/rust-cache@v1
- name: rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: check license headers
run: scripts/license_check.sh
args: --all --check

cargo-deny:
name: cargo-deny (advisories, licenses, bans, ...)
Expand All @@ -100,21 +91,24 @@ jobs:
- uses: actions/checkout@v2
- uses: EmbarkStudios/cargo-deny-action@v1

udeps:
name: cargo-udeps
cargo-udeps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install minimal nightly
uses: actions-rs/toolchain@v1
- uses: actions-rs/toolchain@v1
# Enable caching of the 'librocksdb-sys' crate by additionally caching the
# 'librocksdb-sys' src directory which is managed by cargo
- uses: bmwill/rust-cache@v1 # Fork of 'Swatinem/rust-cache' which allows caching additional paths
with:
profile: minimal
toolchain: nightly
override: true
- uses: Swatinem/rust-cache@v1
path: ~/.cargo/registry/src/**/librocksdb-sys-*
- name: Install cargo-udeps, and cache the binary
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-udeps
locked: true
# Normally running cargo-udeps requires use of a nightly compiler
# In order to have a more stable and less noisy experience, lets instead
# opt to use the stable toolchain specified via the 'rust-toolchain' file
# and instead enable nightly features via 'RUSTC_BOOTSTRAP'
- name: run cargo-udeps
run: cargo +nightly udeps
run: RUSTC_BOOTSTRAP=1 cargo udeps

0 comments on commit 6d5fd7a

Please sign in to comment.