Adding Codecov

1. Code Changes (done by any developer, merged by someone with repo write access)

The developer should add a covecov.yml file if they have not already, e.g.:

coverage: status: project: default: enabled: yes target: auto patch: default: enabled: yes target: 100% comment: false

Add something like the following to your github actions workflows so you can upload coverage info to CodeCov

- name: Upload coverage to CodeCov if: matrix.python-version == '3.12' && matrix.toxenv == 'django42' uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }}

2. GitHub App settings (done by a GitHub org admin, at Axim for openedx)

Maintainer instructions: File a GitHub Issue (uncategorized) with the tCRIL Engineering team to request Codecov get set up properly. Include “Codecov: reponame” in the ticket title and in the body add a link to your codecov.yml file from master/main.

tCRIL Admin Instructions: Navigate to the Codecov Github App Setting page, and add the GitHub repository in question to the list of repositories near the bottom of the page. Don’t forget to click the “Save” button.

3. Branch protection (done by a GitHub org admin, at Axim for openedx)

If you would like to require Codecov to pass for merges to a protected branch, you will first need a commit to be pushed to a PR against the branch in question after making the changes above. You don't necessarily need to merge this, there just needs to be at least one existing run of the Codecov check against that branch.

You can now make the Codecov check required for merges to that branch: Repo → Settings → Branches → Branch Protection Rules → Edit on the desired branch. For example, https://github.com/openedx/edx-django-utils/settings/branches/master . Then under “Require status checks to pass before merging”, search for and select the Codecov check(s) to be required. Finally, click the “Save Changes” button at the bottom of the page.

4. Add a CodeCov repository secret (done by a GitHub org admin, at Axim for openedx)

  1. In a private browsing window, login to github as the openedx-codecov user.

  2. Then login to codecov.io via this github user.

  3. Go to the settings page for the relevant repository in the private browsing window:

    • https://app.codecov.io/gh/openedx/<repo_name>/settings

  4. Copy the repository upload token.

  5. As an admin user, go to the repository secrets section of the repo:

    • https://github.com/openedx/<repo_name>/settings/secrets/actions

  6. Add the token as a new secret named CODECOV_TOKEN