Skip to content

Add codecov #4448

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

Merged
merged 5 commits into from
May 31, 2019
Merged

Add codecov #4448

merged 5 commits into from
May 31, 2019

Conversation

yumibagge
Copy link
Contributor

@yumibagge yumibagge commented Mar 28, 2019

The purpose of this PR is to understand current CBMC coverage.

Below are justification of why I created buildspec-linux-make-gcc-cov.yml and modified config.inc

travis vs. CodeBuild
😢 travis has timeout = 50min and maximum log length 10k

😢 codecov does not support CodeBuild
🔨 Therefore CODECOV_TOKEN needs to be set as a environment variable in Build detail (not in buildspec.xml)
🔨 In order to coverage reporting available, needed to install lcov, curl, python-pip, then pip install codecov (This is to hope codecov.sh find all gcda files)

cmake vs. make

😞 make with CXXFLAGS in the same line causes compile error
🔨 to mitigate this, in config.inc, a new environment variable CPROVER_WITH_PROFILING with CXXFLAGS and LINKFLAGS are added
🔨 append CPROVER_WITH_PROFILING=1 is added for each make and also make -C regression test as it's calling driver which also require coverage instrumentation
cmake and make shows different statistics
❔ it is unclear why it's reported failure when build is complete for cmake

codecov script
😞 bash does not work on CodeBuild
🔨 use the 4 line shell scripts

lcov
😞 codecov.sh does not find gcda files for some reasons, so had to generate coverage info file using lcov

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@yumibagge yumibagge marked this pull request as ready for review March 28, 2019 10:20
@chrisr-diffblue chrisr-diffblue changed the title Add codecov [WIP] Add codecov Mar 28, 2019
@tautschnig
Copy link
Collaborator

Would it be possible to add a few comments to clarify, including a full commit message? This looks like a piece of black magic right now. Useful documentation would include links to documentation that explain that this is the way to interact with codecov.io. Thanks!

Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a work-in-progress experiment by Yumi, which is not intended to be merged just yet. I'm putting a blocking comment here for now, until such times as the experiments are over and we can then decided whether to merge or close.

@tautschnig
Copy link
Collaborator

If we're talking code coverage, here's what I'm dreaming of:

  1. Just overall coverage reports to see how we are doing.
  2. A CI task that compares the coverage report to the changes proposed in a PR, much like we are doing this with clang-format, cpplint, doxygen. The task should fail if modified code is not covered, unless some break-glass option is used (such as special commands in the commit message to openly admit that the changes aren't covered by tests).

@martin-cs
Copy link
Collaborator

A long standing problem with the CPROVER code base is functionality bit-rotting because everyone assumed someone else was using / testing it. If this could help us identify or even avoid this, it would be great.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 3ccfd64).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106160190
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: a62bf2d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106437109
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 23c389f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106458365
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 8cbcbce).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106465840
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

@yumibagge yumibagge force-pushed the yb/codecov branch 6 times, most recently from 09dbbc0 to 8863565 Compare March 31, 2019 15:17
.travis.yml Outdated
@@ -4,7 +4,7 @@ jobs:
include:

- &formatting-stage
stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spurious change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit was removed

- '/var/lib/apt/lists/**/*'
- '/root/.ccache/**/*'
- '/root/.cache/codecov.sh'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the spaces in this line

@yumibagge yumibagge force-pushed the yb/codecov branch 2 times, most recently from 5c0316d to 2d7a508 Compare May 30, 2019 08:45
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 2d7a508).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113725873
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reasonably happy for this to go in as it is, but I've left a couple of queries as comments that would be good to check.

- make -C jbmc/unit test
- make -C jbmc/regression test
- lcov --capture --directory . --output-file ./lcov.info
- VCS_PULL_REQUEST=$(echo $CODEBUILD_SOURCE_VERSION | sed 's/pr\///g')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is VCS_PULL_REQUEST actually used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not too sure. As I referred in another your question. I took this 4 lines of scripts from codecov/codecov-python#140.

- VCS_PULL_REQUEST=$(echo $CODEBUILD_SOURCE_VERSION | sed 's/pr\///g')
- COV_SCRIPT=/root/.cache/codecov.sh
- if [ ! -f "$COV_SCRIPT" ]; then curl -s https://codecov.io/bash > "$COV_SCRIPT"; fi
- echo "$CODEBUILD_INITIATOR" | grep GitHub && bash "$COV_SCRIPT" -t "$CODECOV_TOKEN" || true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand what this line is doing (I'm afraid I don't know what the contents of $CODEBUILD_INITIATOR is off the top of my head) - but I'm slightly worried by the || true - which will basically mask any errors that occur here?

Copy link
Contributor Author

@yumibagge yumibagge May 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, essentially I blindly used script example here
codecov/codecov-python#140
According to https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html, $CODEBUILD_INITIATOR is "the entity that started the build". In our case, (also from log), I believe this is webhook?
[Container] 2019/05/30 09:35:34 Running command echo "$CODEBUILD_INITIATOR" | grep GitHub && bash "$COV_SCRIPT" -t "$CODECOV_TOKEN" || true
GitHub-Hookshot/0a2cefb

Do you want me to try removing the || true?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm honestly not sure on the || true - I guess lets run it as is and see how reliable it is.

@@ -8,6 +8,11 @@ else
CXXFLAGS += -Wall -pedantic -Werror -Wno-deprecated-declarations -Wswitch-enum
endif

ifeq ($(CPROVER_WITH_PROFILING),1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you mentioned that somehow CMake unit tests fail if coverage is enabled, but I think it would still be preferable if we kept Make and CMake builds in sync, and at least adding these options to CMake would be good - even if you raise an issue in the GitHub issue tracker to cover whatever failures you see in CMake unit tests rather than also fixing them in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. The thing is this invariant violation happens only codebuild, and I've tried to reproduce it on local codebuild docker, it did not reproduce. I have a gut feeling though initially, cbmc-codecov environment was openjdk-8, not standard-2.0. Let me give me another go with cmake-coverage and if it's reproducible, I will raise an issue in the GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisr-diffblue , OK, so perhaps the invariant violation I observed was because of AWS image. I no longer observe it. I still have a problem codecov does not find existing coverage files from the VM. I will push just one more time with extra LCOV command it should be able to report. In that case, do you want another buildspec file buildspec-linux-cmake-gcc-cov.yml and CMakeLists.txt to be part of this PR?

@yumibagge yumibagge force-pushed the yb/codecov branch 4 times, most recently from af5c1c2 to 5db16f5 Compare May 30, 2019 13:07
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 5db16f5).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113763817
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 6feed18).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113781916
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 41365e2).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113796061
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

@yumibagge
Copy link
Contributor Author

yumibagge commented May 30, 2019

@peterschrammel and @chrisr-diffblue, I am requesting re-review as the current state is

  • buildspec-linux-make-gcc-cov.xml, config.inc and README.md with codecov badge for CI (both of you approved in this state)
  • buildspec-linux-cmake-gcc-cov.xml and CMakeLists.txt for cmake build but not for CI.

As per request from @chrisr-diffblue, I checked cmake behaviour and a good news is cmake with coverage build does not cause the invariant violation I've initially observed.
Hence, the plan is to add buildspec for cmake-gcc-cov and CMakeLists for the future but not as a part of CI. (I have confirmed buildspec-linux-cmale-gcc-cov.xml succeeded to complete - but for some reasons the PR page said build failed)
image

However, I also realised that there is a quite a bit of difference in analysed lines between make and cmake (Above is make and below is cmake)
image

This trend is reproducible locally
make
image
cmake
image

make
https://codecov.io/gh/diffblue/cbmc/tree/2d7a508576462ca9fae683b642949b736a736997/

cmake
https://codecov.io/gh/diffblue/cbmc/tree/6feed18c171ea61a1a3e08dfe19345242c1d5bc4/

make reports higher coverage, but cmake analyses more lines (the difference in line is 27k?).

Do you want me to investigate this on any further before merged?

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: a780511).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113807199
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

@chrisr-diffblue
Copy link
Contributor

@yumibagge @peterschrammel - Thanks Yumi for the extra clarification. I'm happy for this to go in as it is - but it would be nice to understand why cmake and make give different coverage results. It doesn't entirely surprise me, and I can think of a number of reasons why coverage might be different, but it would be good to be sure :-) However, I'm happy for that work to be done separately to this PR.

@peterschrammel
Copy link
Member

Do you want me to investigate this on any further before merged?

I think this definitely needs to be investigated, but it can be done as a follow-up action.

@peterschrammel peterschrammel merged commit 24212bf into diffblue:develop May 31, 2019
@yumibagge yumibagge deleted the yb/codecov branch July 20, 2019 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants