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

Add code coverage collection and reporting #74

Merged
merged 2 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion .ci/DockerFile.Repository
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ RUN set -eux; \
pkg-config \
; \
cargo install --force cargo-make; \
cargo install cargo2junit;
cargo install cargo2junit; \
rustup component add llvm-tools-preview; \
cargo install grcov;

# create app directory
WORKDIR /usr/src/opensearch-rs
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test-integrations-unreleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ jobs:
components: rustfmt, clippy

- name: Integ OpenSearch ${{ matrix.entry.opensearch_ref }} secured=false
run: "./.ci/run-tests opensearch SNAPSHOT false"
run: "./.ci/run-tests opensearch SNAPSHOT false"

- uses: codecov/codecov-action@v3
with:
files: ./test_results/opensearch.lcov
flags: integration
4 changes: 4 additions & 0 deletions .github/workflows/test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ jobs:
components: rustfmt, clippy
- name: Integ OpenSearch ${{ matrix.entry.version }} secured=${{ matrix.secured }}
run: "./.ci/run-tests opensearch ${{ matrix.entry.version }} ${{ matrix.secured }}"
- uses: codecov/codecov-action@v3
with:
files: ./test_results/opensearch.lcov
flags: integration

15 changes: 14 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ condition = { env_set = [ "OPENSEARCH_URL" ], env_true = ["CARGO_MAKE_CI"] }
script = ["cargo test -p yaml_test_runner -- --test-threads 1 -Z unstable-options --format json | tee test_results/results.json"]
dependencies = ["generate-yaml-tests"]

[tasks.set-coverage-vars]
description = "Set environment variables to enable coverage data"
private = true
condition = { env_true = [ "CARGO_MAKE_CI" ] }
env = { "RUSTFLAGS" = "-C instrument-coverage", "LLVM_PROFILE_FILE" = "${CARGO_MAKE_WORKING_DIRECTORY}/test_results/opensearch-%m.profraw" }

[tasks.convert-coverage-data]
description = "Convert coverage data to lcov format"
private = true
condition = { env_true = [ "CARGO_MAKE_CI" ] }
command = "grcov"
args = ["./test_results", "-s", ".", "--binary-path", "./target/debug", "-t", "lcov", "--branch", "--ignore-not-existing", "--llvm", "-o", "./test_results/opensearch.lcov"]

[tasks.test-opensearch]
category = "OpenSearch"
private = true
Expand Down Expand Up @@ -124,7 +137,7 @@ env = { "CLEANUP" = true, "DETACH" = false }
category = "OpenSearch"
description = "Generates and runs yaml_test_runner package platinum/free tests against a given OpenSearch version"
condition = { env_set = [ "STACK_VERSION"] }
dependencies = ["generate-yaml-tests", "create-test-results-dir", "test-yaml-test-runner", "test-yaml-test-runner-ci", "convert-test-results-junit"]
dependencies = ["set-coverage-vars", "generate-yaml-tests", "create-test-results-dir", "test-yaml-test-runner", "test-yaml-test-runner-ci", "convert-coverage-data", "convert-test-results-junit"]
run_task = "stop-opensearch"

[tasks.test-generator]
Expand Down