From 4ab3473db46b80179b383077a81fef446e330845 Mon Sep 17 00:00:00 2001 From: Santiago Baldassin <140439001+balda-rdx@users.noreply.github.com> Date: Tue, 29 Aug 2023 12:06:17 -0300 Subject: [PATCH] Adding code coverage for unit tests (#1399) * adding code coverage * running in k8 linux runners * fixing the version of the toolchain to be used * adding coverage for the sbor directory * uploading the coverage files * removing the coverage step * debugging * fixing the path to the artifacts * pointing to the reusable workflow * Trigger Build * pointing to the public version of the reusable workflows * pointing to the right branch * pointing to the reusable action * fixing syntax * last syntax fix * running more than one dir * pointing to the setup action * running integration tests * running more tests * running all tests * restoring removed step * fixing syntax * reverting xtasks changes * restoring the ci triggers * pointing to the main branch in the reusable workflows repo --- .github/workflows/ci.yml | 123 ++++++++++++++++++++------------------- .gitignore | 3 + Cargo.toml | 2 +- 3 files changed, 68 insertions(+), 60 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a14e5353218..d2fa55d9f9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,6 @@ on: - betanet - release\/* pull_request: - # Run on PR against any branch env: CARGO_TERM_COLOR: always @@ -33,6 +32,7 @@ jobs: toolchain: 1.70.0 - name: Check format run: bash ./check.sh + sbor-unit-tests: name: Run SBOR unit tests runs-on: ${{ matrix.os }} @@ -40,19 +40,19 @@ jobs: matrix: os: [k8s-linux-runner] steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.70.0 - - name: Run tests - run: cargo test - working-directory: sbor - - name: Run tests (no_std) - run: cargo test --no-default-features --features alloc - working-directory: sbor - - name: Run derive tests - run: cargo test - working-directory: sbor-derive-common + - uses: actions/checkout@v3 + - uses: radixdlt/public-iac-resuable-artifacts/rust-setup@main + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main + with: + tests-dir: sbor + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main + with: + tests-dir: sbor + flags: --no-default-features --features alloc + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main + with: + tests-dir: sbor-derive-common + sbor-integration-tests: name: Run SBOR integration tests runs-on: ${{ matrix.os }} @@ -60,19 +60,19 @@ jobs: matrix: os: [k8s-linux-runner] steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.70.0 - - name: Run tests - run: cargo test - working-directory: sbor-tests - - name: Run tests (no_std) - run: cargo test --no-default-features --features alloc - working-directory: sbor-tests - - name: Run bench - run: cargo bench - working-directory: sbor-tests + - uses: actions/checkout@v3 + - uses: radixdlt/public-iac-resuable-artifacts/rust-setup@main + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main + with: + tests-dir: sbor-tests + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main + with: + tests-dir: sbor-tests + flags: --no-default-features --features alloc + - name: Run bench + run: cargo bench + working-directory: sbor-tests + scrypto-unit-tests: name: Run Scrypto unit tests runs-on: ${{ matrix.os }} @@ -81,21 +81,21 @@ jobs: os: [k8s-linux-runner] steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - uses: radixdlt/public-iac-resuable-artifacts/rust-setup@main + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main with: - toolchain: 1.70.0 - - name: Run tests - run: cargo test - working-directory: scrypto - - name: Run tests (no_std) - run: cargo test --no-default-features --features alloc - working-directory: scrypto - - name: Run abi tests - run: cargo test - working-directory: scrypto-schema - - name: Run derive tests - run: cargo test - working-directory: scrypto-derive + tests-dir: scrypto + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main + with: + tests-dir: scrypto + flags: --no-default-features --features alloc + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main + with: + tests-dir: scrypto-schema + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main + with: + tests-dir: scrypto-derive + scrypto-integration-tests: name: Run Scrypto integration tests runs-on: ${{ matrix.os }} @@ -104,15 +104,15 @@ jobs: os: [k8s-linux-runner] steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - uses: radixdlt/public-iac-resuable-artifacts/rust-setup@main + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main with: - toolchain: 1.70.0 - - name: Run tests - run: cargo test - working-directory: scrypto-tests - - name: Run tests with no_std - run: cargo test --no-default-features --features alloc - working-directory: scrypto-tests + tests-dir: scrypto-tests + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main + with: + tests-dir: scrypto-tests + flags: --no-default-features --features alloc + scrypto-examples: name: Run Scrypto examples runs-on: ${{ matrix.os }} @@ -143,6 +143,7 @@ jobs: - name: Build and test everything run: cargo build --target wasm32-unknown-unknown --release && cargo test --release working-directory: examples/everything + radix-engine: name: Run Radix Engine tests runs-on: ${{ matrix.os }} @@ -196,6 +197,7 @@ jobs: --no-default-features --features alloc \ -p radix-engine \ -p radix-engine-tests + radix-engine-wasmer: name: Run Radix Engine tests (wasmer) runs-on: ${{ matrix.os }} @@ -217,6 +219,7 @@ jobs: --features wasmer \ -p radix-engine \ -p radix-engine-tests + radix-engine-bench: name: Run Radix Engine benchmarks runs-on: ${{ matrix.os }} @@ -233,6 +236,7 @@ jobs: - name: Run bench run: cargo bench working-directory: radix-engine-tests + radix-engine-common-bench: name: Run Radix Engine common benchmarks runs-on: ${{ matrix.os }} @@ -249,6 +253,7 @@ jobs: - name: Run bench run: cargo bench working-directory: radix-engine-common + transaction: name: Run transaction tests runs-on: ${{ matrix.os }} @@ -257,12 +262,11 @@ jobs: os: [k8s-linux-runner] steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - uses: radixdlt/public-iac-resuable-artifacts/rust-setup@main + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main with: - toolchain: 1.70.0 - - name: Run tests - run: cargo test - working-directory: transaction + tests-dir: transaction + transaction-scenarios: name: Run transaction scenarios runs-on: ${{ matrix.os }} @@ -271,12 +275,11 @@ jobs: os: [k8s-linux-runner] steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - uses: radixdlt/public-iac-resuable-artifacts/rust-setup@main + - uses: radixdlt/public-iac-resuable-artifacts/rust-coverage@main with: - toolchain: 1.69.0 - - name: Run tests - run: cargo test - working-directory: transaction-scenarios + tests-dir: transaction-scenarios + cli-resim-rtmc-rtmd: name: Run CLI tests (resim & rtmc & rtmd) runs-on: ${{ matrix.os }} @@ -311,6 +314,7 @@ jobs: - name: Run tests run: bash ./tests/manifest.sh working-directory: simulator + cli-scrypto: name: Run CLI tests (scrypto) runs-on: ${{ matrix.os }} @@ -339,6 +343,7 @@ jobs: - name: Run tests run: bash ./tests/scrypto.sh working-directory: simulator + fuzzer-check: name: Build fuzzer runs-on: ${{ matrix.os }} diff --git a/.gitignore b/.gitignore index c37bcd52e72..6a6c69dd9a2 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,6 @@ perf.data #Rusty-tags *.vi + +# Coverage +*.profraw diff --git a/Cargo.toml b/Cargo.toml index 9103cf4324c..42661e9b8ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,4 +37,4 @@ members = [ "utils", "radix-engine-profiling", "radix-engine-profiling/resources-tracker-macro", -] \ No newline at end of file +]