Movatterモバイル変換


[0]ホーム

URL:


Create a new branchstep2

git checkout maingit pullgit checkout -b 'step2'

Before we continue, let’s create an account and set up our repository onCodecov.

Create a Codecov account

Create an account on Codecov by clicking on oursignup page and following the prompts.

Set up theTeam Bot. If you are using your personal account, you can create acodecov.yml file in the root directory.

codecov:  bot: {{ YOUR_USERNAME }}  # e.g. bot: thomasrockhu-codecovignore:  - "api/app.py"

Now that we have set up our Codecov account, let’s upload coverage reports.

Create CI pipeline

Create a configuration file for your CI. The CI workflows below will checkout the code, install requirements, run tests, and upload the coverage reports to Codecov.

Bitbucket Pipelines

You'll need to adda Codecov upload token as an environment variable in BitBucket. You can find one in the Configuration tab for your repository in the Codecov UI, under General.

First, enable Bitbucket Pipelines for this repository by going toRepository Settings ->Settings (under Pipelines). ClickEnable Pipelines.

Next, add the Codecov token underRepository Settings ->Repository Variables(under Pipelines). Under name, enterCODECOV_TOKEN. Copy the token from above as the value.

pipelines:  default:    - step:        image: python:3.10.4        name: api        script:          - pip install -r api/requirements.txt          - pytest --cov api/          - curl -Os https://cli.codecov.io/latest/linux/codecov          - chmod +x codecov          - ./codecov upload-process -t $CODECOV_TOKEN

Commit the changes and run the CI workflow

Let’s commit our code and open a pull request. Run

git add .git commit -m 'step2: upload coverage reports to Codecov'git push origin step2

Next, go to the demo repository on Bitbucket and open a pull request (PR).

When opening pull requests, be sure to select your own repository as the base branch.

You will see status checks on the PR from the CI. You can click on them to see the progress of the CI/CD. Once complete, you will receive status checks and a comment from Codecov.

codecov/patch andcodecov/project status checks

One of Codecov’s core uses is getting code coverage information directly in a developer’s workflow. The status checks shown above are part of that.

  • Theproject check is used to maintain a coverage percentage across an entire codebase
  • Thepatch check is used for code changed in a PR.

A more mature repository may have a strictproject percentage, while a project new to code coverage may only expect new code to be well-tested (patch coverage). We will be setting some of these values in this section, but you can read more about status checkshere.

If you go to the project on Codecov, you will notice that the dashboard is blank. This is because no coverage information has been uploaded onto the default branch. We can fix this by merging the pull request.

Merge the pull request on Bitbucket and wait for the CI/CD to complete.
When opening pull requests, be sure to select your own repository as the base branch.

Updated 10 months ago



[8]ページ先頭

©2009-2025 Movatter.jp