27

I am trying to use coveralls.io to show a coverage badge for my tests, but the coverage badge is stuck on "unknown".

The relevant repo is here: https://github.com/cfogelberg/grunt-set-app-mode

When I look at coveralls.io for that repo I see the same "coverage: unknown" status: coveralls.io/r/cfogelberg/grunt-set-app-mode

However, the individual builds are being correctly sent to coveralls.io: https://coveralls.io/builds/788669

What am I missing?

5
  • I am in fact having trouble even finding documentation on how to add the coveralls badge. Could you shed some insights for that?
    – d3ming
    Commented Oct 8, 2015 at 17:24
  • 1
    Hey @dming, this should prob be a separate question but in brief: I haven't been able to find good coveralls documentation but the URL for your coveralls badge will be coveralls.io/repos/<coveralls-user-name>/…. You can check it in your browser.
    – cfogelberg
    Commented Oct 10, 2015 at 13:20
  • Yeah I was able to figure it out from inspecting other project's README files as well, but so odd it's not documented anywhere. Anyway, I think my issue might be different from yours as my repo is private and the issue for me appears to be that GitHub cannot render the image without authenticating with coveralls.io. Posted a separate question here: stackoverflow.com/questions/33133006/…
    – d3ming
    Commented Oct 14, 2015 at 18:35
  • Have the same issue with my project. But the "fun" part, is it's not only me. It also happens for my friends who try's to check it out.
    – Kiksen
    Commented Oct 26, 2016 at 20:22
  • 1
    This might not be an answer to this question but might help someone else. I just noticed that github does some caching on those images to. When rendering README.rst, it changes the image URL to https://camo.githubusercontent.com/ followed by a humongous number of characters.
    – Jérôme
    Commented Sep 26, 2017 at 16:52

10 Answers 10

24

If clearing your local cache isn't fixing the image, the problem is likely that it was cached by Github as a part of their image URL anonymization process.

You can force Github to clear their cache of the image with the following curl command. Change the example URL to the one from the your repo, it will always be https://camo.githubusercontent.com/ followed by a long hash.

curl -X PURGE https://camo.githubusercontent.com/4d04abe0044d94fefcf9af2133223....

Source: GitHub Help: About anonymized image URLs

3
  • That returns a forbidden page Commented Dec 29, 2020 at 15:18
  • 3
    This worked for me, December 2022.
    – DannyB
    Commented Dec 24, 2022 at 20:15
  • I was wondering why my NPM Version Badge wasn't updating and was inspecting the HTML element and saw that the img src was at camo.githubusercontent.com and guessed it was some sort of proxy-cache, so like a server-side cache that can't be resolved client-side. I had no issues running the curl -X PURGE on the src URL, getting a successful response: { "status": "ok", "id": "4120-1688343712-210422" } Then I did a hard refresh in my browser (Firefox, Ctrl+F5) and could then see the up-to-date badge image. Commented Jul 14, 2023 at 16:12
9

What am I missing?

It's possible that your browser cached the image. I realized this was happening to me recently. I couldn't understand why my badge said one thing on my github page, but something different on the badge's website.

Now I tend to check websites in a Chrome incognito window so I don't have the cache to worry about.

1
  • 2
    This was true in my case. I simply press the SHIFT key while reloading and the badge was updated.
    – tutug
    Commented Jan 19, 2021 at 3:58
6

In my case, I had the code coverage outdated in my coveralls badge with this Markdown snippet:

[![Coverage Status](https://coveralls.io/repos/github/user-repo/user-project/badge.svg?branch=master)](https://coveralls.io/github/user-repo/user-project?branch=master)

But when I removed the branch parameter of the first URL, the coverage gets updated!

[![Coverage Status](https://coveralls.io/repos/github/user-repo/user-project/badge.svg)](https://coveralls.io/github/user-repo/user-project?branch=master)

Update:

My first solution didn't work the second time though. So I reverted it, and resorted to changing the badge type from SVG to PNG.

[![Coverage Status](https://coveralls.io/repos/github/user-repo/user-project/badge.png?branch=master)](https://coveralls.io/github/user-repo/user-project?branch=master)
0
4

Since posting this question I have pushed more commits and rerun the coveralls task a number of times and the coverage badge now works:

https://github.com/cfogelberg/grunt-set-app-mode/compare/4FB59ACC...58E23E5373

It is not clear why it works now and didn't earlier. coveralls has been added to the default task since the previous failed build on coveralls. However, it was added to the default task and pushed to Github earlier than the next build on coveralls, which only changes the README.md file (fixing a link to a david-dm.org badge).

I'm afraid this isn't really a "solution" as such and I would still love to know (not sure why/who voted the question down), but in any case I hope this information is useful to someone else in the future.

1
3

Your browser cached the badge image. To force an update, hold SHIFT while reloading your browser tab (on Brave on macOS, I do this via CMD + R).

1
  • 1
    This did it for me
    – StatsNoob
    Commented Sep 9, 2021 at 4:50
2

I've come arround this issue adding a PURGE request to purge GitHub's cached copy of the badge at the end of a my github actions workflow:

$ curl -X PURGE https://camo.githubusercontent.com/4d04abe0044d94fefcf9af2133223....

i 've used the http-request-action :

- name: refresh coverage badge
      uses: fjogeleit/http-request-action@master
      with:
        url: https://camo.githubusercontent.com/12c4fcb3b21fbb2a725fc61449fb1b91e972c4c8a2baaf5904936d8e334bdbe8/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f62336230302f63736c792f62616467652e7376673f6272616e63683d64657626736572766963653d676974687562
        method: PURGE
2

For me the problem was that the image was cached by github, not my own browser. There is a fix documented here that worked:

I added 'kill_cache=1' in the image url

ex: src="https://coveralls.io/repos/github/spread-the-code/git-commiter-nodejs/badge.svg?branch=master&kill_cache=1" />

https://github.com/lemurheavy/coveralls-public/issues/1065

1

Add a queryString param to the badge image URL, Here is the answer https://github.com/lemurheavy/coveralls-public/issues/1065#issuecomment-435494495

0

I have tried other proposals here, and none of them seems to work.

Install disable Cookies chrome extension from here.

Go to your github project, press disable cookies, and then restore them back.

coveralls.io badge should be updated after that.

Suspect same problem is applicable also to normal users as well.

In my case image failed to refresh no manner how many times I've pressed reload, used purge or so other tricks (did not want to clear history).

Also anonymous web browsing sometimes helps.

Please note that coveralls.io report takes time to be processed, so need to wait couple of minutes at least. (Can be checked from coveralls.io site).

0

@iamdefinitelyahuman Answer helped me, but I would like to add some more things that weren't clear to me.

I had the same issue. My coveralls status badge was showing an old coverage percentage. The reason was that the badge was cached by GitHub so I had to clean it using a curl command.

In the beginning, I didn't realize where to get the URL "https://camo.githubusercontent.com/...". After some time I understood that it is the badge image path that can be taken by inspecting the image element.

Then I opened Powershell which was a mistake and run the command: curl -X PURGE https://camo.githubusercontent.com/a4550375d0d4b6f1b363909b2aeeb2827303e07388abe00c0662700f1514fef5/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4d69636861656c5a61736c6176736b792f736f6369616c2d6576656e742d6d616e616765722f62616467652e737667.

And I got this error: enter image description here

Then I tried to run this command in CMD and it worked properly. { "status": "ok", "id": "10525-1659579296-180434" }.

Then I still didn't see it on my browser as it was my browser cache issue. I knew it is a browser cache as I could see the new coverage percentage in Incognito.

Lastly, I cleaned the cache of my browser by opening the developer's tools (F12) => Right-click on the refresh button => Empty Cache and Hard Reload. And, that I could see the percentage updated in my browser as well.

Not the answer you're looking for? Browse other questions tagged or ask your own question.