[go: up one dir, main page]

CI: refactor coverage merging and only upload successfully merged traces

What

This refactors the handling of coverage traces and modifies it so that at most one coverage-related file is uploaded.

Why

Previously, the whole $BISECT_FILE directory (set to _coverage_output) was uploaded as an artifact. Normally, this will contain a README and a merged coverage trace. However, if for some reason merging does not occur (for instance, tests fail before merge), a large number of coverage files are uploaded, potentially surpassing GitLab's 1GB artifact size limit.

https://gitlab.com/tezos/tezos/-/jobs/6626435992#L3849

How

Change the naming of the merged coverage file to use the predefined variable CI_JOB_NAME_SLUG instead. The advantage is that we can then specify to store only files whose name is a prefix of that variable, instead of storing the full directory as before. This ensures that if the directory $BISECT_FILE contains unmerged trace files then they will not be uploaded, as they will not have the necessary prefix. Unmerged coverage trace files are on the form NNN.coverage where NNN is a random number.

Manually testing the MR

Check out the CI of this MR. Note the naming of the uploaded coverage traces. Note that they are successfully merged in the job unified_coverage.

Try the coverage downloader on the same pipeline:

dune exec scripts/ci/download_coverage/download.exe -- --from 1256851926 --verbose

To try the script ./scripts/ci/merge_coverage.sh

If BISECT_FILE is empty or CI_MERGE_REQUEST_LABELS contains ci--no-coverage, it only removes all coverage files from _coverage_output and reports coverage disabled:

CI_JOB_NAME_SLUG=foobar ./scripts/ci/merge_coverage.sh
CI_JOB_NAME_SLUG=foobar BISECT_FILE=foobar CI_MERGE_REQUEST_LABELS=ci--no-coverage ./scripts/ci/merge_coverage.sh

If BISECT_FILE is set but coverage is corrupt:

$ touch _coverage_output/lol.coverage
$ CI_JOB_ID=1234 CI_JOB_NAME="foobar" CI_JOB_URL=http://disney.com CI_JOB_NAME_SLUG=foobar BISECT_FILE=_coverage_output/ ./scripts/ci/merge_coverage.sh

it writes `_coverage_output/foobar.corrupt.json

If BISECT_FILE is set and there are coverage traces:

$ make coverage-clean
$ ./scripts/with_coverage.sh dune exec src/lib_version/exe/octez_print_version.exe
$ CI_JOB_NAME_SLUG=foobar BISECT_FILE=_coverage_output/ ./scripts/ci/merge_coverage.sh

It merges the traces into: _coverage_output/foobar.coverage.

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Arvid Jakobsson

Merge request reports

Loading