Skip to content

Commit

Permalink
Add nextest to CI (#1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
smiasojed authored Apr 10, 2024
1 parent 6545821 commit ad0ee62
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 27 deletions.
101 changes: 98 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
if: ${{ !steps.check_permissions.outputs.has-permission }}
run: cargo clippy --profile debug-ci --all-targets -- -D warnings

test:
build-tests:
strategy:
fail-fast: false
matrix:
Expand All @@ -144,6 +144,100 @@ jobs:
- name: Cache
uses: Swatinem/rust-cache@v2

- name: Install nextest
uses: taiki-e/[email protected]
with:
tool: nextest

- name: Build and archive tests
run: cargo nextest archive --cargo-profile debug-ci --workspace --all-features --archive-file nextest-archive-${{ matrix.os }}.tar.zst
- name: Upload archive to workflow
uses: actions/upload-artifact@v4
with:
name: nextest-archive-${{ matrix.os }}
path: nextest-archive-${{ matrix.os }}.tar.zst

run-tests:
needs: build-tests
strategy:
fail-fast: false
matrix:
# We want newer versions than 'latest' here to have current wasm-opt
os: ["ubuntu-22.04", "macos-12"]
partition: [1, 2]
runs-on: ${{ matrix.os }}
env:
RUST_BACKTRACE: full
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rust-src, clippy

- name: Cache
uses: Swatinem/rust-cache@v2

- name: Install nextest
uses: taiki-e/[email protected]
with:
tool: nextest

- name: Download archive
uses: actions/download-artifact@v4
with:
name: nextest-archive-${{ matrix.os }}

- name: Run tests
run: cargo nextest run --archive-file nextest-archive-${{ matrix.os }}.tar.zst --partition count:${{ matrix.partition }}/2 -E 'not (test(integration_tests) | package(contract-build))'

- name: Run contract build tests
# The contract build tests cannot be run in parallel
run: cargo nextest run --archive-file nextest-archive-${{ matrix.os }}.tar.zst --partition count:${{ matrix.partition }}/2 -j 1 -E 'package(contract-build)'

run-integration-test:
needs: build-tests
strategy:
fail-fast: false
matrix:
# We want newer versions than 'latest' here to have current wasm-opt
os: ["ubuntu-22.04", "macos-12"]
partition: [1, 2]
runs-on: ${{ matrix.os }}
env:
RUST_BACKTRACE: full
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rust-src, clippy

- name: Cache
uses: Swatinem/rust-cache@v2

- name: Install nextest
uses: taiki-e/[email protected]
with:
tool: nextest

- name: Download archive
uses: actions/download-artifact@v4
with:
name: nextest-archive-${{ matrix.os }}

- name: Install latest `substrate-contracts-node` binary
env:
CONTRACTS_NODE_URL: https://gitlab.parity.io/parity/mirrors/substrate-contracts-node/-/jobs/artifacts/main/download
Expand All @@ -162,8 +256,9 @@ jobs:
mv artifacts/substrate-contracts-node-$CONTRACTS_NODE_OS/substrate-contracts-node /usr/local/bin
shell: bash

- name: Run tests
run: cargo test --profile debug-ci --workspace --all-features -- --test-threads=1
- name: Run integration tests
# The integration tests cannot be run in parallel
run: cargo nextest run --archive-file nextest-archive-${{ matrix.os }}.tar.zst --partition count:${{ matrix.partition }}/2 -j 1 -E 'test(integration_tests)'

template:
strategy:
Expand Down
48 changes: 24 additions & 24 deletions crates/extrinsics/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ async fn build_upload_instantiate_call() {
.tempdir()
.expect("temporary directory creation failed");

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

cargo_contract(tmp_dir.path())
.arg("new")
.arg("flipper")
Expand All @@ -200,6 +196,10 @@ async fn build_upload_instantiate_call() {
.assert()
.success();

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

let output = cargo_contract(project_path.as_path())
.arg("upload")
.args(["--suri", "//Alice"])
Expand Down Expand Up @@ -262,10 +262,6 @@ async fn build_upload_remove() {
.tempdir()
.expect("temporary directory creation failed");

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

cargo_contract(tmp_dir.path())
.arg("new")
.arg("incrementer")
Expand All @@ -280,6 +276,10 @@ async fn build_upload_remove() {
.assert()
.success();

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

let output = cargo_contract(project_path.as_path())
.arg("upload")
.args(["--suri", "//Alice"])
Expand Down Expand Up @@ -327,10 +327,6 @@ async fn build_upload_instantiate_info() {
.tempdir()
.expect("temporary directory creation failed");

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

cargo_contract(tmp_dir.path())
.arg("new")
.arg("flipper")
Expand All @@ -345,6 +341,10 @@ async fn build_upload_instantiate_info() {
.assert()
.success();

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

let output = cargo_contract(project_path.as_path())
.arg("upload")
.args(["--suri", "//Alice"])
Expand Down Expand Up @@ -450,10 +450,6 @@ async fn api_build_upload_instantiate_call() {
.tempdir()
.expect("temporary directory creation failed");

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

cargo_contract(tmp_dir.path())
.arg("new")
.arg("flipper")
Expand All @@ -468,6 +464,10 @@ async fn api_build_upload_instantiate_call() {
.assert()
.success();

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

// construct the contract file path
let contract_file = project_path.join("target/ink/flipper.contract");

Expand Down Expand Up @@ -590,10 +590,6 @@ async fn api_build_upload_remove() {
.tempdir()
.expect("temporary directory creation failed");

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

cargo_contract(tmp_dir.path())
.arg("new")
.arg("incrementer")
Expand All @@ -608,6 +604,10 @@ async fn api_build_upload_remove() {
.assert()
.success();

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

// construct the contract file path
let contract_file = project_path.join("target/ink/incrementer.contract");

Expand Down Expand Up @@ -706,10 +706,6 @@ async fn build_upload_instantiate_storage() {
.tempdir()
.expect("temporary directory creation failed");

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

cargo_contract(tmp_dir.path())
.arg("new")
.arg("flipper")
Expand All @@ -724,6 +720,10 @@ async fn build_upload_instantiate_storage() {
.assert()
.success();

let node_process = ContractsNodeProcess::spawn(CONTRACTS_NODE)
.await
.expect("Error spawning contracts node");

let output = cargo_contract(project_path.as_path())
.arg("upload")
.args(["--suri", "//Alice"])
Expand Down

0 comments on commit ad0ee62

Please sign in to comment.