Skip to content

Enforce 100% test coverage #316

Closed
Closed

Description

@yeraydiazdiaz

As previously commented we should enfoce a 100% test coverage while testing locally and in CI.

Activity

  1. added this to the v1.0 milestone on Sep 15, 2019
  2. removed this from the v1.0 milestone on Dec 3, 2019
  3. lovelydinosaur commented on Dec 3, 2019

    @lovelydinosaur
    Member

    I'm really, really keen on us getting this back.
    Dropping the 1.0 milestone tho, since it's not strictly required for us to get to a point where we consider HTTPX to be API-stable.

  4. yeraydiazdiaz commented on May 13, 2020

    @yeraydiazdiaz
    ContributorAuthor

    I'd like us to revisit this, IMO we should at least aim to have 100% and if in some situations we can't then we mark as nocover and explain why.

    Thoughts?

  5. lovelydinosaur commented on May 13, 2020

    @lovelydinosaur
    Member

    Yup, v keen on this.

  6. yeraydiazdiaz commented on May 15, 2020

    @yeraydiazdiaz
    ContributorAuthor

    In order to get this going I think we should start enforcing the coverage not to drop on each commit.

    I seem to remember we used to have a codecov but I'm not sure when and why we dropped that?

  7. lovelydinosaur commented on May 15, 2020

    @lovelydinosaur
    Member

    I seem to remember we used to have a codecov but I'm not sure when and why we dropped that?

    We used to have 100% enforced, and somewhere way back that seemed to get accidentally dropped.
    After that we didn't have any enforcement, and I probably dropped codecov when switching across to GitHub actions, as a potential "follow up" action, that I didn't want to block us being able to move to GitHub actions.

    I'd probably be quite keen on instead enforcing it ourselves instead. It's not ideal while we're at <100% because we can probably only enforce "this percent and no less", but it does mean that we can make sure that running the tests locally ensure compliance, rather than having to wait for the cycle of "submit PR", "test suite fails", "maintainer points out why", "contributor adds coverage".

    Also it's one less moving part, and I've found codecov to just end up being a bit invasive compared to what I'd like to see.

    Not absolute on this, so could consider it, or could consider having both local compliance plus "send the results to codecov on CI".

  8. yeraydiazdiaz commented on May 15, 2020

    @yeraydiazdiaz
    ContributorAuthor

    I agree it would be best to have it locally.

    I guess it's not too bad to enforce it via pytest-cov's --cov-fail-under=$CURRENT_COV? We could bump the value manually ourselves as the coverage increases. A quick search hasn't yielded any obvious way of doing this automatically.

  9. lovelydinosaur commented on May 15, 2020

    @lovelydinosaur
    Member

    A quick note on how I'd recommend we loop this all in...

    Our GitHub actions have the lint stage nicely separated from the test stage, so we have scripts/lint and scripts/test steps, which helps us see at a glance which of the linting or the tests have failed.

    However we also want to ensure that contributors are having the linting checked when just running scripts/test (It's too easy to forget to check the linting otherwise) so we automatically run the linting from the test script if we're not on GitHub actions...

    scripts/test:

    if [ -z $GITHUB_ACTIONS ]; then
        scripts/check
    fi
    
    ...  # Run tests

    I think we should do the same for coverage enforcement, so that we can have a GitHub actions step that just runs scripts/coverage, help us see when it's the coverage step that's failed.

    Our test script will then look like this...

    if [ -z $GITHUB_ACTIONS ]; then
        scripts/check
    fi
    
    ...  # Run tests, collecting coverage, but not outputting any coverage reports.
    
    if [ -z $GITHUB_ACTIONS ]; then
        scripts/coverage  # Enforce coverage, display a coverage report
    fi
  10. lovelydinosaur commented on May 15, 2020

    @lovelydinosaur
    Member

    At a later point scripts/coverage could also collate results to CodeCov if it's running in CI, but either way we'll have the structure setup the way we want it.

  11. lovelydinosaur commented on Jul 28, 2020

    @lovelydinosaur
    Member

    We're there now, excepting URLLib3Transport, which we'd like to push into a third party repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    toolingChanges to our CI/CD, tests setup, etc.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions