Skip to content

Commit

Permalink
SNOW-1438057: Add code coverage to precommit (#1643)
Browse files Browse the repository at this point in the history
Signed-off-by: Naren Krishna <[email protected]>
Co-authored-by: Andong Zhan <[email protected]>
  • Loading branch information
sfc-gh-nkrishna and sfc-gh-azhan authored May 21, 2024
1 parent 0117c7c commit 28cc324
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,64 @@ jobs:
.tox/.coverage
.tox/coverage.xml
combine-coverage:
if: ${{ success() || failure() }}
name: Combine coverage
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Upgrade setuptools and pip
run: python -m pip install -U setuptools pip
- name: Install tox
run: python -m pip install tox
- name: Collect all coverages to one dir
run: |
python -c '
from pathlib import Path
import shutil
src_dir = Path("artifacts")
dst_dir = Path(".") / ".tox"
dst_dir.mkdir()
for src_file in src_dir.glob("*/.coverage"):
dst_file = dst_dir / ".coverage.{}".format(src_file.parent.name[9:])
print("{} copy to {}".format(src_file, dst_file))
shutil.copy(str(src_file), str(dst_file))'
- name: Combine coverages
run: python -m tox -e coverage
- name: Publish html coverage
uses: actions/upload-artifact@v4
with:
name: overall_cov_html
path: .tox/htmlcov
- name: Publish xml coverage
uses: actions/upload-artifact@v4
with:
name: overall_cov_xml
path: .tox/coverage.xml
- uses: codecov/codecov-action@v1
with:
file: .tox/coverage.xml
- name: Show coverage diff
run: |
pip install diff_cover
git log -n 5 --pretty=oneline
git fetch -f origin main:main || true
diff-cover .tox/coverage.xml --compare-branch=main --fail-under=95
doc:
needs: lint
name: Build Doc
Expand Down

0 comments on commit 28cc324

Please sign in to comment.