Comments (6)
Hi @twall , @Bachmann1234 ,
I think I hit a similar problem. In my case I'm not using Jenkins but rather Teamcity. Also Teamcity does something like "git checkout -f " at some point and thus clones the git repo in a "HEAD detached" condition (https://www.git-tower.com/learn/git/faq/detached-head-when-checkout-commit/).
I tried and indeed a command like "git diff origin/develop..HEAD" in such condition fails with error
fatal: ambiguous argument 'origin/develop..HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'
I'm not sure how to workaround this... any solution or workaround so far ?
from diff_cover.
I was able to get this to work in GitHub Actions by doing 2 separate checkouts in my workflow (1 for master / main first, then the branch / ref that triggered the workflow, my PR branch in my case):
- name: Check out the repo
uses: actions/checkout@v2
with:
ref: master
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Install diff_cover
run: |
python -m pip install --upgrade pip
pip install diff_cover
- run: diff-cover coverage.xml --compare-branch=origin/master --diff-range-notation '..'
I have added this in case anyone else is trying to get diff_cover working with GitHub Actions
from diff_cover.
Howdy stranger!
I'll see if I can take a look at this. But as I've been saying in other things that have come up my free time has dried up dramatically recently so it may be a bit. We can talk in a less public forum if your curious.
But yeah, I'll try and look this week. No promises though
from diff_cover.
Hey, So the issue title makes me think you read the troubleshooting but I wanted to be extra sure.
When you say 'fetch master did not help' did you specifically make sure to try
git fetch origin master:refs/remotes/origin/master
from the readme?
from diff_cover.
No, I tried the troubleshooting tip, but it didn't work.
An explicit checkout of the target branch (master
) then switching back works, so I'm trying to figure out what happens differently in that case w/r/t symbolic references.
I believe if you do a fresh clone of a repo and snag a hash as described above you can reproduce reliably (don't need jenkins).
from diff_cover.
For what it's worth... This didn't work.
- name: Make ${{ github.base_ref }} branch exist
run: |
git fetch origin master:refs/remotes/origin/master
diff_cover.command_runner.CommandError: fatal: ambiguous argument 'master...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
But this did.
- name: Make ${{ github.base_ref }} branch exist
run: |
git checkout -b ${{ github.base_ref }} --track origin/${{ github.base_ref }}
git checkout -
Though now I'm just passing in the origin/master
or the parent hash depending. (isn't choosing either this or that just silly in GHA...)
- name: Run tox environment
env:
BASE_REF: ${{ fromJSON(format('[{0}, {1}]', toJSON(github.event.before), toJSON(format('origin/{0}', github.base_ref))))[github.base_ref != ''] }}
run: |
tox --skip-pkg-install -- --compare-branch="${BASE_REF}"
[testenv:check-coverage]
changedir = {toxinidir}
commands =
coverage combine coverage_reports/
coverage xml -o {toxinidir}/coverage.xml
coverage report --fail-under=90 --ignore-errors
diff-cover --fail-under=100 {posargs:--compare-branch=master} coverage.xml
from diff_cover.
Related Issues (20)
- Improve error reporting when "git" is not found
- diff-quality plugins should support "--options" and report files HOT 2
- TypeError: diff_cover_report_quality() got an unexpected keyword argument 'reports' HOT 8
- Blank lines not factored into range HOT 2
- Few tests fails in rmtree HOT 6
- 7.3.1: test suite is failing in `tests/test_integration.py::TestDiffQualityIntegration::test_html_with_external_css` unit HOT 2
- Make chardet a optional dependency HOT 1
- In cpp file,The coverage of changed lines is not being counted HOT 2
- any ways to get all measured lines' numbers from json report HOT 2
- Feature request — Invert output to find flaky tests and help determine test failures HOT 1
- does this tool support C++ opencppcoverage? cppcoverage has html, cobertura reports. HOT 1
- urgent!! work environment!!No lines with coverage information in this diff. HOT 2
- new Github action for diff-cover HOT 1
- There is a folder code that cannot be counted. It has been analyzed for a long time, please help HOT 1
- 5 tests fail HOT 2
- Package has classifier "License :: Other/Proprietary License" - raising licensing flags for Sonatype HOT 3
- Enhancing Report Visualization in 'diff-cover' Project for Improved Code Analysis HOT 2
- 7.7.0: pytest is failing in `tests/test_violations_reporter.py::TestFlake8QualityReporterTest::test_file_does_not_exist` unit HOT 33
- Support ruff for quality checking HOT 1
- diff everything on removal HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diff_cover.