Skip to content

Commit

Permalink
revert: pass/fail badges
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitdmak committed Feb 6, 2022
1 parent c71f896 commit c2cbc6d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/docstr-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
schedule:
- cron: '0 0 * * *' # every day at midnight

# for GITHUB_TOKEN
permissions: write-all

jobs:
docstr_coverage:
runs-on: ubuntu-latest
Expand All @@ -25,23 +22,6 @@ jobs:
python -m pip install --upgrade pip
python -m pip install pytest
pip install interrogate
pip install anybadge
- name: Test docstr_coverage with interrogate
run: |
pytest test/test_docstr_coverage.py -s
- name: Upload badge as artifact
if: always()
uses: actions/upload-artifact@v2
with:
name: DocstringCoverage
path: docstr_badge.svg
- name: Delete old badge
if: always()
run: |
rm docstr_badge.svg
- name: Download badge as artifact
if: always()
uses: actions/download-artifact@v2
with:
name: DocstringCoverage
path: docstr_badge.svg
16 changes: 1 addition & 15 deletions test/test_docstr_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,12 @@
import unittest
from interrogate import coverage
from interrogate import config
import os

class TestDocStringsCoverage(unittest.TestCase):
def update_status_badge(self, new_value: int, min_value: int, max_value: int):
# --label and --value are text on left and right side of docstr_badge
# --file specifies .svg file to write to, -o is required for overwriting
# Color of badge for values under "min_value" are red, and above it are green
os.system(f"anybadge \
--label=DocstringCoverage \
--value={new_value} \
--file=docstr_badge.svg -o \
{min_value}=red \
{max_value}=green")

def test_using_interrogate(self):
"""Tests each module, function, classes, methods for presence of docstrings"""
# Parsing config (looks for pyproject.toml by default)
# project_root = Path(__file__).parent.parent
project_root = "./test"
project_root = Path(__file__).parent.parent
toml = config.find_project_config('.')
interrogate_config: config.InterrogateConfig = config.InterrogateConfig(config.parse_pyproject_toml(toml))
# Obtaining and printing results
Expand All @@ -34,7 +21,6 @@ def test_using_interrogate(self):
# covered % must satisfy min % set in .toml
print("\n")
cov.print_results(results, None, interrogate_config.color["verbose"])
self.update_status_badge(int(covered_percent), int(interrogate_config.fail_under), 100)
self.assertGreaterEqual(covered_percent, interrogate_config.fail_under, 'Required minimum percent of code covered by docstrings not achieved.')

if __name__ == '__main__':
Expand Down

0 comments on commit c2cbc6d

Please sign in to comment.