test(coverage): Add Codecov (#2719)

This commit is contained in:
Pepe Fagoaga
2023-08-14 21:08:45 +02:00
committed by GitHub
parent 54137be92b
commit 2298d5356d
5 changed files with 44 additions and 6 deletions

View File

@@ -61,4 +61,8 @@ jobs:
/tmp/hadolint Dockerfile --ignore=DL3013
- name: Test with pytest
run: |
poetry run pytest tests -n auto
poetry run pytest -n auto --cov=./prowler --cov-report=xml tests
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

4
.gitignore vendored
View File

@@ -46,3 +46,7 @@ junit-reports/
# .env
.env*
# Coverage
.coverage*
coverage*

View File

@@ -2,12 +2,20 @@
##@ Testing
test: ## Test with pytest
pytest -n auto -vvv -s -x
pytest -n auto -vvv -s -x
rm -rf .coverage && \
rm -rf ./htmlcov && \
pytest -n auto --cov=./prowler --cov-report=xml tests
coverage: ## Show Test Coverage
coverage run --skip-covered -m pytest -v && \
coverage report -m && \
rm -rf .coverage
coverage run --skip-covered -m pytest -v && \
coverage report -m && \
rm -rf .coverage
coverage report -m
coverage-html: ## Show Test Coverage
coverage html && \
open htmlcov/index.html
##@ Linting
format: ## Format Code

23
poetry.lock generated
View File

@@ -636,6 +636,9 @@ files = [
{file = "coverage-7.2.7.tar.gz", hash = "sha256:924d94291ca674905fe9481f12294eb11f2d3d3fd1adb20314ba89e94f44ed59"},
]
[package.dependencies]
tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""}
[package.extras]
toml = ["tomli"]
@@ -1912,6 +1915,24 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
[package.extras]
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
[[package]]
name = "pytest-cov"
version = "4.1.0"
description = "Pytest plugin for measuring coverage."
optional = false
python-versions = ">=3.7"
files = [
{file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"},
{file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"},
]
[package.dependencies]
coverage = {version = ">=5.2.1", extras = ["toml"]}
pytest = ">=4.6"
[package.extras]
testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"]
[[package]]
name = "pytest-randomly"
version = "3.13.0"
@@ -2895,4 +2916,4 @@ docs = ["mkdocs", "mkdocs-material"]
[metadata]
lock-version = "2.0"
python-versions = "^3.9"
content-hash = "17459c4c8a7acf4c4a31253edf406113fbcedf8d81d17042f6b33665c3a6f47d"
content-hash = "7e241e96b044edcc8097879cea3219952a8344cd08ab3ede8d88bdb98d3a560a"

View File

@@ -64,6 +64,7 @@ moto = "4.1.14"
openapi-spec-validator = "0.6.0"
pylint = "2.17.5"
pytest = "7.4.0"
pytest-cov = "4.1.0"
pytest-randomly = "3.13.0"
pytest-xdist = "3.3.1"
safety = "2.3.5"