Full Code of codecov/example-python for AI

main ce0de1ab0751 cached
13 files
7.1 KB
2.4k tokens
9 symbols
1 requests
Download .txt
Repository: codecov/example-python
Branch: main
Commit: ce0de1ab0751
Files: 13
Total size: 7.1 KB

Directory structure:
gitextract_vr0ahjye/

├── .circleci/
│   └── config.yml
├── .github/
│   ├── dependabot.yml
│   └── workflows/
│       ├── ci.yml
│       └── enforce-license-compliance.yml
├── .gitignore
├── LICENSE.md
├── README.md
├── app/
│   ├── __init__.py
│   ├── calculator.py
│   └── test_calculator.py
├── bitrise.yml
├── codecov.yml
└── requirements.txt

================================================
FILE CONTENTS
================================================

================================================
FILE: .circleci/config.yml
================================================
version: 2.1
orbs:
  codecov: codecov/codecov@4

jobs:
  build:
    docker:
      - image: cimg/python:3.10
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: pip install -r requirements.txt
      - run:
          name: Run tests and collect coverage
          command: pytest --cov app
      - codecov/upload

workflow:
  version: 2.1
  build-test:
    jobs:
      - build


================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: pip
  directory: "/"
  schedule:
    interval: daily
  open-pull-requests-limit: 10


================================================
FILE: .github/workflows/ci.yml
================================================
name: Workflow for Codecov example-python
on: [push, pull_request]
jobs:
  run:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up Python 3.10
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - name: Install dependencies
        run: pip install -r requirements.txt
      - name: Run tests and collect coverage
        run: pytest --cov app --junitxml=junit.xml -o junit_family=legacy
      - name: Upload test results to Codecov
        if: ${{ !cancelled() }}
        uses: codecov/test-results-action@v1
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
      - name: Upload coverage to Codecov (arg token)
        uses: codecov/codecov-action@main
        with:
          fail_ci_if_error: true
          token: ${{ secrets.CODECOV_TOKEN }}
          verbose: true
      - name: Upload coverage to Codecov (env token)
        uses: codecov/codecov-action@main
        with:
          fail_ci_if_error: true
          verbose: true
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
      - name: Upload coverage to Codecov (no token)
        uses: codecov/codecov-action@main
        with:
          fail_ci_if_error: true
          verbose: true
      - name: Upload coverage to Codecov (oidc)
        uses: codecov/codecov-action@main
        with:
          fail_ci_if_error: true
          use_oidc: true
          verbose: true


================================================
FILE: .github/workflows/enforce-license-compliance.yml
================================================
name: Enforce License Compliance

on:
  pull_request:
    branches: [main, master]

jobs:
  enforce-license-compliance:
    runs-on: ubuntu-latest
    steps:
      - name: 'Enforce License Compliance'
        uses: getsentry/action-enforce-license-compliance@57ba820387a1a9315a46115ee276b2968da51f3d # main
        with:
          fossa_api_key: ${{ secrets.FOSSA_API_KEY }}


================================================
FILE: .gitignore
================================================
__pycache__/


================================================
FILE: LICENSE.md
================================================
MIT License

Copyright (c) 2022 Codecov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
# [Codecov](https://codecov.io) Python Example
[![codecov](https://codecov.io/github/codecov/example-python/branch/main/graph/badge.svg?token=tkq655ROg3)](https://app.codecov.io/github/codecov/example-python)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-python.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-python?ref=badge_shield)

This example repository shows how Codecov can be integrated with a simple python project. It uses **GitHub Actions** and **CircleCI** as CI/CD providers and **coverage** as the coverage provider.

For more information, please see the links below.

## Links
- [Quick Start](https://docs.codecov.com/docs/quick-start)
- [GitHub Tutorial](https://docs.codecov.com/docs/github-tutorial)
- [Community Boards](https://community.codecov.io)
- [Support](https://codecov.io/support)
- [Documentation](https://docs.codecov.io)


## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-python.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-python?ref=badge_large)


================================================
FILE: app/__init__.py
================================================


================================================
FILE: app/calculator.py
================================================
class Calculator:

    def add(x, y):
        return x + y

    def subtract(x, y):
        return x - y

    def multiply(x, y):
        return x * y

    def divide(x, y):
        if y == 0:
            return 'Cannot divide by 0'
        return x * 1.0 / y



================================================
FILE: app/test_calculator.py
================================================
from .calculator import Calculator


def test_add():
    assert Calculator.add(1, 2) == 3.0
    assert Calculator.add(1.0, 2.0) == 3.0
    assert Calculator.add(0, 2.0) == 2.0
    assert Calculator.add(2.0, 0) == 2.0
    assert Calculator.add(-4, 2.0) == -2.0

def test_subtract():
    assert Calculator.subtract(1, 2) == -1.0
    assert Calculator.subtract(2, 1) == 1.0
    assert Calculator.subtract(1.0, 2.0) == -1.0
    assert Calculator.subtract(0, 2.0) == -2.0
    assert Calculator.subtract(2.0, 0.0) == 2.0
    assert Calculator.subtract(-4, 2.0) == -6.0

def test_multiply():
    assert Calculator.multiply(1, 2) == 2.0
    assert Calculator.multiply(1.0, 2.0) == 2.0
    assert Calculator.multiply(0, 2.0) == 0.0
    assert Calculator.multiply(2.0, 0.0) == 0.0
    assert Calculator.multiply(-4, 2.0) == -8.0

def test_divide():
    # assert Calculator.divide(1, 2) == 0.5
    assert Calculator.divide(1.0, 2.0) == 0.5
    assert Calculator.divide(0, 2.0) == 0
    assert Calculator.divide(-4, 2.0) == -2.0
    # assert Calculator.divide(2.0, 0.0) == 'Cannot divide by 0'


================================================
FILE: bitrise.yml
================================================
format_version: "13"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other
workflows:
  primary:
    steps:
    - activate-ssh-key@4:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@8: {}
    - script@1:
        inputs:
        - script_file_path: null
        - content: |
            #!/usr/bin/env bash
            set -e
            set -o pipefail
            set -x # debug log

            pip3 install -r requirements.txt
            pytest --cov app
    - codecov@3:
        inputs:
        - OS: macos
        - CODECOV_TOKEN: $CODECOV_TOKEN
    - deploy-to-bitrise-io@2: {}
meta:
  bitrise.io:
    stack: osx-xcode-14.3.x-ventura
    machine_type_id: g2-m1.4core
trigger_map:
- push_branch: main
  workflow: primary
- pull_request_source_branch: '*'
  workflow: primary


================================================
FILE: codecov.yml
================================================
flag_management:
  individual_flags:
    - name: smart-tests
      carryforward: true
      carryforward_mode: "labels"
      statuses:
        - type: "project"
        - type: "patch"

cli:
  plugins:
    pycoverage:
      report_type: "json"


================================================
FILE: requirements.txt
================================================
attrs==25.4.0
coverage==7.12.0
iniconfig==2.3.0
packaging==25.0
pluggy==1.6.0
py==1.11.0
pyparsing==3.2.5
pytest==9.0.1
pytest-cov==7.0.0
tomli==2.3.0
Download .txt
gitextract_vr0ahjye/

├── .circleci/
│   └── config.yml
├── .github/
│   ├── dependabot.yml
│   └── workflows/
│       ├── ci.yml
│       └── enforce-license-compliance.yml
├── .gitignore
├── LICENSE.md
├── README.md
├── app/
│   ├── __init__.py
│   ├── calculator.py
│   └── test_calculator.py
├── bitrise.yml
├── codecov.yml
└── requirements.txt
Download .txt
SYMBOL INDEX (9 symbols across 2 files)

FILE: app/calculator.py
  class Calculator (line 1) | class Calculator:
    method add (line 3) | def add(x, y):
    method subtract (line 6) | def subtract(x, y):
    method multiply (line 9) | def multiply(x, y):
    method divide (line 12) | def divide(x, y):

FILE: app/test_calculator.py
  function test_add (line 4) | def test_add():
  function test_subtract (line 11) | def test_subtract():
  function test_multiply (line 19) | def test_multiply():
  function test_divide (line 26) | def test_divide():
Condensed preview — 13 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (8K chars).
[
  {
    "path": ".circleci/config.yml",
    "chars": 420,
    "preview": "version: 2.1\norbs:\n  codecov: codecov/codecov@4\n\njobs:\n  build:\n    docker:\n      - image: cimg/python:3.10\n    steps:\n "
  },
  {
    "path": ".github/dependabot.yml",
    "chars": 125,
    "preview": "version: 2\nupdates:\n- package-ecosystem: pip\n  directory: \"/\"\n  schedule:\n    interval: daily\n  open-pull-requests-limit"
  },
  {
    "path": ".github/workflows/ci.yml",
    "chars": 1509,
    "preview": "name: Workflow for Codecov example-python\non: [push, pull_request]\njobs:\n  run:\n    runs-on: ubuntu-latest\n    permissio"
  },
  {
    "path": ".github/workflows/enforce-license-compliance.yml",
    "chars": 375,
    "preview": "name: Enforce License Compliance\n\non:\n  pull_request:\n    branches: [main, master]\n\njobs:\n  enforce-license-compliance:\n"
  },
  {
    "path": ".gitignore",
    "chars": 13,
    "preview": "__pycache__/\n"
  },
  {
    "path": "LICENSE.md",
    "chars": 1064,
    "preview": "MIT License\n\nCopyright (c) 2022 Codecov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof"
  },
  {
    "path": "README.md",
    "chars": 1152,
    "preview": "# [Codecov](https://codecov.io) Python Example\n[![codecov](https://codecov.io/github/codecov/example-python/branch/main/"
  },
  {
    "path": "app/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "app/calculator.py",
    "chars": 261,
    "preview": "class Calculator:\n\n    def add(x, y):\n        return x + y\n\n    def subtract(x, y):\n        return x - y\n\n    def multip"
  },
  {
    "path": "app/test_calculator.py",
    "chars": 1082,
    "preview": "from .calculator import Calculator\n\n\ndef test_add():\n    assert Calculator.add(1, 2) == 3.0\n    assert Calculator.add(1."
  },
  {
    "path": "bitrise.yml",
    "chars": 849,
    "preview": "format_version: \"13\"\ndefault_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git\nproject_type: other\nwork"
  },
  {
    "path": "codecov.yml",
    "chars": 245,
    "preview": "flag_management:\n  individual_flags:\n    - name: smart-tests\n      carryforward: true\n      carryforward_mode: \"labels\"\n"
  },
  {
    "path": "requirements.txt",
    "chars": 151,
    "preview": "attrs==25.4.0\ncoverage==7.12.0\niniconfig==2.3.0\npackaging==25.0\npluggy==1.6.0\npy==1.11.0\npyparsing==3.2.5\npytest==9.0.1\n"
  }
]

About this extraction

This page contains the full source code of the codecov/example-python GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 13 files (7.1 KB), approximately 2.4k tokens, and a symbol index with 9 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!