feedback
feedback copied to clipboard
Weird issue with existing commit hash: Upload failed: ["Commit SHA not found"]
Hello dear all,
Description of problem
I have a weird issue with the GitHub CI run and also with the local run.
I am using the Global repository upload token and exported it as an env variable CODECOV_TOKEN.
The PR comment:
Searching for the recent commit hash and trying to upload it using codecovcli. Local run:
Installed as:
pip install codecov-cli
codecovcli --version
codecovcli, version 0.4.0
Trying to upload:
git rev-parse HEAD
bee8b59399397b0b2501b703851843f05df444f2
codecovcli --codecov-yml-path=./codecov.yml do-upload --file=./coverage.xml --commit-sha=bee8b59399397b0b2501b703851843f05df444f2
info - 2023-10-19 13:12:20,329 -- ci service found: local
warning - 2023-10-19 13:12:20,336 -- xcrun is not installed or can't be found.
warning - 2023-10-19 13:12:20,362 -- No gcov data found.
info - 2023-10-19 13:12:20,362 -- Generating coverage.xml report in /home/shahriyarrzayev/REPOS/others/remove-me
info - 2023-10-19 13:12:20,419 -- Wrote XML report to coverage.xml
info - 2023-10-19 13:12:20,427 -- Found 1 coverage files to upload
info - 2023-10-19 13:12:20,427 -- > /home/shahriyarrzayev/REPOS/others/remove-me/coverage.xml
info - 2023-10-19 13:12:20,688 -- Process Upload complete
error - 2023-10-19 13:12:20,689 -- Upload failed: ["Commit SHA not found"]
Open questions:
- Why did it not find the provided sha/hash?
- Why does it first say process upload complete and then give an error?
Extra information
GitHub CI:
name: Test with Coverage
on:
pull_request:
permissions:
checks: write
pull-requests: write
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
jobs:
test-cov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Run tests and collect coverage
run: pytest --cov --cov-report=xml
- name: Install Codecov
run: curl -Os https://cli.codecov.io/latest/linux/codecov && chmod +x codecov
- name: Upload coverage to Codecov
run: ./codecov --codecov-yml-path=./codecov.yml do-upload --file=./coverage.xml --commit-sha ${{ github.event.pull_request.head.sha }}
codecov.yml:
coverage:
status:
project: default
patch: default
target: 100%
threshold: 98%
warn_threshold: 95%
removed_code_behavior: off
require_ci_to_pass: false
@ShahriyarR that message usually shows up when you push up a new commit and CI is running. It should go away after new overage reports are uploaded in CI.
As for trying to upload, it looks like you didn't run the create-commit and create-report commands for the CLI
@ShahriyarR When running local, can you also pass --git-service github to the upload command? With it being local it doesn't know where to look for the SHA otherwise.
@drazisil-codecov @thomasrockhu-codecov thanks for your reply.
I have changed and used some suggested tips. It seems to be instead of do-upload I had to use upload-process.
Unfortunately in CI it still fails to find the commit hash from PR and then I passed it directly as:
./codecov upload-process --git-service github --file ./coverage.xml --commit-sha ${{ github.event.pull_request.head.sha }}
So the working full solution:
name: Test with Coverage
on:
pull_request:
permissions:
checks: write
pull-requests: write
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
jobs:
test-cov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Run tests and collect coverage
run: pytest --cov --cov-report=xml
- name: Install Codecov
run: curl -Os https://cli.codecov.io/latest/linux/codecov && chmod +x codecov
- name: Upload coverage to Codecov
run: ./codecov upload-process --git-service github --file ./coverage.xml --commit-sha ${{ github.event.pull_request.head.sha }}
@ShahriyarR I'm so sorry, this seems like it got lost in the stack. Are you still running into this issue?
@thomasrockhu-codecov Yeah it happens :) Unfortunately, I can't even recall what was going on here) So closing.