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

Upload test coverage to Codecov #1671

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[run]
# Relative is needed for coverage to be merged by SonarCloud
relative_files = True
branch = True
omit =
src/rez/tests/*,
src/rez/completion/*,
src/rez/vendor/*
src/rez/vendor/*
10 changes: 9 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ jobs:
run: rez-python -m pip install pytest-cov parameterized

- name: Run tests
run: rez-selftest -v
run: rez-selftest -v -- --cov=rez --cov-report=xml:coverage.xml
env:
_REZ_ENSURE_TEST_SHELLS: ${{ matrix.shells }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
slug: AcademySoftwareFoundation/rez
files: 'coverage.xml'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ build/
dist/
htmlcov/
.coverage
coverage.xml
*~
docs/_build
.DS_Store
Expand Down
3 changes: 1 addition & 2 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ sonar.projectName=rez

# Source properties
sonar.sources=src
sonar.exclusions=src/build_utils/**,src/rez/backport/**,src/rez/data/**,src/rez/tests/**,src/rez/vendor/**

sonar.exclusions=src/build_utils/**,src/rez/data/**,src/rez/tests/**,src/rez/vendor/**
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[![Docs](https://readthedocs.org/projects/rez/badge/?version=stable)](https://rez.readthedocs.io/en/stable)
[![PyPI](https://github.com/AcademySoftwareFoundation/rez/workflows/pypi/badge.svg)](https://github.com/AcademySoftwareFoundation/rez/actions?query=workflow%3Apypi+event%3Arelease)
[![Benchmark](https://github.com/AcademySoftwareFoundation/rez/workflows/benchmark/badge.svg)](https://github.com/AcademySoftwareFoundation/rez/actions?query=workflow%3Abenchmark+event%3Arelease)<br>
[![Coverage](https://codecov.io/gh/AcademySoftwareFoundation/rez/graph/badge.svg?token=FLYggQOE7W)](https://codecov.io/gh/AcademySoftwareFoundation/rez)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=AcademySoftwareFoundation_rez&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=AcademySoftwareFoundation_rez)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=AcademySoftwareFoundation_rez&metric=bugs)](https://sonarcloud.io/summary/new_code?id=AcademySoftwareFoundation_rez)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=AcademySoftwareFoundation_rez&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=AcademySoftwareFoundation_rez)
Expand Down
11 changes: 11 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
coverage:
status:
project: off

github_checks:
annotations: false

ignore:
- "src/rez/tests"
- "src/rez/vendor"
- "src/rez/completion"
2 changes: 0 additions & 2 deletions pytest.ini

This file was deleted.

15 changes: 5 additions & 10 deletions src/rez/cli/selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,7 @@ def command(opts, parser, extra_arg_groups=None):

try:
if use_pytest:
cwd = os.getcwd()
os.chdir(tests_dir)
try:
run_pytest(module_tests, opts.tests, opts.verbose,
extra_arg_groups)
finally:
os.chdir(cwd)

run_pytest(module_tests, opts.tests, opts.verbose, extra_arg_groups)
else:
run_unittest(module_tests, opts.tests, opts.verbose)
finally:
Expand All @@ -121,6 +114,8 @@ def run_unittest(module_tests, tests, verbosity):
def run_pytest(module_tests, tests, verbosity, extra_arg_groups):
from pytest import main

tests_dir = os.path.abspath(os.path.join(__file__, "..", "..", "tests"))

# parse test name, e.g.
# "rez.tests.test_solver.TestSolver.test_01"
# into
Expand All @@ -133,11 +128,11 @@ def run_pytest(module_tests, tests, verbosity, extra_arg_groups):
specifier += "::" + part
continue
if os.path.isfile(part + ".py"):
specifier = part + ".py"
specifier = os.path.join(tests_dir, f"{part}.py")
if specifier:
test_specifications.append(specifier)

module_tests = [("test_%s.py" % x) for x in sorted(module_tests)]
module_tests = [os.path.join(tests_dir, f"test_{x}.py") for x in sorted(module_tests)]
tests = module_tests + test_specifications

argv = tests[:]
Expand Down