Skip to content
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

NEXT-37303 - Add coverage to CI #14

Merged
merged 3 commits into from
Aug 2, 2024

Conversation

MalteJanz
Copy link
Contributor

@MalteJanz MalteJanz commented Jul 30, 2024

Adds coverage reporting to the CI

Unfortunately GitHub is not able to display covered lines in the diff viewer, unlike GitLab. So Instead I came up with the following solution:

  • every PR gets a comment with
    • an overview of the total repository coverage
    • a link to download the complete HTML report, that includes all the details like which lines are covered

Increases the coverage and code cleanup

Additionally I did some code cleanup + written more tests for the already existing code.

@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch 9 times, most recently from 6ee25af to 8099cad Compare July 30, 2024 13:53
@shopware shopware deleted a comment from github-actions bot Jul 30, 2024
@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch 2 times, most recently from de5061d to 3be797c Compare July 30, 2024 14:23
@shopware shopware deleted a comment from github-actions bot Jul 30, 2024
@shopware shopware deleted a comment from github-actions bot Jul 30, 2024
@shopware shopware deleted a comment from github-actions bot Jul 30, 2024
@MalteJanz MalteJanz self-assigned this Jul 30, 2024
@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch 2 times, most recently from 587c335 to ec073e3 Compare July 30, 2024 15:02
@shopware shopware deleted a comment from github-actions bot Jul 30, 2024
@shopware shopware deleted a comment from github-actions bot Jul 30, 2024
@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch from ec073e3 to 0168007 Compare July 30, 2024 15:05
@MalteJanz
Copy link
Contributor Author

ToDo: increase coverage + code cleanup

@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch from 0168007 to 0677846 Compare July 30, 2024 15:13
@shopware shopware deleted a comment from github-actions bot Jul 30, 2024
@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch from 0677846 to 44a7c36 Compare July 30, 2024 15:17
@shopware shopware deleted a comment from github-actions bot Jul 30, 2024
@shopware shopware deleted a comment from github-actions bot Jul 30, 2024
@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch from 44a7c36 to 3a55c78 Compare July 31, 2024 06:39
@shopware shopware deleted a comment from github-actions bot Jul 31, 2024
@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch from 3a55c78 to 05e2448 Compare July 31, 2024 06:49
@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch 2 times, most recently from 3be698f to 2c64fce Compare August 1, 2024 12:55
@shopware shopware deleted a comment from github-actions bot Aug 1, 2024
@shopware shopware deleted a comment from github-actions bot Aug 1, 2024
@shopware shopware deleted a comment from github-actions bot Aug 1, 2024
@shopware shopware deleted a comment from github-actions bot Aug 1, 2024
@shopware shopware deleted a comment from github-actions bot Aug 1, 2024
@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch from 2c64fce to 17fbd66 Compare August 2, 2024 06:28
@shopware shopware deleted a comment from github-actions bot Aug 2, 2024
@MalteJanz MalteJanz marked this pull request as ready for review August 2, 2024 06:28
Copy link

github-actions bot commented Aug 2, 2024

Summary of the total line code coverage for the whole codebase

Total lines Covered Skipped %
1809 960 849 53.07
Summary of each file (click to expand)
File Total lines Covered Skipped %
src/api/filter.rs 133 132 1 99.25
src/api/mod.rs 263 0 263 0.00
src/cli.rs 43 30 13 69.77
src/config_file.rs 68 44 24 64.71
src/data/export.rs 115 0 115 0.00
src/data/import.rs 138 0 138 0.00
src/data/transform/mod.rs 334 259 75 77.54
src/data/transform/script.rs 233 197 36 84.55
src/data/validate.rs 298 298 0 100.00
src/main.rs 184 0 184 0.00
More details (click to expand)

Download full HTML report

You can download the full HTML report here: click to download
Hint: You need to extract it locally and open the index.html, there you can see which lines are not covered in each file.

You can also generate these reports locally

For that, you need to install cargo-llvm-cov, then you can run:

cargo llvm-cov --all-features --no-fail-fast --open

Hint: There are also other ways to see code coverage in Rust. For example with RustRover, you can execute tests with coverage generation directly in the IDE.

Remember

Your tests should be meaningful and not just be written to raise the coverage.
Coverage is just a tool to detect forgotten code paths you may want to think about, not your instructor to write tests

@MalteJanz
Copy link
Contributor Author

Let's get these changes merged for now. I will keep the ticket still in progress and do a follow up PR with further tests 🙂 .

But before writing further tests I want to experiment with a bigger refactor: I want to try removing async from the codebase, as it has the potential to reduce the complexity quite a bit and is one less (complex) topic to learn. It's still unclear to me if that refactor works out but it's better to try it sooner than later. Points that need an answer:

  • Can the non-async code also be as cleanly written?
  • Is there a big performance hit by going with a normal thread pool approach?

Copy link
Member

@LarsKemper LarsKemper left a comment

Choose a reason for hiding this comment

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

LGTM 💪

Especially the type conversion during deserialization, has already caused issues with the default profiles for me 😅

.github/workflows/ci.yml Show resolved Hide resolved
@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch from 17fbd66 to 7fb15e1 Compare August 2, 2024 07:56
Copy link

github-actions bot commented Aug 2, 2024

Summary of the total line code coverage for the whole codebase

Total lines Covered Skipped %
1829 974 855 53.25
Summary of each file (click to expand)
File Total lines Covered Skipped %
src/api/filter.rs 147 146 1 99.32
src/api/mod.rs 267 0 267 0.00
src/cli.rs 43 30 13 69.77
src/config_file.rs 68 44 24 64.71
src/data/export.rs 117 0 117 0.00
src/data/import.rs 138 0 138 0.00
src/data/transform/mod.rs 334 259 75 77.54
src/data/transform/script.rs 233 197 36 84.55
src/data/validate.rs 298 298 0 100.00
src/main.rs 184 0 184 0.00
More details (click to expand)

Download full HTML report

You can download the full HTML report here: click to download
Hint: You need to extract it locally and open the index.html, there you can see which lines are not covered in each file.

You can also generate these reports locally

For that, you need to install cargo-llvm-cov, then you can run:

cargo llvm-cov --all-features --no-fail-fast --open

Hint: There are also other ways to see code coverage in Rust. For example with RustRover, you can execute tests with coverage generation directly in the IDE.

Remember

Your tests should be meaningful and not just be written to raise the coverage.
Coverage is just a tool to detect forgotten code paths you may want to think about, not your instructor to write tests

"limit": null,
"page": 1
}
"media": {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LarsKemper after rebasing I cleaned up the criteria serialization a bit more:

  • to not include "limit": null, because why send that data to the server
  • to not include "page": 1, because that should also be the default on the server side

So we're back to empty objects in the request if there is no criteria for an association 🎉

I also found a small issue that the clippy CI pipeline wasn't failing on warnings (it's a really nice linter and reported a useful warning on your last PR, see https://github.com/shopware/sw-sync-cli/actions/runs/10211517905/job/28253002414#step:5:12 🙈 )

@MalteJanz MalteJanz force-pushed the next-37303/add-code-coverage-and-cleanup branch from 7fb15e1 to 3360b5a Compare August 2, 2024 08:01
Copy link

github-actions bot commented Aug 2, 2024

Summary of the total line code coverage for the whole codebase

Total lines Covered Skipped %
1826 971 855 53.18
Summary of each file (click to expand)
File Total lines Covered Skipped %
src/api/filter.rs 144 143 1 99.31
src/api/mod.rs 267 0 267 0.00
src/cli.rs 43 30 13 69.77
src/config_file.rs 68 44 24 64.71
src/data/export.rs 117 0 117 0.00
src/data/import.rs 138 0 138 0.00
src/data/transform/mod.rs 334 259 75 77.54
src/data/transform/script.rs 233 197 36 84.55
src/data/validate.rs 298 298 0 100.00
src/main.rs 184 0 184 0.00
More details (click to expand)

Download full HTML report

You can download the full HTML report here: click to download
Hint: You need to extract it locally and open the index.html, there you can see which lines are not covered in each file.

You can also generate these reports locally

For that, you need to install cargo-llvm-cov, then you can run:

cargo llvm-cov --all-features --no-fail-fast --open

Hint: There are also other ways to see code coverage in Rust. For example with RustRover, you can execute tests with coverage generation directly in the IDE.

Remember

Your tests should be meaningful and not just be written to raise the coverage.
Coverage is just a tool to detect forgotten code paths you may want to think about, not your instructor to write tests

@MalteJanz MalteJanz merged commit 97f8184 into main Aug 2, 2024
3 checks passed
@MalteJanz MalteJanz deleted the next-37303/add-code-coverage-and-cleanup branch August 2, 2024 12:07
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.

3 participants