From da2e3eb1ee059afff6037ba50d0a2442558069f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=8BAndrzej=20Ressel?= Date: Sun, 29 Sep 2024 21:37:30 +0200 Subject: [PATCH] Code coverage (#428) --- .config/nextest.toml | 2 ++ .github/workflows/build.yml | 17 +++++++++++++++++ .gitignore | 3 ++- justfile | 10 +++++++++- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .config/nextest.toml diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 000000000..53eb9d6d0 --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,2 @@ +[profile.ci.junit] # this can be some other profile, too +path = "junit.xml" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 625553faf..c4f9cac95 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -106,6 +106,23 @@ jobs: run: just test env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get code coverage + run: just test-coverage + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload coverage data to codecov + uses: codecov/codecov-action@v4 + with: + files: lcov.info + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + files: target/nextest/ci/junit.xml + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} - run: git add . && git diff - run: git diff --cached - name: Ensure no files have changed diff --git a/.gitignore b/.gitignore index b6447cbe9..e18a3be90 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ target .idea/ output.log -*.wasm \ No newline at end of file +*.wasm +lcov.info \ No newline at end of file diff --git a/justfile b/justfile index 346034303..f7cd7aeaa 100644 --- a/justfile +++ b/justfile @@ -5,6 +5,8 @@ NEXTEST_VERSION := "0.9.72" CARGO_COMPONENT_VERSION := "0.16.0" # renovate: datasource=crate depName=sd packageName=sd SD_VERSION := "1.0.0" +# renovate: datasource=crate depName=cargo-llvm-cov packageName=cargo-llvm-cov +CARGO_LLVM_COV_VERSION := "0.6.13" FORMATTABLE_PROJECTS := "-p pulumi_wasm -p pulumi_wasm_common -p pulumi_wasm_generator -p pulumi_wasm_generator_lib \ -p pulumi_wasm_runner -p pulumi_wasm_runner_component_creator -p pulumi_wasm_rust -p pulumi_wasm_rust_macro \ @@ -28,9 +30,11 @@ package-language-plugin VERSION: install-requirements: rustup component add rustfmt + rustup component add llvm-tools-preview cargo binstall --no-confirm cargo-nextest@{{NEXTEST_VERSION}} cargo binstall --no-confirm cargo-component@{{CARGO_COMPONENT_VERSION}} cargo binstall --no-confirm sd@{{SD_VERSION}} + cargo binstall --no-confirm cargo-llvm-cov@{{CARGO_LLVM_COV_VERSION}} # Compiling everything together causes linking issues build-wasm-components: @@ -118,7 +122,11 @@ publish-providers: # DO NOT EDIT - PUBLISH-PROVIDERS - END test: - cargo nextest run --workspace --timings + cargo nextest run --profile ci --workspace --timings + +test-coverage: + cargo llvm-cov --no-report -p pulumi_wasm_core + cargo llvm-cov report --lcov --output-path lcov.info docs: docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material