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

Add support for -cover + integration test code coverage #7415

Merged
merged 7 commits into from
May 8, 2023

Conversation

dereknola
Copy link
Member

@dereknola dereknola commented May 2, 2023

Proposed Changes

Adds the new cover flag in go 1.20. This enables us to get complete coverage reports from all our Integration tests.

Types of Changes

Build Feature

Verification

To use the new tool:

  1. Build K3s with a new build flag GOCOVER=1 make
  2. Set the GOCOVERDIR env to an empty directory where the metadata + counters will be written to
  3. Start K3s or run an integration test
  4. When finished (either stopping k3s or the test finishes) use the go tool covdata to generate results
    • go tool covdata percent -i $GOCOVERDIR produces a human readable percentage for all package files
    • go tool covdata textfmt -i $GOCOVERDIR -o coverage.out produces a report readable by tools like codecov and coveralls

Testing

Linked Issues

User-Facing Change


Further Comments

@dereknola dereknola requested a review from a team as a code owner May 2, 2023 23:11
@codecov
Copy link

codecov bot commented May 3, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.25 🎉

Comparison is base (e1d4cff) 19.57% compared to head (cb77990) 19.83%.

❗ Current head cb77990 differs from pull request most recent head 63997c7. Consider uploading reports for the commit 63997c7 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7415      +/-   ##
==========================================
+ Coverage   19.57%   19.83%   +0.25%     
==========================================
  Files          81       81              
  Lines        5461     7604    +2143     
==========================================
+ Hits         1069     1508     +439     
- Misses       4170     5870    +1700     
- Partials      222      226       +4     
Flag Coverage Δ
unittests 19.83% <ø> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 81 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -128,7 +132,7 @@ if [ ! -x ${INSTALLBIN}/cni ]; then
fi

echo Building k3s
CGO_ENABLED=1 "${GO}" build -tags "$TAGS" -gcflags="all=${GCFLAGS}" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC" -o bin/k3s ./cmd/server/main.go
CGO_ENABLED=1 "${GO}" build $BLDFLAGS -tags "$TAGS" -gcflags="all=${GCFLAGS}" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC" -o bin/k3s ./cmd/server/main.go
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that I am purposely not enclosing BLDFLAGS with quotes. This prevents empty "" from being added when BLDFLAG is not set, which breaks go build

@dereknola dereknola changed the title [WIP] Add support for -cover + integration test code coverage Add support for -cover + integration test code coverage May 5, 2023
pkg/server/server.go Outdated Show resolved Hide resolved
@dereknola dereknola merged commit c6dc789 into k3s-io:master May 8, 2023
dereknola added a commit to dereknola/k3s that referenced this pull request May 9, 2023
* Add support for -cover in k3s server
* Update codecov reporting
* Sigterm in StopK3sServer
Signed-off-by: Derek Nola <[email protected]>
@dereknola dereknola deleted the int_coverage branch May 9, 2023 19:49
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.

5 participants