Merge pull request #3632 from stacks-network/chore/unit-test-speedup

CI/Build: Speedup unit tests
This commit is contained in:
pavitthrap
2023-03-30 13:59:33 -04:00
committed by GitHub
3 changed files with 19 additions and 29 deletions

View File

@@ -1,22 +0,0 @@
FROM rust:bullseye AS test
WORKDIR /build
ENV CARGO_MANIFEST_DIR="$(pwd)"
RUN rustup component add llvm-tools-preview && \
cargo install grcov
ENV RUSTFLAGS="-Cinstrument-coverage" \
LLVM_PROFILE_FILE="stacks-blockchain-%p-%m.profraw"
COPY . .
RUN cargo build --workspace && \
cargo test --workspace
# Generate coverage report and upload it to codecov
RUN grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
FROM scratch AS export-stage
COPY --from=test /build/lcov.info /

View File

@@ -40,17 +40,21 @@ jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Add code coverage tools
run: |
rustup component add llvm-tools-preview
cargo install grcov
- uses: actions/checkout@v2
- name: Run units tests (with coverage)
env:
DOCKER_BUILDKIT: 1
# Remove .dockerignore file so codecov has access to git info
RUSTFLAGS: -Cinstrument-coverage
LLVM_PROFILE_FILE: stacks-blockchain-%p-%m.profraw
run: |
rm .dockerignore
docker build -o coverage-output -f ./.github/actions/bitcoin-int-tests/Dockerfile.code-cov .
cargo test --workspace
grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
- uses: codecov/codecov-action@v2
with:
files: ./coverage-output/lcov.info
files: ./lcov.info
name: unit_tests
fail_ci_if_error: false

View File

@@ -109,8 +109,16 @@ monitoring_prom = ["prometheus"]
slog_json = ["slog-json", "stacks_common/slog_json", "clarity/slog_json"]
testing = []
[profile.dev.package.regex]
opt-level = 2
# Use a bit more than default optimization for
# dev builds to speed up test execution
[profile.dev]
opt-level = 1
# Use release-level optimization for dependencies
# This slows down "first" builds on development environments,
# but won't impact subsequent builds.
[profile.dev.package."*"]
opt-level = 3
[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(target_env = "msvc")))'.dependencies]
sha2 = { version = "0.10", features = ["asm"] }