Skip to content

Conversation

@navinns
Copy link
Contributor

@navinns navinns commented Jul 24, 2020

Issue #, if available:

Description of changes:

  • Adds code to create coverage report
  • Adds option to upload report to codecov.io

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@navinns navinns requested a review from aggarw13 July 24, 2020 20:00
@navinns navinns force-pushed the development branch 2 times, most recently from 59cfdd8 to 97629a4 Compare July 24, 2020 20:27
pavanmr94
pavanmr94 previously approved these changes Jul 24, 2020
aggarw13
aggarw13 previously approved these changes Jul 24, 2020
@navinns navinns requested a review from dan4thewin July 24, 2020 21:46
log("\n----------------------------------------------------------------")
log("Upload Code Coverage report to codecov.io")
log("----------------------------------------------------------------")
cmd = f"curl -s https://codecov.io/bash | bash -s - -t {codecov_token}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey... umm... this is a non-starter.

Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify, I mean running untrusted code is a non-starter.

@codecov-commenter
Copy link

codecov-commenter commented Jul 28, 2020

Codecov Report

Merging #1076 into development will increase coverage by 3.45%.
The diff coverage is 100.00%.

Impacted file tree graph

@@               Coverage Diff                @@
##           development     #1076      +/-   ##
================================================
+ Coverage        96.54%   100.00%   +3.45%     
================================================
  Files                9         4       -5     
  Lines             5643      1180    -4463     
  Branches           641       365     -276     
================================================
- Hits              5448      1180    -4268     
+ Misses               9         0       -9     
+ Partials           186         0     -186     
Impacted Files Coverage Δ
libraries/standard/mqtt/src/mqtt_state.c 100.00% <ø> (+4.06%) ⬆️
libraries/standard/http/src/http_client.c 100.00% <100.00%> (+12.51%) ⬆️
libraries/standard/mqtt/src/mqtt.c 100.00% <100.00%> (+5.58%) ⬆️
libraries/standard/mqtt/src/mqtt_lightweight.c 100.00% <100.00%> (+5.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c2f3405...df9d7c7. Read the comment docs.

target_build_result = target_result.setdefault("CodeCoverage", {})
out = _build_target("coverage", src, build_path, build_flags, c_flags)
log(out)
out = _run_cmd(f"gcovr -r . -x -o {build_path}/cobertura.xml")
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be named cobertura?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes as we can use this file with cobertura as well

out = _run_cmd(f"gcovr -r . -x -o {build_path}/cobertura.xml")
log(out)

commit_id = os.environ.get("ghprbActualCommit") or ""
Copy link
Member

Choose a reason for hiding this comment

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

We probably want coverage run on the merge head (${sha1} in Jenkins)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm ok

Comment on lines +186 to +207
cmd_code_coverage,
"--config-file",
"--src",
"--build-path",
"--build-flags",
"--c-flags",
"--codecov-token",
)
Copy link
Member

Choose a reason for hiding this comment

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

At this point I'm inclined to think we should just take the config as an argument and do the rest through the config or environment variables. It's getting difficult to grapple with all the options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

config is one of the argument, we have options to override options in config

Copy link
Member

Choose a reason for hiding this comment

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

I'm not convinced that flexibility is required.

return result


def _build_code_coverage(src, build_path, build_flags, c_flags, codecov_token):
Copy link
Member

Choose a reason for hiding this comment

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

what's the significance of build_flags vs c_flags?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in csdk we have 2 levels of flags one for cmake and other for compiler

build_flags is for cmake and c_flags are for compiler

Copy link
Member

Choose a reason for hiding this comment

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

I don't like the build_flags name. But at the very least we should have a descriptive doc string saying what they are.

navinns added 3 commits August 4, 2020 20:49
* Adds code to create coverage report
* Adds option to upload report to codecov.io
nateglims
nateglims previously approved these changes Aug 4, 2020
target_build_result = target_result.setdefault("CodeCoverage", {})
out = _build_target("coverage", src, build_path, build_flags, c_flags)
log(out)
out = _run_cmd(f"gcovr -r . -x -o {build_path}/cobertura.xml")
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this might be passed to a shell - so what happens if build path contains a space?

Copy link
Contributor

Choose a reason for hiding this comment

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

or worse, a semicolon...

@navinns navinns force-pushed the development branch 2 times, most recently from 4be5512 to f55fbf7 Compare August 5, 2020 01:02
nateglims
nateglims previously approved these changes Aug 5, 2020
@navinns navinns merged commit b5f1ed6 into aws:development Aug 5, 2020
@navinns navinns deleted the development branch August 5, 2020 01:17
@navinns navinns restored the development branch August 5, 2020 19:26
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Aug 27, 2020
* Adds Code Coverage

* Adds code to create coverage report
* Adds option to upload report to codecov.io

* Use requests
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Aug 28, 2020
* Adds Code Coverage

* Adds code to create coverage report
* Adds option to upload report to codecov.io

* Use requests
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Aug 31, 2020
* Adds Code Coverage

* Adds code to create coverage report
* Adds option to upload report to codecov.io

* Use requests
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Sep 1, 2020
* Adds Code Coverage

* Adds code to create coverage report
* Adds option to upload report to codecov.io

* Use requests
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.

6 participants