Giter Club home page Giter Club logo

sourcegraph-codecov's Introduction

Codecov Sourcegraph extension

Build Status codecov FOSSA Status

⚠️ Deprecation notice

Sourcegraph extensions have been deprecated with the September 2022 Sourcegraph release. Learn more.

The repo and the docs below are kept to support older Sourcegraph versions.

Description

A Sourcegraph extension for showing code coverage information from Codecov on GitHub, Sourcegraph, and other tools.

🗃️ Source code

➕ Add to Sourcegraph

Features

  • Support for GitHub.com and Sourcegraph.com
  • Line coverage overlays on files (with green/yellow/red background colors)
  • Line branches/hits annotations on files
  • File coverage ratio indicator (Coverage: N%) and toggle button
  • Support for using a Codecov API token to see coverage for private repositories
  • File and directory coverage decorations on Sourcegraph

Usage

On GitHub using the Chrome extension

  1. Install Sourcegraph for Chrome
  2. Enable the Codecov extension on Sourcegraph
  3. Visit tuf_store.go in theupdateframework/notary on GitHub (or any other file in a public repository that has Codecov code coverage)
  4. Click the Coverage: N% button to toggle Codecov test coverage background colors on the file (scroll down if they aren't immediately visible)

Screenshot

With private GitHub.com repositories

You can use the Codecov extension for private repositories on GitHub.com. Your code is never sent to Sourcegraph.

  1. Follow the Codecov extension usage instructions above to install Sourcegraph for Chrome
  2. Go to the command palette on GitHub (added by the Sourcegraph browser extension, see screenshot below) and choose "Codecov: Set API token for private repositories"
  3. Enter your Codecov API token
  4. Visit any file in a GitHub.com private repository that has Codecov coverage data

image

Your code is never sent to Sourcegraph. The Codecov extension runs on the client side in a Web Worker and communicates with Codecov directly to retrieve code coverage data.

With Codecov Enterprise and GitHub Enterprise

You can use this extension to overlay coverage information from your Codecov Enterprise install into GitHub Enterprise.

  1. Follow the Codecov extension usage instructions above to install Sourcegraph for Chrome
  2. From the command palette (added by the Sourcegraph browser extension, see screenshot above) on GitHub Enterprise click, "Codecov: Setup up Codecov Enterprise"
  3. From the pop up that appears, set your Version control type to: ghe
  4. From the next pop up that appears, set your Codecov endpoint, this is just the root level of your Codecov Enterprise domain, e.g., https://codecov.mycompany.com.
  5. Go to the command palette on GitHub and choose "Codecov: Set API token for private repositories"
  6. Enter your Codecov Enterprise API token.
  7. Visit any file in your Github Enterprise install with coverage data uploaded to Codecov Enterprise to see coverage data.

Note: Additional documentation, if needed, can be found in Codecov's official documentation.

On Sourcegraph.com

  1. Visit tuf_store.go in theupdateframework/notary on Sourcegraph.com (or any other file that has Codecov code coverage)
  2. Click the Coverage: N% button to toggle Codecov test coverage background colors on the file (sign-in required)

The Codecov extension is enabled by default on Sourcegraph.com, so you don't need to add it from its extension registry listing.

With a self-hosted Sourcegraph instance and the browser extension

File decorations

Enable file decorations in user, organization or global settings to see coverage status of files and directories in the file tree and on directory pages.

{
    "codecov.fileDecorations.show": true
}

File decorations

License

FOSSA Status

sourcegraph-codecov's People

Contributors

3askaal avatar anthonygedeon avatar armenzg avatar chrismwendt avatar dependabot[bot] avatar eliatcodecov avatar eseliger avatar felixfbecker avatar fossabot avatar joelkw avatar lguychard avatar mitchell-codecov avatar ryan-blunden avatar ryankscott avatar snyk-bot avatar sqs avatar taras-yemets avatar thomasrockhu avatar thomasrockhu-codecov avatar tjkandala avatar vovakulikov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sourcegraph-codecov's Issues

"Coverage: X%" button doesn't appear by default

Testing Item: https://sourcegraph-team.monday.com/boards/322741303/pulses/322741437

Local Sourcegraph started through: IMAGE=sourcegraph/server:3.8.0-rc.2 ./dev/run-server-image.sh

While testing for release 3.8, even with setting "codecov.hideCoverageButton": false, explicitly defined, I could not see the "Coverage: X%" button on Sourcegraph (local) or GitHub (with extension), but coverage line highlights are visible.

Screenshot from 2019-09-18 12-39-17

On Sourcegraph, after loading a code page with the coverage line highlights, when I navigate to another page then return to the code, by hitting the browser back button, the button appears. So it seems to only render when the page is re-rendered after navigating away and back (maybe component update issue?). After refreshing the page the highlights appear but the button doesn't.

Screenshot from 2019-09-18 12-50-02

Can't add token for private repos

The only option available in the sourcegraph menu is to go to the codecov documentation. How can I set the token for private repos?

image

Issue with Firefox on private repository

Hi,

I recently decided to setup code-cov on a private repository.

While it seems to work perfectly with Chrome; i tried to setup the extension on Firefox,
but i can't make it work : The highlight does not work, and the coverage button does not appear on github.

Yet, i followed the same step than i did to install the chrome extension.

Here are the Chrome logs (For which it works):

Sourcegraph browser extension is running
Detected code host: github
Browser extension is enabled
Code view added

Activating Sourcegraph extension: sourcegraph/codecov
Activating Sourcegraph extension: sourcegraph/git-extras
Activating Sourcegraph extension: sourcegraph/python

Here are the Firefox logs (For which it does not work):

Sourcegraph browser extension is running
Detected code host: github
Browser extension is enabled
Code view added

Sourcegraph browser extension is running 
Sourcegraph native integration is already running 
Activating Sourcegraph extension: sourcegraph/template

I don't seems to be the only one to meet this problem in my team.
Do you see any reason why it would fail to work ? Is there some additional step to be done concerning firefox ?

Note : the Firefox version i'm using (on mac) is Version 82.0.3

Thanks,

Showing coverage for commits

I just installed the extension and I'm seeing diffs on github working for specific files but not for commits.

For example I don't see coverage showing up mapbox/geometry.hpp@c83a2ab but I do see coverage showing at https://github.com/mapbox/geometry.hpp/blob/c83a2ab18a225254f128b6f5115aa39d04f2de21/include/mapbox/geometry_io.hpp.

I think the commit view is the most valuable place to show coverage. Also the now deprecated https://github.com/codecov/browser-extension used to work this way: it showed coverage for commits.

code cov highlighting requires refresh on github.com

Hey all 👋

Just wanted to flag an issue that has been observed with highlighting when navigating hyper-links on github.com

When navigating through hyperlinks or loading a file page on GitHub.com, during the initial loading of a page no syntax highlighting is observed.
Screen Shot 2022-07-13 at 4 25 38 PM

Additionally, there are errors in the console for Uncaught Error: Could not find repository content element

Reloading the page returns syntax highlighting
Screen Shot 2022-07-13 at 4 25 51 PM

When the highlighting isn't loadin a CSS class .repository-content seems not to be loading in the <turbo-frame> HTML element
Screen Shot 2022-07-14 at 12 34 23 PM

On a page refresh the class seems to load correctly
Screen Shot 2022-07-14 at 12 35 32 PM

It may be the case that Github has started using some new pjax library stuff, and that sourcegraph browser extension doesn't currently have handlers for this?
https://github.com/defunkt/jquery-pjax

Set API token for private repositories reports error when viewing a file page

Specifically, the error message "To set a Codecov API token, navigate to a file and then re-run this command." is displayed (nearly unreadably, I had to highlight text to figure this out) when clicking on the command.

I'm not sure when exactly this happened, but the codecov token I generated hadn't been used since last week (and I wasn't getting coverage overlays), so I removed/readded the sourcegraph extension only to not be able to re-add the token.

While the message suggests that you need to be on a file page, it currently is displaying on all pages for me.

Screen Shot 2020-01-13 at 4 43 55 PM

Happy to provide more details if needed. It's possible this is related to #11, but the symptoms seem sufficiently different.

Doesn't work entirely

I used this neat integration. It recently stopped working. I found sourcegraph/sourcegraph#43802 which confirms that apparently this integration is "no more". Leaving this note so might help to others interested to find why it no longer works.

request: allow customization of line coverage colors ( accessibility )

Currently, the high contrast of the chosen coverage highlight colors can be painful on the eyes, especially if you're using some method of forcing pages into a dark mode. Additionally, the lines can be difficult to tell apart with various types of colorblindness.

The "simplest" method of resolution would be to allow configuration of line highlight colors, such that end-users can set a trio of colors that are more pleasant in contrast of their browsing environment.

Discuss: Behavior for files with no test coverage data

We use Codecov on all of the code in our repository. But some code files have no tests and therefore no test coverage data, and the extension's current behavior can be confusing because a user would probably expect those files to be marked "0% coverage" instead of showing nothing.

For example, https://sourcegraph.com/github.com/sourcegraph/sourcegraph@eda8778b442c5fb25617e07e006516c4d815092a/-/blob/cmd/frontend/auth/providers/providers.go is a file in a Go package that has no test files. There is no "0% coverage" displayed, the file in the sidebar has no file tree decorations with "0%", and the lines have no red background colors to indicate no coverage. This causes a user to think either that the Codecov extension is not working, or perhaps that the file is not missing test coverage ("well, I didn't see any red lines!").

That file's directory is marked as having "0%" coverage in the sidebar:
image

I don't know what the solution is here. Is the problem with how we're sending up test coverage from our repository to Codecov? Can the extension infer that "0% coverage" on the directory means the same for all files? Is this a per-language thing, a Codecov thing, or an extension thing?

(Related: internal Sourcegraph discussion at https://sourcegraph.slack.com/archives/C01CSS3TC75/p1609369144174800?thread_ts=1609367985.172800&cid=C01CSS3TC75.)

Error message when selecting action

Using Sourcegraph.com, when I select the below.

screen shot 2018-09-17 at 1 57 21 pm

Produced the error message.

Request commands/$executeCommand failed with message: Cannot read property 'showInputBox' of undefined.

Type errors on master

On master, yarn run typecheck prints these errors:

> yarn run typecheck
yarn run v1.16.0
$ tsc -p tsconfig.json
src/model.ts:18:9 - error TS2322: Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.

18         baseURL: endpoint.url,
           ~~~~~~~

  src/api.ts:7:5
    7     baseURL: string
          ~~~~~~~
    The expected type comes from property 'baseURL' which is declared here on type 'CodecovGetCommitCoverageArgs'

src/model.ts:31:9 - error TS2322: Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.

31         baseURL: endpoint.url,
           ~~~~~~~

  src/api.ts:7:5
    7     baseURL: string
          ~~~~~~~
    The expected type comes from property 'baseURL' which is declared here on type 'CodecovGetCommitCoverageArgs'

src/model.ts:44:9 - error TS2322: Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.

44         baseURL: endpoint.url,
           ~~~~~~~

  src/api.ts:7:5
    7     baseURL: string
          ~~~~~~~
    The expected type comes from property 'baseURL' which is declared here on type 'CodecovGetCommitCoverageArgs'

src/model.ts:49:39 - error TS2345: Argument of type 'unknown' is not assignable to parameter of type '{ l: { [line: number]: string | number | null | undefined; }; t: { c: string; }; } | undefined'.
  Type 'unknown' is not assignable to type '{ l: { [line: number]: string | number | null | undefined; }; t: { c: string; }; }'.

49         const ratio = toCoverageRatio(fileData)
                                         ~~~~~~~~

src/uri.test.ts:11:50 - error TS2554: Expected 1 arguments, but got 2.

11             assert.throws(() => resolveURI(null, 'file:///d/f')))
                                                    ~~~~~~~~~~~~~

src/uri.test.ts:15:34 - error TS2554: Expected 1 arguments, but got 2.

15                 resolveURI(null, 'git://example.com/repo?v#d/f'),
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/uri.test.ts:27:53 - error TS2554: Expected 1 arguments, but got 2.

27                 resolveURI({ repo: 'r', rev: 'v' }, 'file:///d/f'),
                                                       ~~~~~~~~~~~~~

src/uri.test.ts:39:21 - error TS2554: Expected 1 arguments, but got 2.

39                     'git://example.com/repo?v#d/f'
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/uri.test.ts:52:21 - error TS2554: Expected 1 arguments, but got 2.

52                     'git://example.com/repo2?v2#d/f'
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/uri.test.ts:63:46 - error TS2554: Expected 1 arguments, but got 2.

63         assert.throws(() => resolveURI(null, 'example://a')))
                                                ~~~~~~~~~~~~~

src/uri.ts:41:15 - error TS2322: Type 'readonly Endpoint[] | undefined' is not assignable to type 'Endpoint[] | undefined'.
  The type 'readonly Endpoint[]' is 'readonly' and cannot be assigned to the mutable type 'Endpoint[]'.

41         const endpoints: Endpoint[] | undefined = sourcegraph.configuration.get<Settings>().get('codecov.endpoints')
                 ~~~~~~~~~


Found 11 errors.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@3askaal these seem to have been introduced in #19

Authorization no longer works with Codecov API v2. Migrate to API v2.

The extension does not show commit coverage data anymore.
Commit coverage requests fail with a 401 error:

{"meta": {"status": 401}, "error": {"reason": "Credentials are invalid. Please login again.", "context": null}}

Removing the access_token from the query string helps resolve the request successfully (as it’s the public repo).

The URL we use is different from v1 get single commit URL (commits vs commit). Moreover, the docs page we reference in the code no longer exists. But, the request is still resolved without the access token in it.

Codecov is migrating its API to v2, though they claim that v1 is still maintained (at least for six months). I checked the v2 way to authorize and could successfully get the commit coverage data using this endpoint.

It's likely that to make the extension work again, we need to migrate API to v2.

Plugin does not work for private repository

After following the instructions in the readme for private repos, my console has an Uncaught RepoNotFoundError error when viewing my private repo.

After contacting codecov support, they told me to do the following:

  • navigate to chrome://extensions
  • enable developer mode (top-right corner)
  • Inspect the background page of the sourcegraph extension
  • reload the code page on GitHub page in a browser tab
  • check the chrome dev tools for the extension’s background page
  • In the “Network” tab, the ResolveRev, ResolveRepo steps should return 200

The network tab did not have any activity.

Is there anything else that needs to be done that's not in the readme? For what its worth, I do see a "Configure sourcegraph" button.

Coverage overlay for PRs

Related to #10,
But would be really awesome to have the overlay on the diff overview for PRs.
ie on this page https://github.com/<org>/<repo>/pull/<#pr>/files

The old codecov extension offered this and it was amazing. After submitting a PR, one could see which lines of the code they'd touched were covered.

It was especially nice how it'd continue to use a darker green/red highlighting in the line number gutter to indicate which lines were added/removed, whilst the lighter green/red highlighting across the actual code indicated what lines were covered by tests.

All the best. :)

Doesn't work on Firefox

There is no coverage button/codecov option on Firefox. Seems that codecov extension doesn't load at all. Everything works fine on Chrome.

Firefox Nightly 95.0a1 (2021-10-14) / Sourcegraph v21.9.10.1803
image

Chrome 94.0.4606.81 / Sourcegraph v21.9.10.1802
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.