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 coverage data to codecov #464

Closed
justinvp opened this issue Jul 24, 2023 · 2 comments · Fixed by #469
Closed

Add coverage data to codecov #464

justinvp opened this issue Jul 24, 2023 · 2 comments · Fixed by #469
Assignees
Labels
kind/engineering Work that is not visible to an external user resolution/fixed This issue was fixed

Comments

@justinvp
Copy link
Member

No description provided.

@justinvp justinvp added the kind/engineering Work that is not visible to an external user label Jul 24, 2023
@justinvp justinvp added this to the 0.92 milestone Aug 1, 2023
@justinvp justinvp self-assigned this Aug 1, 2023
@abhinav abhinav assigned abhinav and unassigned justinvp Aug 1, 2023
abhinav added a commit that referenced this issue Aug 1, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 1, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 1, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 1, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 1, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 1, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 1, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 1, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 2, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 2, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 7, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 8, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 8, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 8, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 9, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
@abhinav
Copy link
Contributor

abhinav commented Aug 9, 2023

Status update:

#469 works fine for unit test coverage tracking—that's the straightforward bit.
However, it does not currently work for integration test coverage tracking.
The reason for this is that go test does not allow using GOCOVERDIR (for integration tests) and -coverprofile (for unit tests) at the same time. It specifically overrides GOCOVERDIR:

https://github.com/golang/go/blob/c19c4c566c63818dfd059b352e52c4710eecf14d/src/cmd/go/internal/test/test.go#L1337-L1341

So if there's a mix of unit and integration tests in the same directory, and we run the following:

GOCOVERDIR=$(pwd)/coverage go test -coverprofile foo.out

The value of GOCOVERDIR will not be propagated to the coverage-instrumented binary that we're trying to get integration testing coverage information out of.

From the original proposal for this feature, this is a known limitation that is intended to be addressed in a follow up. Per this comment, a workaround for this is to build the test binary without running the tests (go test -c), and then call it with the undocumented -test.gocoverdir flag.

# Build the test binary with coverage instrumentation:
go test -coverpkg=example.com/foo/... -c -o ./test

# Run the test binary with GOCOVERDIR set for integration test coverage
# and the -test.gocoverdir flag set for unit test coverage.
GOCOVERDIR=$(pwd)/coverage ./test -test.gocoverdir=$(pwd)/coverage

This works, but it has to be done on a per-package basis so some tooling is necessary to build and run the test binaries for each test.

I prototyped such a tool and it appears to do the job, but I'm not certain that this is a good idea long-term. It's a couple hundred lines of code built on an unsupported, undocumented workaround.

On top of that, the pulumi-language-yaml binary in particular seems to do some kind of unclean exit which leaves without writing coverage data, so even if GOCOVERDIR is propagated all the way to it, it doesn't report anything yet except 0%. I'm currently debugging that.

@mikhailshilkov mikhailshilkov removed this from the 0.92 milestone Aug 28, 2023
abhinav added a commit that referenced this issue Aug 28, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 28, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
abhinav added a commit that referenced this issue Aug 29, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
@abhinav
Copy link
Contributor

abhinav commented Aug 29, 2023

Update: With the graceful shutdown work that was landed on pu/pu master recently, and the tool I prototyped above, we are able to successfully get reliable coverage data out of the pulumi-language-yaml binary.
The tool will be necessary only until the relevant upstream issue in go test is resolved.

justinvp pushed a commit that referenced this issue Sep 4, 2023
Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464
justinvp pushed a commit that referenced this issue Sep 4, 2023
* ci: Add coverage tracking

Adds a `make test_cover` target to the Makefile
which builds pulumi-language-yaml with coverage instrumentation
and runs all tests with coverage tracking.

Note that right now, there are no tests that invoke pulumi-language-yaml
so integration test data is empty.

For CI, adds an coverage option that, when enabled,
will run `make test_cover` instead of `make test`,
and upload the results to codecov.
This option is only enabled for tests invoked for PRs
and by the `/run-acceptance-tests` command.

Additionally, similarly to pulumi/pulumi#13334,
this adds a workflow that runs tests on master with coverage tracking
every 12 hours.

Resolves #464

* Add gocov tool

Adds an experimental tool that runs `go test -c` and then runs the tests
for each package separately.

This will provide combined coverage data for unit and integration tests.

* gocv: Support test2json

Adds a flag to use test2json to run the test binary,
enabling compatibility with gotestsum.

* gocov: Add -race flag
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/engineering Work that is not visible to an external user resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants