Skip to content

Commit

Permalink
Merge branch 'IDX-2603-bazel-test-coverage' into 'master'
Browse files Browse the repository at this point in the history
chore(IDX-2603): generate test coverage

Initial test coverage job ~ execute `bazel coverage` for targets that don't depend on any canister codebase ([no instrumentation supported](rust-lang/rust#81684)) on scheduled CI pipeline and manually on MR pipelines. Report is accessible via CI job's artifacts ~ [example](https://dfinity-lab.gitlab.io/-/public/ic/-/jobs/5036171285/artifacts/cov_html/index.html).

Ignoring the failure of tests for now. Will be addressed separately.
> Coverage reports are also produced if tests fail, though note that this does not extend to the failed tests - only passing tests are reported.

Closes IDX-2603 

Closes IDX-2603

See merge request dfinity-lab/public/ic!14633
  • Loading branch information
marko-k0 committed Sep 14, 2023
2 parents 0ebf3ed + 7bd6093 commit ea66978
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"image": "dfinity/ic-build:4f2f17cf3622948424b0aeb6c0b57c82112d7a3e7174250d25181fe8a4d66334",
"image": "dfinity/ic-build:2da2766c7ab6cfc0ae6104e39e104ed5de4389c87f121b18ca4bc4d672f7ba03",
"remoteUser": "ubuntu",
"privileged": true,
"runArgs": [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: self-hosted
timeout-minutes: 80
container:
image: dfinity/ic-build:4f2f17cf3622948424b0aeb6c0b57c82112d7a3e7174250d25181fe8a4d66334
image: dfinity/ic-build:2da2766c7ab6cfc0ae6104e39e104ed5de4389c87f121b18ca4bc4d672f7ba03
options: --user ubuntu
if: ${{ vars.RUN_CI == 'true' }}
steps:
Expand Down
1 change: 1 addition & 0 deletions bazel/canisters.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def rust_canister(name, service_file, **kwargs):
"""
wasm_name = "_wasm_" + name.replace(".", "_")
kwargs.setdefault("visibility", ["//visibility:public"])
kwargs.setdefault("tags", []).append("canister")

rust_binary(
name = wasm_name,
Expand Down
4 changes: 2 additions & 2 deletions gitlab-ci/config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ after_script:
artifacts:
expire_in: 3 days
image:
name: "registry.gitlab.com/dfinity-lab/core/docker/ic-build:4f2f17cf3622948424b0aeb6c0b57c82112d7a3e7174250d25181fe8a4d66334"
name: "registry.gitlab.com/dfinity-lab/core/docker/ic-build:2da2766c7ab6cfc0ae6104e39e104ed5de4389c87f121b18ca4bc4d672f7ba03"
tags:
- dfinity-ic
variables:
Expand All @@ -133,7 +133,7 @@ after_script:
.ic-build-legacy-image:
extends: .ic-build-image
image:
name: "registry.gitlab.com/dfinity-lab/core/docker/ic-build-legacy:4f2f17cf3622948424b0aeb6c0b57c82112d7a3e7174250d25181fe8a4d66334"
name: "registry.gitlab.com/dfinity-lab/core/docker/ic-build-legacy:2da2766c7ab6cfc0ae6104e39e104ed5de4389c87f121b18ca4bc4d672f7ba03"

.cargo-rules:
rules:
Expand Down
27 changes: 27 additions & 0 deletions gitlab-ci/config/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,33 @@ bazel-build-fuzzers-archives:
fi
- !reference [after_script]


bazel-test-coverage:
extends:
- .bazel-test-all
- .rules-post-master
timeout: 80 minutes
artifacts:
expire_in: 14 days
when: always
paths:
- cov_targets.txt
- cov_report.dat
- cov_html
variables:
BAZEL_COMMAND: "coverage"
BAZEL_EXTRA_ARGS: "--repository_cache=/cache/bazel --combined_report=lcov"
script:
- |
bazel query --universe_scope=//... \
"kind(test, //rs/...) except kind(test, allrdeps(attr('tags', 'canister', //rs/...)))" > cov_targets.txt
# shellcheck disable=SC2046,SC2086
bazel ${BAZEL_STARTUP_ARGS} coverage ${BAZEL_CI_CONFIG} ${BAZEL_EXTRA_ARGS} \
--combined_report=lcov $(<cov_targets.txt) || true
cp bazel-out/_coverage/_coverage_report.dat cov_report.dat
genhtml --output cov_html cov_report.dat
bazel-test-all:
extends:
- .bazel-test-all
Expand Down
Loading

0 comments on commit ea66978

Please sign in to comment.