Skip to content

Commit

Permalink
Moving .coveragerc info into pyproject.toml (#1692)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Apr 22, 2024
1 parent 08f8c1d commit dbdeb99
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 59 deletions.
35 changes: 0 additions & 35 deletions .coveragerc

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/coverage.yaml
Expand Up @@ -30,10 +30,10 @@ jobs:
pip install -e .[memprof,mpi,test]
- name: Run Coverage
run: |
coverage run --rcfile=.coveragerc -m pytest -n 4 --cov=armi --cov-config=.coveragerc --cov-report=lcov --ignore=venv armi
mpiexec -n 2 --use-hwthread-cpus coverage run --rcfile=.coveragerc -m pytest --cov=armi --cov-config=.coveragerc --cov-report=lcov --cov-append --ignore=venv armi/tests/test_mpiFeatures.py || true
mpiexec -n 2 --use-hwthread-cpus coverage run --rcfile=.coveragerc -m pytest --cov=armi --cov-config=.coveragerc --cov-report=lcov --cov-append --ignore=venv armi/tests/test_mpiParameters.py || true
coverage combine --rcfile=.coveragerc --keep -a
coverage run --rcfile=pyproject.toml -m pytest -n 4 --cov=armi --cov-config=pyproject.toml --cov-report=lcov --ignore=venv armi
mpiexec -n 2 --use-hwthread-cpus coverage run --rcfile=pyproject.toml -m pytest --cov=armi --cov-config=pyproject.toml --cov-report=lcov --cov-append --ignore=venv armi/tests/test_mpiFeatures.py || true
mpiexec -n 2 --use-hwthread-cpus coverage run --rcfile=pyproject.toml -m pytest --cov=armi --cov-config=pyproject.toml --cov-report=lcov --cov-append --ignore=venv armi/tests/test_mpiParameters.py || true
coverage combine --rcfile=pyproject.toml --keep -a
- name: Publish to coveralls.io
uses: coverallsapp/github-action@v1.1.2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unittests.yaml
Expand Up @@ -30,6 +30,6 @@ jobs:
run: |
pip install -e .[memprof,mpi,test]
pytest -n 4 armi
mpiexec -n 2 --use-hwthread-cpus coverage run --rcfile=.coveragerc -m pytest --cov=armi --cov-config=.coveragerc --cov-report=lcov --cov-append --ignore=venv armi/tests/test_mpiFeatures.py || true
mpiexec -n 2 --use-hwthread-cpus coverage run --rcfile=.coveragerc -m pytest --cov=armi --cov-config=.coveragerc --cov-report=lcov --cov-append --ignore=venv armi/tests/test_mpiParameters.py || true
coverage combine --rcfile=.coveragerc --keep -a
mpiexec -n 2 --use-hwthread-cpus coverage run --rcfile=pyproject.toml -m pytest --cov=armi --cov-config=pyproject.toml --cov-report=lcov --cov-append --ignore=venv armi/tests/test_mpiFeatures.py || true
mpiexec -n 2 --use-hwthread-cpus coverage run --rcfile=pyproject.toml -m pytest --cov=armi --cov-config=pyproject.toml --cov-report=lcov --cov-append --ignore=venv armi/tests/test_mpiParameters.py || true
coverage combine --rcfile=pyproject.toml --keep -a
21 changes: 8 additions & 13 deletions armi/cases/case.py
Expand Up @@ -30,10 +30,8 @@
import glob
import os
import pathlib
import platform
import pstats
import re
import shutil
import sys
import textwrap
import time
Expand Down Expand Up @@ -62,8 +60,8 @@
from armi.utils.directoryChangers import DirectoryChanger
from armi.utils.directoryChangers import ForcedCreationDirectoryChanger

# change from default .coverage to help with Windows dotfile issues.
# Must correspond with data_file entry in `coveragerc`!
# Change from default .coverage to help with Windows dotfile issues.
# Must correspond with data_file entry in `pyproject.toml`!
COVERAGE_RESULTS_FILE = "coverage_results.cov"


Expand Down Expand Up @@ -444,6 +442,10 @@ def _getCoverageRcFile(userCovFile, makeCopy=False):
"""Helper to provide the coverage configuration file according to the OS. A
user-supplied file will take precedence, and is not checked for a dot-filename.
Notes
-----
ARMI replaced the ".coveragerc" file has been replaced by "pyproject.toml".
Parameters
----------
userCovFile : str
Expand All @@ -455,21 +457,14 @@ def _getCoverageRcFile(userCovFile, makeCopy=False):
Returns
-------
covFile : str
path of coveragerc file
path of pyprojec.toml file
"""
# User-defined file takes precedence.
if userCovFile:
return os.path.abspath(userCovFile)

covRcDir = os.path.abspath(context.PROJECT_ROOT)
covFile = os.path.join(covRcDir, ".coveragerc")
if platform.system() == "Windows":
covFileWin = os.path.join(covRcDir, "coveragerc")
if makeCopy is True:
# Make a copy of the file without the dot in the name
shutil.copy(covFile, covFileWin)
return covFileWin
return covFile
return os.path.join(covRcDir, "pyproject.toml")

def _startProfiling(self):
"""Helper to the Case.run(): start the Python profiling,
Expand Down
5 changes: 1 addition & 4 deletions armi/cases/tests/test_cases.py
Expand Up @@ -139,10 +139,7 @@ def test_getCoverageRcFile(self):
covRcDir = os.path.abspath(context.PROJECT_ROOT)
# Don't actually copy the file, just check the file paths match
covRcFile = case._getCoverageRcFile(userCovFile="", makeCopy=False)
if platform.system() == "Windows":
self.assertEqual(covRcFile, os.path.join(covRcDir, "coveragerc"))
else:
self.assertEqual(covRcFile, os.path.join(covRcDir, ".coveragerc"))
self.assertEqual(covRcFile, os.path.join(covRcDir, "pyproject.toml"))

userFile = "UserCovRc"
covRcFile = case._getCoverageRcFile(userCovFile=userFile, makeCopy=False)
Expand Down
1 change: 1 addition & 0 deletions doc/release/0.3.rst
Expand Up @@ -42,6 +42,7 @@ Bug Fixes
Quality Work
------------
#. We now enforce a maximum line length of 120 characters, using ``ruff``. (`PR#1646 <https://github.com/terrapower/armi/pull/1646>`_)
#. Move ``.coveragerc`` file information into ``pyproject.toml``. (`PR#1692 <https://github.com/terrapower/armi/pull/1692>`_)
#. TBD

Changes that Affect Requirements
Expand Down
39 changes: 39 additions & 0 deletions pyproject.toml
Expand Up @@ -219,6 +219,45 @@ filterwarnings = [
"ignore: the matrix subclass is not the recommended way:PendingDeprecationWarning",
]

[tool.coverage.run]
exclude_also = [
"armi/cli/gridGui.py",
"armi/utils/gridEditor.py",
"armi/utils/tests/test_gridGui.py",
"venv/",
]
source = ["armi"]
parallel = true
# Change default .coverage file to something that doesn't have a dot
# because some Windows services can't handle dots.
data_file = "coverage_results.cov"

[tool.coverage.report]
# Regexes for lines to exclude from consideration
omit = [
"armi/cli/gridGui.py",
"armi/utils/gridEditor.py",
"*/tests/*",
]

exclude_also = [
# Don't complain about missing debug-only code:
"def __repr__",
"if self\\.debug",

# Don't complain if tests don't hit defensive assertion code:
"raise AssertionError",
"raise KeyboardInterrupt",
"raise NotImplementedError",
"except ImportError",
"pass",

# Don't complain if non-runnable code isn't run:
"if __name__ == .__main__.:",
]

ignore_errors = true


#######################################################################
# DATA FILES TO BE INCLUDED WITH THE PROJECT #
Expand Down

0 comments on commit dbdeb99

Please sign in to comment.