Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update tests to use cargo-nextest if present #1243

Merged
merged 5 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ jobs:
- name: Check targets are installed correctly
run: rustup target list --installed

- name: Install cargo-nextest
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin

- name: Check all features compilation
run: cargo check --verbose --features try-runtime,runtime-benchmarks --locked

- name: Run all tests
run: cargo test --features try-runtime,runtime-benchmarks --locked
run: make test-all

native-linux:
needs: checks-and-tests
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
test-runtimes:
tests:
runs-on: [self-hosted, Linux, X64]
steps:
- name: Checkout the source code
Expand All @@ -26,5 +26,8 @@ jobs:
- name: Check targets are installed correctly
run: rustup target list --installed

- name: Runtime integration tests
run: make test-runtimes
- name: Install cargo-nextest
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin

- name: Run all tests
run: make test-all
25 changes: 22 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,27 @@ runtime-upgrade-test:
cargo build -p $(runtime)-runtime --release --locked
cd tests/e2e && yarn --frozen-lockfile && yarn test:runtime-upgrade-$(runtime)

# use `cargo nextest run` if cargo-nextest is installed, fallback cargo test
cargo_test = $(shell which cargo-nextest >/dev/null && echo "cargo nextest run" || echo "cargo test")

.PHONY: test
test:
SKIP_WASM_BUILD= ${cargo_test} --all
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to skip --all since it disables some part of the code (even though I think they're not tested by UTs) that are run outside of evm-tracing context. This is why we specified try-runtime,runtime-benchmarks explicitly before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually --all is deprecated and needs to be replaced with --workspace. I don't understand it disables some part of the code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some parts of the client code are compiled only when evm-tracing is disabled, and vice-versa. That's what I meant by disabled - poor choice of words from my side.

Since non-evm-tracing client is more important, running tests with disabled evm-tracing makes more sense. But then again, I don't believe we have tests covering client so perhaps this worry is baseless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't run any test with feature evm-tracing. Will add one


.PHONY: try-runtime
try-runtime:
SKIP_WASM_BUILD= ${cargo_test} --all --features try-runtime

.PHONY: test-benchmarks
test-benchmarks:
SKIP_WASM_BUILD= ${cargo_test} --all --features runtime-benchmarks


.PHONY: test-runtimes
test-runtimes:
SKIP_WASM_BUILD= cargo test -p integration-tests --features=shibuya
SKIP_WASM_BUILD= cargo test -p integration-tests --features=shiden
SKIP_WASM_BUILD= cargo test -p integration-tests --features=astar
SKIP_WASM_BUILD= ${cargo_test} -p integration-tests --features=shibuya
SKIP_WASM_BUILD= ${cargo_test} -p integration-tests --features=shiden
SKIP_WASM_BUILD= ${cargo_test} -p integration-tests --features=astar

.PHONY: test-all
test-all: test test-runtimes try-runtime test-benchmarks
1 change: 1 addition & 0 deletions bin/collator/src/local/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ pub(crate) mod tests {
use sp_runtime::BuildStorage;

#[test]
#[ignore]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this btw? 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will require building wasm which means more time to compile and it's just for local so not that critical if this breaks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I will let it compile local runtime, will revert this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need btw, we can just remove that test. But your call.

fn test_create_development_chain_spec() {
development_config().build_storage().unwrap();
}
Expand Down
Loading