diff --git a/.config/nextest.toml b/.config/nextest.toml index 9e9c5b857..0529a1244 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,3 +1,6 @@ [profile.default] slow-timeout = { period = "120s", terminate-after = 1 } -retries = 3 # for flaky tests +retries = 3 # for flaky tests + +[profile.integration] +slow-timeout = { period = "3600s", terminate-after = 1 } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcbc7e686..1a0f13471 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,36 +81,31 @@ jobs: integration-test: name: Integration Test Suite runs-on: [self-hosted, linux] - needs: test + needs: rustfmt steps: - uses: actions/checkout@v3 - name: Install Clang run: sudo apt-get update && sudo apt-get install -y clang - uses: dtolnay/rust-toolchain@stable + with: + components: llvm-tools-preview + - uses: taiki-e/install-action@cargo-llvm-cov + - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - uses: extractions/setup-just@v2 - - name: Run integration tests + - name: Run integration tests with coverage env: RUST_LOG: warn - run: just run_integration_tests - - cli-builds: - name: tycho-cli check - runs-on: [self-hosted, linux] - needs: rustfmt - steps: - - uses: actions/checkout@v3 - - name: Install Clang - run: sudo apt-get update && sudo apt-get install -y clang - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 + run: just run_integration_tests_cov + - name: Upload integration test coverage to Codecov + uses: codecov/codecov-action@v3 + if: github.repository == 'broxus/tycho' with: - cache-on-failure: true - - uses: extractions/setup-just@v2 - - name: Build CLI - run: just build + token: ${{ secrets.CODECOV_TOKEN }} + files: integration_codecov.json + fail_ci_if_error: true metrics: name: Metrics diff --git a/justfile b/justfile index 188271e75..96b8afa70 100644 --- a/justfile +++ b/justfile @@ -79,7 +79,31 @@ update_rpc_proto: cargo run -p tycho-gen-protos # === Integration tests stuff === +run_integration_tests_cov: prepare_integration_tests + #!/usr/bin/env bash + set -euo pipefail + export INTEGRATION_TEST=1 + if [ -n "${CI:-}" ]; then + # Running in CI + RUST_BACKTRACE=1 cargo llvm-cov nextest \ + --package tycho-core \ + --profile integration \ + --cargo-profile release_check \ + --test archives heavy_archives \ + --run-ignored all \ + --output-path integration_codecov.json \ + --codecov + else + # Running locally - show coverage report in browser + RUST_BACKTRACE=1 cargo llvm-cov nextest \ + --package tycho-core \ + --profile integration \ + --cargo-profile release_check \ + --test archives heavy_archives \ + --run-ignored all \ + --open + fi # Runs all tests including ignored. Will take a lot of time to run. run_integration_tests: prepare_integration_tests ./scripts/run-integration-tests.sh diff --git a/scripts/common.sh b/scripts/common.sh old mode 100644 new mode 100755 diff --git a/scripts/coverage.py b/scripts/coverage.py index 7fdc5abe4..f84bd7194 100755 --- a/scripts/coverage.py +++ b/scripts/coverage.py @@ -2,18 +2,42 @@ import os import sys +def should_collect_coverage(crate_name: str) -> bool: + """ + Determines if coverage should be collected for a crate. -blacklist = ["25519", "tokio"] + Logic: + - In integration tests: only collect for tycho-* crates + - Otherwise: collect for everything except blacklisted crates + """ + # Default blacklist + ALWAYS_BLACKLISTED = {"25519", "tokio"} + # Integration test mode + if os.environ.get("INTEGRATION_TEST"): + return "tycho" in crate_name + + # Normal mode + return crate_name not in ALWAYS_BLACKLISTED + +def get_crate_name(args): + """Extract crate name from rustc arguments""" + for i, arg in enumerate(args): + if arg == "--crate-name": + return args[i + 1] + return "" def main(): # The first argument is the path to rustc, followed by its arguments args = sys.argv[1:] - # coverage is necessary only for our project + # Get crate name crate_name = get_crate_name(args) - if any(crate in crate_name for crate in blacklist): + + # Check if we should collect coverage + if not should_collect_coverage(crate_name): try: + # Remove coverage instrumentation flags instrument_coverage_index = args.index("instrument-coverage") del args[instrument_coverage_index] del args[instrument_coverage_index - 1] @@ -23,17 +47,5 @@ def main(): # Execute rustc with the potentially modified arguments os.execvp(args[0], args) - -def get_crate_name(args): - for i, arg in enumerate(args): - if arg == "--crate-name": - return args[i + 1] - return "" - - -def eprint(*args, **kwargs): - print(*args, file=sys.stderr, **kwargs) - - if __name__ == "__main__": main()