From 2dd1a7952f2410be204f1998909667c260116638 Mon Sep 17 00:00:00 2001 From: Inga Ulusoy Date: Wed, 5 Oct 2022 11:25:48 +0200 Subject: [PATCH] Create ci.yml (#29) * Create ci.yml * include pytest * Update pyproject.toml * include pytest-cov * use approx in pytest * Update test_faces.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add coverage yaml * reduce passing grade Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++ codecov.yml | 11 +++++++++ misinformation/test/test_faces.py | 3 ++- pyproject.toml | 4 +++- requirements.txt | 4 +++- 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 codecov.yml 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