Skip to content

Commit

Permalink
move style tests to justfile, add them as separate github checks (#10444
Browse files Browse the repository at this point in the history
)

cc @frol, with this change formatting errors should be reported
basically instantaneously, while still allowing people to reproduce
almost all of CI by simply running `just test-ci` locally :)
  • Loading branch information
Ekleog-NEAR authored Jan 16, 2024
1 parent 885392a commit db20a66
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 131 deletions.
12 changes: 0 additions & 12 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ slow-timeout = { period = "10m", terminate-after = 3 }
retries = 0
threads-required = 2

[[profile.default.overrides]]
filter = 'package(style-tests)'
slow-timeout = { period = "120s", terminate-after = 5 }
retries = 0
threads-required = 4

# Unfortunately no support for inheriting profiles yet:
# https://github.com/nextest-rs/nextest/issues/387
[profile.ci]
Expand All @@ -28,9 +22,3 @@ filter = 'test(test_full_estimator)'
slow-timeout = { period = "10m", terminate-after = 3 }
retries = 0
threads-required = 2

[[profile.ci.overrides]]
filter = 'package(style-tests)'
slow-timeout = { period = "120s", terminate-after = 5 }
retries = 0
threads-required = 4
73 changes: 54 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,9 @@ jobs:
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-nextest
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-deny
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-llvm-cov
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-udeps

# Setup the dependency rust cache and llvm-cov
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
Expand All @@ -86,7 +80,7 @@ jobs:
protobuf_backward_compat:
name: "Protobuf Backward Compatibility"
runs-on: ubuntu-22.04-8core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@1158f4fa81bc02e1ff62abcca6d516c9e24c77da
Expand All @@ -96,7 +90,7 @@ jobs:

py_backward_compat:
name: "Backward Compatibility"
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
Expand Down Expand Up @@ -125,7 +119,7 @@ jobs:

py_db_migration:
name: "Database Migration"
runs-on: ubuntu-22.04-8core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
Expand Down Expand Up @@ -222,7 +216,7 @@ jobs:

py_style_check:
name: "Style"
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
Expand Down Expand Up @@ -266,14 +260,10 @@ jobs:

rpc_error_schema:
name: "RPC Schema"
runs-on: ubuntu-22.04-8core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
prefix-key: "0" # change this to invalidate CI cache
shared-key: "cargo_nextest-linux"
save-if: "false" # use the cache from nextest, but don’t double-save
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: just
Expand All @@ -288,8 +278,52 @@ jobs:
with:
fail: true

check_fmt:
name: "Cargo Fmt"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: just
- run: just check-cargo-fmt

check_clippy:
name: "Cargo Clippy"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: just
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
- run: just check-cargo-clippy

check_cargo_deny:
name: "Cargo Deny"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: just
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-deny
- run: just check-cargo-deny

check_themis:
name: "Themis"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: just
- run: just check-themis

check_non_default:
name: "Non-default configuration builds"
name: "Non-default Configuration Builds"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -299,8 +333,8 @@ jobs:
- run: just check-non-default

check_udeps:
name: "Unused dependencies"
runs-on: ubuntu-latest
name: "Unused Dependencies"
runs-on: ubuntu-22.04-8core
steps:
- uses: actions/checkout@v4
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
Expand All @@ -309,7 +343,8 @@ jobs:
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-udeps
- run: just check-udeps
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
- run: just check-cargo-udeps

cargo_audit:
name: "Cargo Audit"
Expand Down
4 changes: 0 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ members = [
"test-utils/runtime-tester/fuzz",
"test-utils/store-validator",
"test-utils/testlib",
"test-utils/style",
"tools/database",
"tools/chainsync-loadtest",
"tools/fork-network",
Expand Down
34 changes: 30 additions & 4 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ ci_hack_nextest_profile := if env("CI_HACKS", "0") == "1" { "--profile ci" } els
test *FLAGS: (test-ci FLAGS) test-extra

# only the tests that are exactly the same as the ones in CI
test-ci *FLAGS: (nextest "stable" FLAGS) (nextest "nightly" FLAGS) check-non-default check-udeps python-style-checks
test-ci *FLAGS: check-cargo-fmt \
python-style-checks \
check-cargo-deny \
check-themis \
check-cargo-clippy \
check-non-default \
check-cargo-udeps \
(nextest "nightly" FLAGS) \
(nextest "stable" FLAGS)
# order them with the fastest / most likely to fail checks first
# when changing this, remember to adjust the CI workflow in parallel, as CI runs each of these in a separate job

# tests that are as close to CI as possible, but not exactly the same code
test-extra: check-lychee
Expand Down Expand Up @@ -54,12 +64,27 @@ nextest-integration TYPE *FLAGS:
nextest-integration TYPE *FLAGS:
@echo "Nextest integration tests are currently disabled on macos!"

# Check various build configurations that aren’t exercised by a plain `cargo nextest` work as
# anticipated.
# check various build configurations compile as anticipated
check-non-default:
# Ensure that near-vm-runner always builds without default features enabled
cargo check -p near-vm-runner --no-default-features

# check rust formatting
check-cargo-fmt:
cargo fmt -- --check

# check clippy lints
check-cargo-clippy:
env CARGO_TARGET_DIR="target/clippy" cargo clippy --all-features --all-targets --locked

# check cargo deny lints
check-cargo-deny:
cargo deny --all-features --locked check bans

# themis-based checks
check-themis:
env CARGO_TARGET_DIR="target/themis" cargo run --locked -p themis

# generate a codecov report for RULE
codecov RULE:
#!/usr/bin/env bash
Expand All @@ -82,7 +107,8 @@ python-style-checks:
python3 scripts/fix_nightly_feature_flags.py
./scripts/formatting --check

check-udeps:
# verify there is no unused dependency specified in a Cargo.toml
check-cargo-udeps:
rustup toolchain install nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
env CARGO_TARGET_DIR={{justfile_directory()}}/target/udeps RUSTFLAGS='--cfg=udeps --cap-lints=allow' cargo +nightly udeps
Expand Down
12 changes: 0 additions & 12 deletions test-utils/style/Cargo.toml

This file was deleted.

79 changes: 0 additions & 79 deletions test-utils/style/src/lib.rs

This file was deleted.

0 comments on commit db20a66

Please sign in to comment.