From 437e222407b326c01d8a4ba20d7ff385ea69d281 Mon Sep 17 00:00:00 2001 From: Taiwo Olori <101744737+OloriT@users.noreply.github.com> Date: Sat, 18 Nov 2023 06:34:25 +0000 Subject: [PATCH 1/6] changed test_add to fail --- .github/workflows/ci_cd_wf.yml | 29 +++++++++++++++++++++++++++++ tests/test_calculator.py | 17 +++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .github/workflows/ci_cd_wf.yml diff --git a/.github/workflows/ci_cd_wf.yml b/.github/workflows/ci_cd_wf.yml new file mode 100644 index 00000000..8ca03d4c --- /dev/null +++ b/.github/workflows/ci_cd_wf.yml @@ -0,0 +1,29 @@ +name: test + +on: + push: + branches: + - main + pull_request: + branches: + - "*" + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Check out repo code + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: "3.x" + + - name: Install Dependencies + run: | + python -m pip install -r requirements.txt + - name: Run tests + run: | + python -m pytest -v tests \ No newline at end of file diff --git a/tests/test_calculator.py b/tests/test_calculator.py index e69de29b..1a7ee7fb 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -0,0 +1,17 @@ +from calculator import add, div, mul, sub + + +def test_add(): + assert add(1, 1) == 0 + + +def test_sub(): + assert sub(1, 1) == 0 + + +def test_mul(): + assert mul(1, 1) == 1 + + +def test_div(): + assert div(2, 1) == 2 \ No newline at end of file From 2aaeaf451e2849bec0419df2f3d1fdc97326507d Mon Sep 17 00:00:00 2001 From: Taiwo Olori <101744737+OloriT@users.noreply.github.com> Date: Sat, 18 Nov 2023 07:43:36 +0100 Subject: [PATCH 2/6] Update test_calculator.py --- tests/test_calculator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 1a7ee7fb..efdc7a33 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -2,7 +2,7 @@ def test_add(): - assert add(1, 1) == 0 + assert add(1, 1) == 2 def test_sub(): @@ -14,4 +14,4 @@ def test_mul(): def test_div(): - assert div(2, 1) == 2 \ No newline at end of file + assert div(2, 1) == 2 From 13e158a8efd7f7e23a2c6817954b0067c9d5bb36 Mon Sep 17 00:00:00 2001 From: Taiwo Olori <101744737+OloriT@users.noreply.github.com> Date: Sat, 18 Nov 2023 06:55:32 +0000 Subject: [PATCH 3/6] pytest code coverage badge and full report --- .github/workflows/ci_cd_wf.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd_wf.yml b/.github/workflows/ci_cd_wf.yml index 8ca03d4c..4221e69e 100644 --- a/.github/workflows/ci_cd_wf.yml +++ b/.github/workflows/ci_cd_wf.yml @@ -26,4 +26,7 @@ jobs: python -m pip install -r requirements.txt - name: Run tests run: | - python -m pytest -v tests \ No newline at end of file + python -m pytest -v tests + - name: Pytest Coverage Comment + uses: MishaKav/pytest-coverage-comment@v1.1.49 + \ No newline at end of file From 4c921e1abf27e43b96d1f887dc50404802064950 Mon Sep 17 00:00:00 2001 From: Taiwo Olori <101744737+OloriT@users.noreply.github.com> Date: Sat, 18 Nov 2023 08:37:30 +0000 Subject: [PATCH 4/6] Added coverage files --- .github/workflows/ci_cd_wf.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd_wf.yml b/.github/workflows/ci_cd_wf.yml index 4221e69e..44615e3c 100644 --- a/.github/workflows/ci_cd_wf.yml +++ b/.github/workflows/ci_cd_wf.yml @@ -27,6 +27,18 @@ jobs: - name: Run tests run: | python -m pytest -v tests - - name: Pytest Coverage Comment + + - name: Install Py-test Cov Reports + run: | + python -m pip install pytest-cov + + - name: Install pytest-cov for report uses: MishaKav/pytest-coverage-comment@v1.1.49 + with: + pytest-coverage-path: ./pytest-coverage.txt + junitxml-path: ./pytest.xml + + - name: Build coverage file + run: | + pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=src tests/ | tee pytest-coverage.txt \ No newline at end of file From afb315f071837cfa35b52cf43484b4d324ca0a8e Mon Sep 17 00:00:00 2001 From: Taiwo Olori <101744737+OloriT@users.noreply.github.com> Date: Sat, 18 Nov 2023 08:59:02 +0000 Subject: [PATCH 5/6] made change to test_calculator --- tests/test_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 1a7ee7fb..aeae4a4d 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -2,7 +2,7 @@ def test_add(): - assert add(1, 1) == 0 + assert add(1, 1) == 2 def test_sub(): From ca0d2540aeb4c342e3c9b2509ad7f0edccec9dda Mon Sep 17 00:00:00 2001 From: Taiwo Olori <101744737+OloriT@users.noreply.github.com> Date: Sat, 18 Nov 2023 09:25:40 +0000 Subject: [PATCH 6/6] eitted yml file --- .github/workflows/ci_cd_wf.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_cd_wf.yml b/.github/workflows/ci_cd_wf.yml index 44615e3c..606c0d9b 100644 --- a/.github/workflows/ci_cd_wf.yml +++ b/.github/workflows/ci_cd_wf.yml @@ -33,12 +33,12 @@ jobs: python -m pip install pytest-cov - name: Install pytest-cov for report - uses: MishaKav/pytest-coverage-comment@v1.1.49 + uses: MishaKav/pytest-coverage-comment@main with: pytest-coverage-path: ./pytest-coverage.txt junitxml-path: ./pytest.xml - name: Build coverage file run: | - pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=src tests/ | tee pytest-coverage.txt + pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=tests/ | tee pytest-coverage.txt \ No newline at end of file