From 4285e6ce58be593e0009e5df394b8733c8356f77 Mon Sep 17 00:00:00 2001 From: Naureen Date: Fri, 16 Jun 2023 17:17:54 +0100 Subject: [PATCH 1/8] add workflows Signed-off-by: Naureen --- .github/workflows/ci_cd_wf.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 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..f9c46ac7 --- /dev/null +++ b/.github/workflows/ci_cd_wf.yml @@ -0,0 +1,26 @@ +name : test + +on: + push: + branches: + - main + +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 calculator.py \ No newline at end of file From 48f073e74ad556e6d78a8687af086e771605d53c Mon Sep 17 00:00:00 2001 From: Naureen Date: Fri, 16 Jun 2023 17:18:07 +0100 Subject: [PATCH 2/8] add tests Signed-off-by: Naureen --- tests/test_calculator.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_calculator.py b/tests/test_calculator.py index e69de29b..12e2b861 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -0,0 +1,11 @@ +def test_add(): + assert add(1,1) == 2 + +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 2cd131be297d3a84b01cfd881fd7b067a123623b Mon Sep 17 00:00:00 2001 From: Naureen Date: Fri, 16 Jun 2023 20:31:09 +0100 Subject: [PATCH 3/8] update workflow Signed-off-by: Naureen --- .github/workflows/ci_cd_wf.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd_wf.yml b/.github/workflows/ci_cd_wf.yml index f9c46ac7..f5bc683e 100644 --- a/.github/workflows/ci_cd_wf.yml +++ b/.github/workflows/ci_cd_wf.yml @@ -23,4 +23,4 @@ jobs: python -m pip install -r requirements.txt - name: Run tests run: | - python -m pytest calculator.py \ No newline at end of file + python -m pytest -v tests \ No newline at end of file From 14d582d49d198f83c7089a2354654f9499918d89 Mon Sep 17 00:00:00 2001 From: Naureen Date: Sat, 17 Jun 2023 12:56:47 +0100 Subject: [PATCH 4/8] Import calculator file for test Signed-off-by: Naureen --- tests/test_calculator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 12e2b861..ab990525 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -1,5 +1,6 @@ +from calculator import add, div, mul, sub def test_add(): - assert add(1,1) == 2 + assert add(1,1) == 0 def test_sub(): assert sub(1,1) == 0 From b96364d7e2d101e03a79e9bb7826c9ab7f2a5f6c Mon Sep 17 00:00:00 2001 From: Naureen Date: Sat, 17 Jun 2023 13:10:18 +0100 Subject: [PATCH 5/8] update workflow Signed-off-by: Naureen --- .github/workflows/ci_cd_wf.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci_cd_wf.yml b/.github/workflows/ci_cd_wf.yml index f5bc683e..8eeb601d 100644 --- a/.github/workflows/ci_cd_wf.yml +++ b/.github/workflows/ci_cd_wf.yml @@ -4,6 +4,9 @@ on: push: branches: - main + pull_request: + branches: + - "*" jobs: test: From 390c4d4851d3d6c9da3272d92fa070b919fcf6ca Mon Sep 17 00:00:00 2001 From: Naureen Date: Sat, 17 Jun 2023 13:15:24 +0100 Subject: [PATCH 6/8] update test file Signed-off-by: Naureen --- 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 ab990525..49910161 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -1,6 +1,6 @@ from calculator import add, div, mul, sub def test_add(): - assert add(1,1) == 0 + assert add(1,1) == 2 def test_sub(): assert sub(1,1) == 0 From 3a80c16cef5fcb74f8b30bedf281132e8e1b8a88 Mon Sep 17 00:00:00 2001 From: Naureen Date: Sat, 17 Jun 2023 13:32:33 +0100 Subject: [PATCH 7/8] add pytest coverage comment Signed-off-by: Naureen --- .github/workflows/ci_cd_wf.yml | 19 ++++++++++++++++++- tests/test_calculator.py | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_cd_wf.yml b/.github/workflows/ci_cd_wf.yml index 8eeb601d..0f14c343 100644 --- a/.github/workflows/ci_cd_wf.yml +++ b/.github/workflows/ci_cd_wf.yml @@ -26,4 +26,21 @@ 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@main + with: + pytest-coverage-path: ./path-to-file/pytest-coverage.txt + pytest-xml-coverage-path: ./path-to-file/coverage.xml + title: My Coverage Report Title + badge-title: My Badge Coverage Title + hide-badge: false + hide-report: false + create-new-comment: false + hide-comment: false + report-only-changed-files: false + remove-link-from-badge: false + unique-id-for-comment: python3.8 + junitxml-path: ./path-to-file/pytest.xml + junitxml-title: My JUnit Xml Summary Title \ No newline at end of file diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 49910161..073cf6dd 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -9,4 +9,4 @@ def test_mul(): assert mul(1,1) == 1 def test_div(): - assert div(2,1) == 2 \ No newline at end of file + assert div(2,1) == 0 \ No newline at end of file From a1d475574fb72ab3ef004bcf6b38bd4fee55ed92 Mon Sep 17 00:00:00 2001 From: Naureen Date: Sat, 17 Jun 2023 13:38:43 +0100 Subject: [PATCH 8/8] update indetation Signed-off-by: Naureen --- .github/workflows/ci_cd_wf.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_cd_wf.yml b/.github/workflows/ci_cd_wf.yml index 0f14c343..effbca7b 100644 --- a/.github/workflows/ci_cd_wf.yml +++ b/.github/workflows/ci_cd_wf.yml @@ -28,9 +28,9 @@ jobs: run: | python -m pytest -v tests - - name: Pytest coverage comment - uses: MishaKav/pytest-coverage-comment@main - with: + - name: Pytest coverage comment + uses: MishaKav/pytest-coverage-comment@main + with: pytest-coverage-path: ./path-to-file/pytest-coverage.txt pytest-xml-coverage-path: ./path-to-file/coverage.xml title: My Coverage Report Title