diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7101061 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04] + python-version: [3.9] + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install . + - name: Run pytest + run: | + cd misinformation + python -m pytest -s --cov=. --cov-report=xml + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: true + files: misinformation/coverage.xml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..7c0d83d --- /dev/null +++ b/codecov.yml @@ -0,0 +1,11 @@ +codecov: + require_ci_to_pass: yes + +coverage: + status: + project: + default: + target: 0 + patch: + default: + target: 80 diff --git a/misinformation/test/test_faces.py b/misinformation/test/test_faces.py index 5d839b0..27c40a1 100644 --- a/misinformation/test/test_faces.py +++ b/misinformation/test/test_faces.py @@ -1,5 +1,6 @@ import misinformation.faces as fc import json +from pytest import approx def test_analyse_faces(): @@ -22,4 +23,4 @@ def test_analyse_faces(): if type(mydict["emotion"][i]) == tuple else mydict["emotion"][i] ) - assert temp == out_dict["emotion"][i] + assert approx(temp) == out_dict["emotion"][i] diff --git a/pyproject.toml b/pyproject.toml index a83dd3c..44dc948 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,10 +35,12 @@ dependencies = [ "tensorflow", "keras", "openpyxl", + "pytest", + "pytest-cov", ] [project.scripts] misinformation_prefetch_models = "misinformation.utils:misinformation_prefetch_models" [tool.setuptools] -packages = ["misinformation"] \ No newline at end of file +packages = ["misinformation"] diff --git a/requirements.txt b/requirements.txt index 80c4370..dbb0ece 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,6 @@ retina_face setuptools tensorflow keras -openpyxl \ No newline at end of file +openpyxl +pytest +pytest-cov