diff --git a/.github/workflows/ci_cd_wf.yml b/.github/workflows/ci_cd_wf.yml new file mode 100644 index 00000000..df5e57f0 --- /dev/null +++ b/.github/workflows/ci_cd_wf.yml @@ -0,0 +1,36 @@ +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 with coverage + run: | + python -m pytest -v --cov=calculator --cov-report=term-missing --cov-report=xml:coverage.xml tests/test_calculator.py + + - name: Upload coverage report + uses: actions/upload-artifact@v2 + with: + name: coverage-report + path: coverage.xml diff --git a/requirements.txt b/requirements.txt index 222e40bb..9e49c653 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ iniconfig==2.0.0 packaging==23.1 pluggy==1.0.0 pytest==7.3.1 +pytest-cov==2.12.1 tomli==2.0.1 diff --git a/tests/test_calculator.py b/tests/test_calculator.py index e69de29b..aeae4a4d 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) == 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