vercel / arg

Simple argument parsing
https://npmjs.com/arg
MIT License
1.23k stars 54 forks source link

add code coverage with codecov #38

Closed pmuellr closed 3 years ago

pmuellr commented 5 years ago

fixes https://github.com/zeit/arg/issues/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:

Qix- commented 5 years ago

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 commented 5 years ago

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:

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- commented 5 years ago

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}" .