diff --git a/.ci/DockerFile.Repository b/.ci/DockerFile.Repository index d2bdb57e..e6581592 100644 --- a/.ci/DockerFile.Repository +++ b/.ci/DockerFile.Repository @@ -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 diff --git a/.github/workflows/test-integrations-unreleased.yml b/.github/workflows/test-integrations-unreleased.yml index 4835e00f..9e63a23b 100644 --- a/.github/workflows/test-integrations-unreleased.yml +++ b/.github/workflows/test-integrations-unreleased.yml @@ -46,4 +46,9 @@ jobs: components: rustfmt, clippy - name: Integ OpenSearch ${{ matrix.entry.opensearch_ref }} secured=false - run: "./.ci/run-tests opensearch SNAPSHOT false" \ No newline at end of file + run: "./.ci/run-tests opensearch SNAPSHOT false" + + - uses: codecov/codecov-action@v3 + with: + files: ./test_results/opensearch.lcov + flags: integration \ No newline at end of file diff --git a/.github/workflows/test-integrations.yml b/.github/workflows/test-integrations.yml index f954afa2..830213ce 100644 --- a/.github/workflows/test-integrations.yml +++ b/.github/workflows/test-integrations.yml @@ -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 \ No newline at end of file diff --git a/Makefile.toml b/Makefile.toml index 1ce8f8cb..2afe7a71 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -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 @@ -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]