Skip to content

add code coverage with codecov#38

Closed
pmuellr wants to merge 1 commit intovercel:masterfrom
pmuellr:pmuellr-37-code-coverage
Closed

add code coverage with codecov#38
pmuellr wants to merge 1 commit intovercel:masterfrom
pmuellr:pmuellr-37-code-coverage

Conversation

@pmuellr
Copy link

@pmuellr pmuellr commented Feb 20, 2019

fixes #37

I had some difficulties getting codecov to work with the existing
circleci config. Wasn't really sure why a Docker build was being
done, didn't seem to need to be. And ... a Docker image was being
built but not actually run? Not sure what was going on there.

So, I copied from the following circleci config instead:

To enable the codecov bits to work:

  • the GH repo will need to be set up in codecov.io
  • this will create a token to be used when uploading the codecov file(s)
  • that token should be added as an env var in circleci named CODECOV_TOKEN
  • voilà, should work

fixes vercel#37

I had some difficulties getting codecov to work with the existing
circleci config.  Wasn't really sure why a Docker build was being
done, didn't seem to need to be.  And ... a Docker image was being
built but not actually run?  Not sure what was going on there.

So, I copied from the following circleci config instead:

- https://github.com/zeit/dns-cached-resolve/blob/master/.circleci/config.yml

To enable the codecov bits to work:

- the GH repo will need to be set up in codecov.io
- this will create a token to be used when uploading the codecov file(s)
- that token should be added as an env var in circleci named CODECOV_TOKEN
- voilà, should work
@Qix-
Copy link
Contributor

Qix- commented Feb 20, 2019

Tests in docker provide a way to test locally and remotely in an environment that is more or less deterministic. The format of a Dockerfile is easily learned and quite ubiquitous and cuts out guesswork for making sure dependencies are installed correctly.

This was intentional. Please don't remove it.

@pmuellr
Copy link
Author

pmuellr commented Feb 20, 2019

Ah, I see - an interesting little hack to get a stable env to run tests against. I don't think I've ever seen usage of docker build purely for the side effects of the RUN commands! :-)

A few problems though, getting codecov integrated with this:

  • codecov needs the output of the jest coverage to upload to their service
  • it also wants git info
  • other little things like getting the CODECOV_TOKEN env passed in

It was getting ugly as I was getting closer to making this work with the existing structure, and so decided to look at how other folks were using circleci.

It doesn't seem like there's going to be much different - deterministically - between the Dockerfile and what's going on in circleci with the new config. Or maybe I'm missing something. So, I'm curious if you want the Dockerfile just for ad-hoc testing, or whether you think it really needs to be part of the circleci build/test.

If just for ad-hoc testing, it should probably be moved out of the .circleci dir, and probably add an npm script for the docker build command.

@Qix-
Copy link
Contributor

Qix- commented Feb 21, 2019

codecov needs the output of the jest coverage to upload to their service

Install codecov's reporter from inside the docker image, of course

it also wants git info

Then remove .git from the .dockerignore and make sure it's COPY'd.

other little things like getting the CODECOV_TOKEN env passed in

In the config yaml file:

docker build -e CODECOV_TOKEN="${CODECOV_TODEN}" .

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.

Add code coverage analysis + badge

3 participants