Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codecov is using default branch for coverage and tests reports with workflows on feature branch push event #1732

Open
qiuxiaomu opened this issue Dec 24, 2024 · 3 comments
Assignees
Labels
Low Low Priority Issues (to be fixed or re-evaluated in 12 months support

Comments

@qiuxiaomu
Copy link

I have 2 separate workflow files, one for build and the other one is for tests; once the build on commit parent finished successfully the test workflow will be triggered on the commit parent ( in this case it is a feature branch push).

Checking the checkout step I can confirm github runner pulled the correct feature branch. In the Codecov step though, with verbose turned on I can see the branch was develop.

What is the configuration that I need to let Codecov pick up the commit parent (feature branch) here?

@thomasrockhu-codecov
Copy link
Contributor

@qiuxiaomu can you give more details here? A link to the CI or the output from the Codecov step?

@thomasrockhu-codecov thomasrockhu-codecov self-assigned this Dec 25, 2024
@thomasrockhu-codecov thomasrockhu-codecov added support Low Low Priority Issues (to be fixed or re-evaluated in 12 months labels Dec 25, 2024
@qiuxiaomu
Copy link
Author

qiuxiaomu commented Dec 25, 2024

Sure thing @thomasrockhu-codecov; it is however a private project, so the CI link might not be accessible; but here's the verbose log from codecov, and thanks for taking the time to look into this!

Run codecov/codecov-action@v5
Run CC_ACTION_VERSION=$(cat ${GITHUB_ACTION_PATH}/src/version)
==> Running Action version 5.1.2
Run git config --global --add safe.directory /home/runner/work/demo/demo
Run CC_FORK="false"
Run if [ "false" == 'true' ] && [ "$CC_FORK" != 'true' ];
==> Token set from input
Run if [ -z "$CC_BRANCH" ] && [ -z "$CC_TOKEN" ] && [ "$CC_FORK" == 'true' ]
Run if [ -z "$CC_SHA" ];
Run ${GITHUB_ACTION_PATH}/dist/codecov.sh
     _____          _
    / ____|        | |
   | |     ___   __| | ___  ___ _____   __
   | |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
   | |___| (_) | (_| |  __/ (_| (_) \ V /
    \_____\___/ \__,_|\___|\___\___/ \_/
                            Wrapper-0.0.31
                                  
==> Detected linux
 -> Downloading https://cli.codecov.io/latest/linux/codecov
==> Finishing downloading linux:latest
      Version: v9.1.1
 
gpg: directory '/home/runner/.gnupg' created
gpg: keybox '/home/runner/.gnupg/pubring.kbx' created
gpg: /home/runner/.gnupg/trustdb.gpg: trustdb created
gpg: key 806BB28AED779869: public key "Codecov Uploader (Codecov Uploader Verification Key) <security@codecov.io>" imported
gpg: Total number processed: 1
gpg:               imported: 1
==> Verifying GPG signature integrity
 -> Downloading https://cli.codecov.io/latest/linux/codecov.SHA256SUM
 -> Downloading https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig
 
gpg: Signature made Sat Dec  7 16:07:53 20[24](https://github.com/qiuxiaomu/demo/actions/runs/12476145973/job/34820542326#step:7:25) UTC
gpg:                using RSA key 27034E7FDB850E0BBC2C62FF806BB28AED779869
gpg: Good signature from "Codecov Uploader (Codecov Uploader Verification Key) <security@codecov.io>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 2703 4E7F DB85 0E0B BC2C  62FF 806B B28A ED77 9869
codecov: OK
==> CLI integrity verified

 -> Token of length 36 detected
==> Running upload-coverage
      ./codecov --verbose upload-coverage -t <redacted> --git-service github --gcov-executable gcov
info - 2024-12-24 02:56:33,008 -- ci service found: github-actions
debug - 2024-12-24 02:56:33,010 -- versioning system found: <class 'codecov_cli.helpers.versioning_systems.GitVersioningSystem'>
debug - 2024-12-24 02:56:33,012 -- versioning system found: <class 'codecov_cli.helpers.versioning_systems.GitVersioningSystem'>
warning - 2024-12-24 02:56:33,014 -- No config file could be found. Ignoring config.
debug - 2024-12-24 02:56:33,014 -- No codecov_yaml found
debug - 2024-12-24 02:56:33,016 -- Starting upload coverage --- {"verbose": true, "auto_load_params_from": null, "codecov_yml_path": null, "enterprise_url": null, "version": "cli-9.1.1", "command": "upload-coverage", "git_service": "github", "gcov_executable": "gcov", "commit_sha": "f[35](https://github.com/qiuxiaomu/demo/actions/runs/12476145973/job/34820542326#step:7:37)20576f3293ffe4826aa0fc4ae07a8659dcfe6", "fail_on_error": false, "slug": "qiuxiaomu/demo", "report_code": "default", "network_root_folder": "/home/runner/work/demo/demo", "files_search_root_folder": "/home/runner/work/demo/demo", "files_search_exclude_folders": [], "files_search_explicitly_listed_files": [], "disable_search": false, "disable_file_fixes": false, "build_code": "12476145973", "build_url": "https://github.com/qiuxiaomu/demo/actions/runs/12476145973", "job_code": "Demo Unit Tests", "name": "12476145973", "branch": "develop", "pull_request_number": null, "env_vars": {}, "flags": [], "plugin_names": ["xcode", "gcov", "pycoverage"], "dry_run": false, "use_legacy_uploader": false, "handle_no_reports_found": false, "report_type": "coverage", "network_filter": null, "network_prefix": null, "gcov_args": null, "gcov_ignore": null, "gcov_include": null, "swift_project": null, "parent_sha": null}
debug - 2024-12-24 02:56:33,017 -- Selected preparation plugins --- {"selected_plugins": ["<class 'codecov_cli.plugins.xcode.XcodePlugin'>", "<class 'codecov_cli.plugins.gcov.GcovPlugin'>", "<class 'codecov_cli.plugins.pycoverage.Pycoverage'>"], "cli_config": {}}
debug - 2024-12-24 02:56:33,017 -- Running preparation plugin: <class 'codecov_cli.plugins.xcode.XcodePlugin'>
debug - 2024-12-24 02:56:33,017 -- Running xcode plugin...
warning - 2024-12-24 02:56:33,017 -- xcrun is not installed or can't be found.
debug - 2024-12-24 02:56:33,017 -- Running preparation plugin: <class 'codecov_cli.plugins.gcov.GcovPlugin'>
debug - 2024-12-24 02:56:33,017 -- Running gcov plugin...
warning - 2024-12-24 02:56:33,032 -- No gcov data found.
debug - 2024-12-24 02:56:33,032 -- Running preparation plugin: <class 'codecov_cli.plugins.pycoverage.Pycoverage'>
warning - 2024-12-24 02:56:33,032 -- coverage.py is not installed or can't be found.
debug - 2024-12-24 02:56:33,032 -- Collecting relevant files
info - 2024-12-24 02:56:33,065 -- Found 1 coverage files to report
info - 2024-12-24 02:56:33,065 -- > /home/runner/work/demo/demo/coverage.xml
debug - 2024-12-24 02:56:33,067 -- Selected uploader to use: <class 'codecov_cli.services.upload.upload_sender.UploadSender'>
debug - 2024-12-24 02:56:33,071 -- Sending upload request to Codecov
info - 2024-12-24 02:56:33,656 -- Your upload is now processing. When finished, results will be available at: https://app.codecov.io/github/qiuxiaomu/demo/commit/f3520576f3293ffe4826aa0fc4ae07a8659dcfe6
debug - 2024-12-24 02:56:33,656 -- Upload request to Codecov complete. --- {"response": {"raw_upload_location": "https://storage.googleapis.com/codecov-production/shelter/github/qiuxiaomu%3A%3A%3A%3Ademo/f3520576f3293ffe4826aa0fc4ae07a8659dcfe6/7c67492f-42a6-4fb1-b9fe-0245e5fe2e6d.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EJWQHUGIBILH4J7Q6ZUSCIFNEOLYSNDS7L3B4N5SIBQ2J4YLYE5CRFCD%2F20241224%2Fus%2Fs3%2Faws4_request&X-Amz-Date=20241224T025633Z&X-Amz-Expires=30&X-Amz-SignedHeaders=host&X-Amz-Signature=d965d4aa3b9a80c91f2419b322960f3d7e0c07fdb0dab791ffd61[46](https://github.com/qiuxiaomu/demo/actions/runs/12476145973/job/34820542326#step:7:49)ffe72b5bb", "url": "https://app.codecov.io/github/qiuxiaomu/demo/commit/f3520576f3293ffe4826aa0fc4ae07a8[65](https://github.com/qiuxiaomu/demo/actions/runs/12476145973/job/34820542326#step:7:69)9dcfe6"}}
debug - 2024-12-24 02:56:33,656 -- Sending upload to storage
info - 2024-12-24 02:56:33,743 -- Process Upload complete
debug - 2024-12-24 02:56:33,743 -- Upload result --- {"result": "RequestResult(error=None, warnings=[], status_code=200, text='')"}

Here's the yml for my test workflow:

name: Demo Unit Tests

on:
  workflow_run:
    workflows: [Demo Build]
    types:
      - completed

jobs:
  unit-test:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 2

    steps:
    - name: Check out repo
      uses: actions/checkout@v4
      with:
        ref: ${{ github.event.workflow_run.head_branch }}
    - name: Set up Python 3.12
      uses: actions/setup-python@v5
      with:
        python-version: '3.12'
    - name: Set up ta-lib
      run: |
        export DEBIAN_FRONTEND=noninteractive
        wget https://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
        tar -xzf ta-lib-0.4.0-src.tar.gz
        cd ta-lib/
        sudo ./configure --prefix=/usr
        sudo make
        sudo make install
        cd -
    - name: Set up Poetry
      run: |
        python -m pip install --upgrade pip
        pip install poetry
        poetry install --no-root
    - name: Test with pytest
      run: poetry run pytest --cov --cov-report=xml --junitxml=unit_test_report.xml tests -o junit_family=legacy
    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v5
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        verbose: true
    - name: Upload test results to Codecov
      if: ${{ !cancelled() }}
      uses: codecov/test-results-action@v1
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        verbose: true
        flags: py312
        name: demo-py312

here's the build workflow:

name: Demo Build

on:
  push:
    branches: ["*"]
  pull_request:
    branches: ["develop"]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false

    steps:
    - name: Check out repo
      uses: actions/checkout@v4
    - name: Set up Python 3.12
      uses: actions/setup-python@v5
      with:
        python-version: '3.12'
    - name: Set up ta-lib
      run: |
        export DEBIAN_FRONTEND=noninteractive
        wget https://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
        tar -xzf ta-lib-0.4.0-src.tar.gz
        cd ta-lib/
        sudo ./configure --prefix=/usr 
        sudo make
        sudo make install
        cd -
    - name: Set up Poetry
      run: |
        python -m pip install --upgrade pip
        pip install poetry
        poetry install --no-root
    - name: Build with Poetry
      run: |
        poetry build
        rm -rf dist
    - name: Lint with Ruff
      uses: astral-sh/ruff-action@v2
      with:
        args: 'check --select E9 --select F63 --select F7 --select F82'

@qiuxiaomu
Copy link
Author

It seems that Codecov did pick up the changes made on the commit parent as the coverage percentage got updated along with test reports; it's just the branch was still showing develop, the commit parent wasn't even in the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Low Low Priority Issues (to be fixed or re-evaluated in 12 months support
Projects
None yet
Development

No branches or pull requests

2 participants