diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 5a7c8365..1bdc929c 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -47,7 +47,6 @@ jobs: run: make pytest lint: runs-on: ubuntu-22.04 - environment: CI steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -64,18 +63,37 @@ jobs: pip install -U setuptools sudo apt-get update -qq sudo apt-get install -qq swig libxml2-dev libxmlsec1-dev - pip install --force-reinstall --no-binary lxml lxml make install-req make install-lint - name: Run linters run: | make flake8 make black + coveralls: + runs-on: ubuntu-22.04 + environment: CI + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: | + pip install -U setuptools + sudo apt-get update -qq + sudo apt-get install -qq swig libxml2-dev libxmlsec1-dev + make install-req + make install-test - name: Run coveralls env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} run: | pip install coveralls - coverage run setup.py test - coverage report -m - coveralls + make coverage + make coveralls diff --git a/Makefile b/Makefile index 89ea36f4..8f86afd7 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ FLAKE8=flake8 PYTEST=pytest COVERAGE=coverage COVERAGE_CONFIG=tests/coverage.rc +COVERALLS=coveralls MAIN_SOURCE=src/onelogin/saml2 DEMOS=demo-django demo-flask demo-tornado demo_pyramid TESTS=tests/src/OneLogin/saml2_tests @@ -19,8 +20,14 @@ install-lint: $(PIP) install -e ".[lint]" pytest: - $(COVERAGE) run --source $(MAIN_SOURCE) --rcfile=$(COVERAGE_CONFIG) -m pytest - $(COVERAGE) report -m --rcfile=$(COVERAGE_CONFIG) + $(pytest) + +coverage: + $(COVERAGE) run -m $(PYTEST) + $(COVERAGE) report -m + +coveralls: + $(COVERALLS) black: $(BLACK) $(SOURCES) diff --git a/pyproject.toml b/pyproject.toml index 83c7383f..eee84f5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ Changelog = "https://github.com/SAML-Toolkits/python3-saml/blob/master/changelog [project.optional-dependencies] test = [ - "coverage>=4.5.2", + "coverage[toml]>=4.5.2", "pytest>=4.6", ] lint = [ @@ -93,3 +93,30 @@ atomic = true ignore_comments = true skip_gitignore = true src_paths = ['src'] + +[tool.coverage.run] +branch = true + +[tool.coverage.paths] +source = [ + "src/onelogin/saml2" +] + +[tool.coverage.report] +# Regexes for lines to exclude from consideration +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "if self.debug", + "if debug", + "raise AssertionError", + "raise NotImplementedError", + "if 0:", + "if __name__ == .__main__.:" +] +show_missing = true +ignore_errors = true + + +[tool.coverage.html] +directory = "coverage_html_report" \ No newline at end of file diff --git a/tests/coverage.rc b/tests/coverage.rc deleted file mode 100644 index 855ec7f9..00000000 --- a/tests/coverage.rc +++ /dev/null @@ -1,30 +0,0 @@ -[run] -branch = True - -omit = - -[paths] -source = src/onelogin/saml2 - -[report] -# Regexes for lines to exclude from consideration -exclude_lines = - - - # Have to re-enable the standard pragma - pragma: no cover - - # Don't complain about missing debug-only code: - def __repr__ - if self\.debug - if debug - - # Don't complain if tests don't hit defensive assertion code: - raise AssertionError - raise NotImplementedError - - # Don't complain if non-runnable code isn't run: - if 0: - if __name__ == .__main__.: - -ignore_errors = True