add code coverage bade & ci: fix pytest-cov

cv2_1
scito 1 year ago
parent 51094a1a18
commit 04d864c093

@ -36,7 +36,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-mock mypy types-protobuf
pip install flake8 pytest pytest-mock pytest-cov mypy types-protobuf
pip install --use-pep517 -r requirements.txt
- name: Lint with flake8
run: |
@ -49,5 +49,15 @@ jobs:
mypy --install-types --non-interactive *.py
mypy --strict *.py
if: matrix.python-version == '3.x'
- name: Test with pytest
run: pytest
if: matrix.python-version != '3.x' || matrix.platform == 'ubuntu-latest'
- name: Test with pytest (with code coverage)
run: pytest --cov=test_extract_otp_secret_keys_pytest
run: pytest --cov=test_extract_otp_secret_keys_pytest --junitxml=pytest.xml --cov-report=term-missing | tee pytest-coverage.txt
if: matrix.python-version == '3.x' && matrix.platform == 'ubuntu-latest'
# https://github.com/marketplace/actions/pytest-coverage-comment
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml

2
.gitignore vendored

@ -16,3 +16,5 @@ venv/
*.whl
build/
extract_otp_secret_keys.egg-info/
*.xml
pytest-coverage.txt

78
Pipfile.lock generated

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "507dfa1a2ffdf56718b6f68f988b5576d8b15cadb9a43fa74edcb273dd7af0b5"
"sha256": "d07d5e2bd005a0045969de4ed2427a1edc17c0fee0bde853aef1437da16b31ec"
},
"pipfile-spec": 6,
"requires": {
@ -190,6 +190,66 @@
"markers": "python_version >= '3.6'",
"version": "==22.2.0"
},
"coverage": {
"extras": [
"toml"
],
"hashes": [
"sha256:07bcfb1d8ac94af886b54e18a88b393f6a73d5959bb31e46644a02453c36e475",
"sha256:09f6b5a8415b6b3e136d5fec62b552972187265cb705097bf030eb9d4ffb9b60",
"sha256:0a79137fc99815fff6a852c233628e735ec15903cfd16da0f229d9c4d45926ab",
"sha256:0b4b3a4d9915b2be879aff6299c0a6129f3d08a775d5a061f503cf79571f73e4",
"sha256:1285648428a6101b5f41a18991c84f1c3959cee359e51b8375c5882fc364a13f",
"sha256:12a5aa77783d49e05439fbe6e6b427484f8a0f9f456b46a51d8aac022cfd024d",
"sha256:19ec666533f0f70a0993f88b8273057b96c07b9d26457b41863ccd021a043b9a",
"sha256:1e414dc32ee5c3f36544ea466b6f52f28a7af788653744b8570d0bf12ff34bc0",
"sha256:2c44fcfb3781b41409d0f060a4ed748537557de9362a8a9282182fafb7a76ab4",
"sha256:397b4a923cc7566bbc7ae2dfd0ba5a039b61d19c740f1373791f2ebd11caea59",
"sha256:3cfc595d2af13856505631be072835c59f1acf30028d1c860b435c5fc9c15b69",
"sha256:3dd4ee135e08037f458425b8842d24a95a0961831a33f89685ff86b77d378f89",
"sha256:486ee81fa694b4b796fc5617e376326a088f7b9729c74d9defa211813f3861e4",
"sha256:4f943a3b2bc520102dd3e0bb465e1286e12c9a54f58accd71b9e65324d9c7c01",
"sha256:63d56165a7c76265468d7e0c5548215a5ba515fc2cba5232d17df97bffa10f6c",
"sha256:66b18c3cf8bbab0cce0d7b9e4262dc830e93588986865a8c78ab2ae324b3ed56",
"sha256:691571f31ace1837838b7e421d3a09a8c00b4aac32efacb4fc9bd0a5c647d25a",
"sha256:6c5ad996c6fa4d8ed669cfa1e8551348729d008a2caf81489ab9ea67cfbc7498",
"sha256:6d55d840e1b8c0002fce66443e124e8581f30f9ead2e54fbf6709fb593181f2c",
"sha256:72d1507f152abacea81f65fee38e4ef3ac3c02ff8bc16f21d935fd3a8a4ad910",
"sha256:74f70cd92669394eaf8d7756d1b195c8032cf7bbbdfce3bc489d4e15b3b8cf73",
"sha256:830525361249dc4cd013652b0efad645a385707a5ae49350c894b67d23fbb07c",
"sha256:854f22fa361d1ff914c7efa347398374cc7d567bdafa48ac3aa22334650dfba2",
"sha256:89caf4425fe88889e2973a8e9a3f6f5f9bbe5dd411d7d521e86428c08a873a4a",
"sha256:9158f8fb06747ac17bd237930c4372336edc85b6e13bdc778e60f9d685c3ca37",
"sha256:92651580bd46519067e36493acb394ea0607b55b45bd81dd4e26379ed1871f55",
"sha256:978258fec36c154b5e250d356c59af7d4c3ba02bef4b99cda90b6029441d797d",
"sha256:9823e4789ab70f3ec88724bba1a203f2856331986cd893dedbe3e23a6cfc1e4e",
"sha256:9b373c9345c584bb4b5f5b8840df7f4ab48c4cbb7934b58d52c57020d911b856",
"sha256:a4a574a19eeb67575a5328a5760bbbb737faa685616586a9f9da4281f940109c",
"sha256:aec2d1515d9d39ff270059fd3afbb3b44e6ec5758af73caf18991807138c7118",
"sha256:b3695c4f4750bca943b3e1f74ad4be8d29e4aeab927d50772c41359107bd5d5c",
"sha256:b3763e7fcade2ff6c8e62340af9277f54336920489ceb6a8cd6cc96da52fcc62",
"sha256:b66bb21a23680dee0be66557dc6b02a3152ddb55edf9f6723fa4a93368f7158d",
"sha256:b6f22bb64cc39bcb883e5910f99a27b200fdc14cdd79df8696fa96b0005c9444",
"sha256:b77015d1cb8fe941be1222a5a8b4e3fbca88180cfa7e2d4a4e58aeabadef0ab7",
"sha256:b9ea158775c7c2d3e54530a92da79496fb3fb577c876eec761c23e028f1e216c",
"sha256:c20cfebcc149a4c212f6491a5f9ff56f41829cd4f607b5be71bb2d530ef243b1",
"sha256:cfded268092a84605f1cc19e5c737f9ce630a8900a3589e9289622db161967e9",
"sha256:d1991f1dd95eba69d2cd7708ff6c2bbd2426160ffc73c2b81f617a053ebcb1a8",
"sha256:d3022c3007d3267a880b5adcf18c2a9bf1fc64469b394a804886b401959b8742",
"sha256:d6814854c02cbcd9c873c0f3286a02e3ac1250625cca822ca6bc1018c5b19f1c",
"sha256:d87717959d4d0ee9db08a0f1d80d21eb585aafe30f9b0a54ecf779a69cb015f6",
"sha256:e00c14720b8b3b6c23b487e70bd406abafc976ddc50490f645166f111c419c39",
"sha256:e60bef2e2416f15fdc05772bf87db06c6a6f9870d1db08fdd019fbec98ae24a9",
"sha256:e78e9dcbf4f3853d3ae18a8f9272111242531535ec9e1009fa8ec4a2b74557dc",
"sha256:f66460f17c9319ea4f91c165d46840314f0a7c004720b20be58594d162a441d8",
"sha256:fa6a5a224b7f4cfb226f4fc55a57e8537fcc096f42219128c2c74c0e7d0953e1",
"sha256:fb992c47cb1e5bd6a01e97182400bcc2ba2077080a17fcd7be23aaa6e572e390",
"sha256:fd1b9c5adc066db699ccf7fa839189a649afcdd9e02cb5dc9d24e67e7922737d",
"sha256:fd556ff16a57a070ce4f31c635953cc44e25244f91a0378c6e9bdfd40fdb249f"
],
"markers": "python_version >= '3.7'",
"version": "==7.0.1"
},
"dill": {
"hashes": [
"sha256:a07ffd2351b8c678dfc4a856a3005f8067aea51d6ba6c700796a4d9e280f39f0",
@ -353,6 +413,22 @@
"index": "pypi",
"version": "==7.2.0"
},
"pytest-cov": {
"hashes": [
"sha256:2feb1b751d66a8bd934e5edfa2e961d11309dc37b73b0eabe73b5945fee20f6b",
"sha256:996b79efde6433cdbd0088872dbc5fb3ed7fe1578b68cdbba634f14bb8dd0470"
],
"index": "pypi",
"version": "==4.0.0"
},
"pytest-mock": {
"hashes": [
"sha256:f4c973eeae0282963eb293eb173ce91b091a79c1334455acfac9ddee8a1c784b",
"sha256:fbbdb085ef7c252a326fd8cdcac0aa3b1333d8811f131bdcc701002e1be7ed4f"
],
"index": "pypi",
"version": "==3.10.0"
},
"tomlkit": {
"hashes": [
"sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b",

@ -1,6 +1,7 @@
# Extract TOTP/HOTP secret keys from Google Authenticator
[![CI Status](https://github.com/scito/extract_otp_secret_keys/actions/workflows/ci.yml/badge.svg)](https://github.com/scito/extract_otp_secret_keys/actions/workflows/ci.yml)
![coverage](https://img.shields.io/badge/coverage-95%25-yellowgreen)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/protobuf)
[![GitHub Pipenv locked Python version](https://img.shields.io/github/pipenv/locked/python-version/scito/extract_otp_secret_keys)](https://github.com/scito/extract_otp_secret_keys/blob/master/Pipfile.lock)
![protobuf version](https://img.shields.io/badge/protobuf-4.21.12-informational)

@ -0,0 +1,4 @@
[mypy]
[mypy-protobuf_generated_python.*]
ignore_errors = True

@ -1,6 +1,6 @@
from __future__ import annotations # for compatibility with Python < 3.11
import pathlib
from setuptools import setup # type: ignore
from setuptools import setup
setup(
name='extract_otp_secret_keys',
@ -14,10 +14,13 @@ setup(
author='scito',
author_email='info@scito.ch',
# https://pypi.org/classifiers/
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Environment :: X11 Applications :: Qt',
'Environment :: Win32 (MS Windows)',
'Topic :: System :: Archiving :: Backup',
'Topic :: Utilities',

@ -238,7 +238,7 @@ eval "$cmd"
# Test
cmd="pytest --cov=test_extract_otp_secret_keys_pytest"
cmd="pytest --cov=test_extract_otp_secret_keys_pytest --junitxml=pytest.xml --cov-report=term-missing | tee pytest-coverage.txt"
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
eval "$cmd"
@ -246,6 +246,12 @@ cmd="$PIPENV run pytest --cov=test_extract_otp_secret_keys_pytest"
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
eval "$cmd"
# Update Code Coverage in README.md
# https://github.com/marketplace/actions/pytest-coverage-comment
# Coverage-95%25-yellowgreen
TOTAL_COVERAGE=$(cat pytest-coverage.txt | grep 'TOTAL' | perl -ne 'print "$&" if /\b(\d{1,3})%/') && perl -i -pe "s/coverage-(\d{1,3}%)25-/coverage-${TOTAL_COVERAGE}25-/" README.md
# Build docker
cmd="docker build . -t extract_otp_secret_keys_no_qr_reader -f Dockerfile_no_qr_reader --pull"

Loading…
Cancel
Save