From 55c39fa7c101b73579df00e9e83f2a7b72af5206 Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:56:51 +0000 Subject: [PATCH 01/16] step0: add python dependencies --- api/requirements.txt | 142 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 api/requirements.txt diff --git a/api/requirements.txt b/api/requirements.txt new file mode 100644 index 00000000..1a73aa07 --- /dev/null +++ b/api/requirements.txt @@ -0,0 +1,142 @@ +anyio==4.2.0 +argon2-cffi==23.1.0 +argon2-cffi-bindings==21.2.0 +arrow==1.3.0 +asttokens==2.4.1 +async-lru==2.0.4 +attrs==23.2.0 +Babel==2.14.0 +beautifulsoup4==4.12.2 +bleach==6.1.0 +blinker==1.7.0 +certifi==2023.11.17 +cffi==1.16.0 +charset-normalizer==3.3.2 +click==8.1.7 +colorama==0.4.6 +comm==0.2.1 +contourpy==1.2.0 +coverage==7.4.1 +cycler==0.12.1 +debugpy==1.8.0 +decorator==5.1.1 +defusedxml==0.7.1 +exceptiongroup==1.2.0 +executing==2.0.1 +fastjsonschema==2.19.1 +filelock==3.13.1 +Flask==3.0.2 +fonttools==4.47.0 +fqdn==1.5.1 +fsspec==2023.12.2 +gitdb==4.0.11 +GitPython==3.1.41 +idna==3.6 +iniconfig==2.0.0 +ipykernel==6.28.0 +ipython==8.20.0 +isoduration==20.11.0 +itsdangerous==2.1.2 +jedi==0.19.1 +Jinja2==3.1.2 +joblib==1.3.2 +json5==0.9.14 +jsonpointer==2.4 +jsonschema==4.20.0 +jsonschema-specifications==2023.12.1 +jupyter-events==0.9.0 +jupyter-lsp==2.2.1 +jupyter-server-mathjax==0.2.6 +jupyter_client==8.6.0 +jupyter_core==5.7.1 +jupyter_server==2.12.3 +jupyter_server_terminals==0.5.1 +jupyterlab==4.0.10 +jupyterlab_git==0.50.0 +jupyterlab_pygments==0.3.0 +jupyterlab_server==2.25.2 +kiwisolver==1.4.5 +MarkupSafe==2.1.3 +matplotlib==3.8.2 +matplotlib-inline==0.1.6 +mistune==3.0.2 +mpmath==1.3.0 +nbclient==0.9.0 +nbconvert==7.14.0 +nbdime==4.0.1 +nbformat==5.9.2 +nest-asyncio==1.5.8 +networkx==3.2.1 +notebook_shim==0.2.3 +numpy==1.26.3 +nvidia-cublas-cu12==12.1.3.1 +nvidia-cuda-cupti-cu12==12.1.105 +nvidia-cuda-nvrtc-cu12==12.1.105 +nvidia-cuda-runtime-cu12==12.1.105 +nvidia-cudnn-cu12==8.9.2.26 +nvidia-cufft-cu12==11.0.2.54 +nvidia-curand-cu12==10.3.2.106 +nvidia-cusolver-cu12==11.4.5.107 +nvidia-cusparse-cu12==12.1.0.106 +nvidia-nccl-cu12==2.18.1 +nvidia-nvjitlink-cu12==12.3.101 +nvidia-nvtx-cu12==12.1.105 +overrides==7.4.0 +packaging==23.2 +pandas==2.1.4 +pandocfilters==1.5.0 +parso==0.8.3 +pexpect==4.9.0 +pillow==10.2.0 +platformdirs==4.1.0 +plotly==5.18.0 +pluggy==1.4.0 +prometheus-client==0.19.0 +prompt-toolkit==3.0.43 +psutil==5.9.7 +ptyprocess==0.7.0 +pure-eval==0.2.2 +pycparser==2.21 +Pygments==2.17.2 +pyparsing==3.1.1 +pytest==8.0.0 +pytest-cov==4.1.0 +python-dateutil==2.8.2 +python-json-logger==2.0.7 +pytz==2023.3.post1 +PyYAML==6.0.1 +pyzmq==25.1.2 +referencing==0.32.1 +requests==2.31.0 +rfc3339-validator==0.1.4 +rfc3986-validator==0.1.1 +rpds-py==0.16.2 +scikit-learn==1.3.2 +scipy==1.11.4 +seaborn==0.13.1 +Send2Trash==1.8.2 +six==1.16.0 +smmap==5.0.1 +sniffio==1.3.0 +soupsieve==2.5 +stack-data==0.6.3 +sympy==1.12 +tenacity==8.2.3 +terminado==0.18.0 +threadpoolctl==3.2.0 +tinycss2==1.2.1 +tomli==2.0.1 +torch==2.1.2 +tornado==6.4 +traitlets==5.14.1 +triton==2.1.0 +types-python-dateutil==2.8.19.20240106 +typing_extensions==4.9.0 +tzdata==2023.4 +uri-template==1.3.0 +urllib3==2.0.7 +wcwidth==0.2.13 +webcolors==1.13 +webencodings==0.5.1 +websocket-client==1.7.0 +Werkzeug==3.0.1 From b20ea55d34cb24d1b6d34f84d970bfe036e61d34 Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:10:22 +0000 Subject: [PATCH 02/16] 'step1: add calculator' --- api/app.py | 35 +++++++++++++++++++++++++++++++++++ api/calculator/__init__.py | 0 api/calculator/calculator.py | 14 ++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 api/app.py create mode 100644 api/calculator/__init__.py create mode 100644 api/calculator/calculator.py diff --git a/api/app.py b/api/app.py new file mode 100644 index 00000000..d91792d1 --- /dev/null +++ b/api/app.py @@ -0,0 +1,35 @@ +from flask import ( + Flask, + request, +) + +from calculator.calculator import Calculator + +app = Flask(__name__) + +@app.route('/api/add', methods=['POST']) +def add(): + return operation('add', 2) + +@app.route('/api/subtract', methods=['POST']) +def subtract(): + return operation('subtract', 2) + +@app.route('/api/multiply', methods=['POST']) +def multiply(): + return operation('multiply', 2) + +@app.route('/api/divide', methods=['POST']) +def divide(): + return operation('divide', 2) + +def operation(method, num_factors): + factors = [] + if num_factors == 2: + factors.append(float(request.json.get('x'))) + factors.append(float(request.json.get('y'))) + + return str(getattr(Calculator, method)(*factors)) + + +app.run(host='0.0.0.0', port=8080) \ No newline at end of file diff --git a/api/calculator/__init__.py b/api/calculator/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/calculator/calculator.py b/api/calculator/calculator.py new file mode 100644 index 00000000..eac4e7ac --- /dev/null +++ b/api/calculator/calculator.py @@ -0,0 +1,14 @@ +class Calculator: + def add(x, y): + return x + y + + def subtract(x, y): + return x - y + + def multiply(x, y): + return x * y + + def divide(x, y): + if y == 0: + return 'Cannot divide by 0' + return x * 1.0 / y \ No newline at end of file From d356a0a32e8eba3ea3cdb543b7577e519f4625b3 Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:18:50 +0000 Subject: [PATCH 03/16] step1: add calculator backend and tests --- api/calculator/test_calculator.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 api/calculator/test_calculator.py diff --git a/api/calculator/test_calculator.py b/api/calculator/test_calculator.py new file mode 100644 index 00000000..69fa778f --- /dev/null +++ b/api/calculator/test_calculator.py @@ -0,0 +1,30 @@ +from .calculator import Calculator + + +def test_add(): + assert Calculator.add(1, 2) == 3.0 + assert Calculator.add(1.0, 2.0) == 3.0 + assert Calculator.add(0, 2.0) == 2.0 + assert Calculator.add(2.0, 0) == 2.0 + assert Calculator.add(-4, 2.0) == -2.0 + +def test_subtract(): + assert Calculator.subtract(1, 2) == -1.0 + assert Calculator.subtract(2, 1) == 1.0 + assert Calculator.subtract(1.0, 2.0) == -1.0 + assert Calculator.subtract(0, 2.0) == -2.0 + assert Calculator.subtract(2.0, 0.0) == 2.0 + assert Calculator.subtract(-4, 2.0) == -6.0 + +def test_multiply(): + assert Calculator.multiply(1, 2) == 2.0 + assert Calculator.multiply(1.0, 2.0) == 2.0 + assert Calculator.multiply(0, 2.0) == 0.0 + assert Calculator.multiply(2.0, 0.0) == 0.0 + assert Calculator.multiply(-4, 2.0) == -8.0 + +def test_divide(): + assert Calculator.divide(1, 2) == 0.5 + assert Calculator.divide(1.0, 2.0) == 0.5 + assert Calculator.divide(0, 2.0) == 0 + assert Calculator.divide(-4, 2.0) == -2.0 \ No newline at end of file From 0344ca6417178d2c8882f8f23f7320bfe9c220ea Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:31:02 +0100 Subject: [PATCH 04/16] Create api.yml --- .github/workflows/api.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/api.yml diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml new file mode 100644 index 00000000..28d97cb2 --- /dev/null +++ b/.github/workflows/api.yml @@ -0,0 +1,19 @@ +name: API workflow + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + name: Test python API + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v2 + with: + python-version: '3.11' + - name: Install requirements + run: pip install -r api/requirements.txt + - name: Run tests and collect coverage + run: pytest --cov=api.calculator --cov-report=xml + - name: Upload coverage reports to Codecov with GitHub Action + uses: codecov/codecov-action@v3 From 3e806cf26c42828914d86abaa0e3fd0ea680d75c Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:34:35 +0100 Subject: [PATCH 05/16] Update api.yml --- .github/workflows/api.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 28d97cb2..d0bd4cca 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -16,4 +16,6 @@ jobs: - name: Run tests and collect coverage run: pytest --cov=api.calculator --cov-report=xml - name: Upload coverage reports to Codecov with GitHub Action - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4.0.1 + + From 4e2dede771bb45784d88378188622cfedc5b9c4c Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:41:17 +0000 Subject: [PATCH 06/16] step2: upload coverage reports to Codecov --- .github/workflows/api.yml | 19 +++++++++++++++++++ .github/workflows/config.yml | 24 ++++++++++++++++++++++++ .github/workflows/workflow.yml | 11 +++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .github/workflows/api.yml create mode 100644 .github/workflows/config.yml create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml new file mode 100644 index 00000000..4a924aaa --- /dev/null +++ b/.github/workflows/api.yml @@ -0,0 +1,19 @@ +name: API workflow + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + name: Test python API + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v2 + with: + python-version: '3.11' + - name: Install requirements + run: pip install -r api/requirements.txt + - name: Run tests and collect coverage + run: pytest --cov=api.calculator --cov-report=xml + - name: Upload coverage reports to Codecov with GitHub Action + uses: codecov/codecov-action@v3 \ No newline at end of file diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml new file mode 100644 index 00000000..95a7f585 --- /dev/null +++ b/.github/workflows/config.yml @@ -0,0 +1,24 @@ +version: 2.1 + +orbs: + codecov: codecov/codecov@3.2.2 + +jobs: + test-api: + docker: + - image: cimg/python:3.10.2 + steps: + - checkout + - run: + name: Install requirements + command: pip install -r api/requirements.txt + - run: + name: Run tests and collect coverage + command: pytest --cov api.calculator + - codecov/upload + +workflows: + version: 2.1 + build-test: + jobs: + - test-api \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 00000000..ff98af38 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,11 @@ +steps: + - uses: actions/checkout@master + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true # optional (default = false) + files: ./coverage1.xml,./coverage2.xml # optional + flags: unittests # optional + name: codecov-umbrella # optional + token: ${{ secrets.CODECOV_TOKEN }} # required + verbose: true # optional (default = false) + \ No newline at end of file From 267ba380e335272dbeb147887e7c9540d7773ecb Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:59:13 +0000 Subject: [PATCH 07/16] step3: add project status check target --- codecov.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..b6ac064f --- /dev/null +++ b/codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + target: 100% + threshold: 1% \ No newline at end of file From 8e199cfa1a223c5eaabf778732f25889c43c5d5c Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:06:05 +0000 Subject: [PATCH 08/16] step3: cover divide by 0 case --- api/calculator/test_calculator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/calculator/test_calculator.py b/api/calculator/test_calculator.py index 69fa778f..0763267a 100644 --- a/api/calculator/test_calculator.py +++ b/api/calculator/test_calculator.py @@ -27,4 +27,6 @@ def test_divide(): assert Calculator.divide(1, 2) == 0.5 assert Calculator.divide(1.0, 2.0) == 0.5 assert Calculator.divide(0, 2.0) == 0 - assert Calculator.divide(-4, 2.0) == -2.0 \ No newline at end of file + assert Calculator.divide(-4, 2.0) == -2.0 +def test_divide_by_0(): + assert Calculator.divide(2.0, 0) == 'Cannot divide by 0' \ No newline at end of file From 7c9f37a88aabf528db2bfcdc32f4a2b72ac839d3 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 10 Feb 2024 20:06:12 +0000 Subject: [PATCH 09/16] Restyled by autopep8 --- api/calculator/test_calculator.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/calculator/test_calculator.py b/api/calculator/test_calculator.py index 0763267a..c534ac6f 100644 --- a/api/calculator/test_calculator.py +++ b/api/calculator/test_calculator.py @@ -8,6 +8,7 @@ def test_add(): assert Calculator.add(2.0, 0) == 2.0 assert Calculator.add(-4, 2.0) == -2.0 + def test_subtract(): assert Calculator.subtract(1, 2) == -1.0 assert Calculator.subtract(2, 1) == 1.0 @@ -16,6 +17,7 @@ def test_subtract(): assert Calculator.subtract(2.0, 0.0) == 2.0 assert Calculator.subtract(-4, 2.0) == -6.0 + def test_multiply(): assert Calculator.multiply(1, 2) == 2.0 assert Calculator.multiply(1.0, 2.0) == 2.0 @@ -23,10 +25,13 @@ def test_multiply(): assert Calculator.multiply(2.0, 0.0) == 0.0 assert Calculator.multiply(-4, 2.0) == -8.0 + def test_divide(): assert Calculator.divide(1, 2) == 0.5 assert Calculator.divide(1.0, 2.0) == 0.5 assert Calculator.divide(0, 2.0) == 0 assert Calculator.divide(-4, 2.0) == -2.0 + + def test_divide_by_0(): - assert Calculator.divide(2.0, 0) == 'Cannot divide by 0' \ No newline at end of file + assert Calculator.divide(2.0, 0) == 'Cannot divide by 0' From bf3691c0822c17c1fe22adba70f31fdf1d3f1024 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 10 Feb 2024 20:06:13 +0000 Subject: [PATCH 10/16] Restyled by black --- api/calculator/test_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/calculator/test_calculator.py b/api/calculator/test_calculator.py index c534ac6f..2f6c3a20 100644 --- a/api/calculator/test_calculator.py +++ b/api/calculator/test_calculator.py @@ -34,4 +34,4 @@ def test_divide(): def test_divide_by_0(): - assert Calculator.divide(2.0, 0) == 'Cannot divide by 0' + assert Calculator.divide(2.0, 0) == "Cannot divide by 0" From c3623ad0b013032007a28329829292c00db0a8e6 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 10 Feb 2024 20:06:15 +0000 Subject: [PATCH 11/16] Restyled by prettier-yaml --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index b6ac064f..045842d2 100644 --- a/codecov.yml +++ b/codecov.yml @@ -3,4 +3,4 @@ coverage: project: default: target: 100% - threshold: 1% \ No newline at end of file + threshold: 1% From 2e087c6b9c0eb31ee4a9b8bb35afd0dca63c1a95 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 10 Feb 2024 20:06:16 +0000 Subject: [PATCH 12/16] Restyled by pyment --- api/calculator/test_calculator.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/calculator/test_calculator.py b/api/calculator/test_calculator.py index 2f6c3a20..6067e895 100644 --- a/api/calculator/test_calculator.py +++ b/api/calculator/test_calculator.py @@ -2,6 +2,7 @@ def test_add(): + """ """ assert Calculator.add(1, 2) == 3.0 assert Calculator.add(1.0, 2.0) == 3.0 assert Calculator.add(0, 2.0) == 2.0 @@ -10,6 +11,7 @@ def test_add(): def test_subtract(): + """ """ assert Calculator.subtract(1, 2) == -1.0 assert Calculator.subtract(2, 1) == 1.0 assert Calculator.subtract(1.0, 2.0) == -1.0 @@ -19,6 +21,7 @@ def test_subtract(): def test_multiply(): + """ """ assert Calculator.multiply(1, 2) == 2.0 assert Calculator.multiply(1.0, 2.0) == 2.0 assert Calculator.multiply(0, 2.0) == 0.0 @@ -27,6 +30,7 @@ def test_multiply(): def test_divide(): + """ """ assert Calculator.divide(1, 2) == 0.5 assert Calculator.divide(1.0, 2.0) == 0.5 assert Calculator.divide(0, 2.0) == 0 @@ -34,4 +38,5 @@ def test_divide(): def test_divide_by_0(): + """ """ assert Calculator.divide(2.0, 0) == "Cannot divide by 0" From 83208274c46d94b3d3ad09de45cdf936a080da25 Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:32:09 +0000 Subject: [PATCH 13/16] step3: add Codecov badge --- .github/workflows/api.yml | 2 +- .github/workflows/config.yml | 8 ++++---- .github/workflows/workflow.yml | 8 ++++---- README.md | 2 ++ api/calculator/calculator.py | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index dda54fbc..8309a931 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -16,7 +16,7 @@ jobs: - name: Run tests and collect coverage run: pytest --cov=api.calculator --cov-report=xml - name: Upload coverage reports to Codecov with GitHub Action - uses: codecov/codecov-action@v4.0.1 + uses: codecov/codecov-action@v3 diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 95a7f585..106030aa 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -1,9 +1,9 @@ -version: 2.1 + version: 2.1 -orbs: + orbs: codecov: codecov/codecov@3.2.2 -jobs: + jobs: test-api: docker: - image: cimg/python:3.10.2 @@ -17,7 +17,7 @@ jobs: command: pytest --cov api.calculator - codecov/upload -workflows: + workflows: version: 2.1 build-test: jobs: diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index ff98af38..9d0d7dc1 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -1,6 +1,7 @@ -steps: - - uses: actions/checkout@master - - uses: codecov/codecov-action@v4 + steps: + - uses: actions/checkout@master + - uses: codecov/codecov-action@v4 + with: fail_ci_if_error: true # optional (default = false) files: ./coverage1.xml,./coverage2.xml # optional @@ -8,4 +9,3 @@ steps: name: codecov-umbrella # optional token: ${{ secrets.CODECOV_TOKEN }} # required verbose: true # optional (default = false) - \ No newline at end of file diff --git a/README.md b/README.md index 8471a1b6..ffbf3853 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # codecov-demo This repository is meant to show the features and functionalities of Codecov. You can follow along [here](https://docs.codecov.com/docs/codecov-tutorial). + +[![codecov](https://codecov.io/gh/NCherfaoui/codecov-demo/graph/badge.svg?token=ZEaY1zqYfQ)](https://codecov.io/gh/NCherfaoui/codecov-demo) \ No newline at end of file diff --git a/api/calculator/calculator.py b/api/calculator/calculator.py index eac4e7ac..f92e65e2 100644 --- a/api/calculator/calculator.py +++ b/api/calculator/calculator.py @@ -10,5 +10,5 @@ def multiply(x, y): def divide(x, y): if y == 0: - return 'Cannot divide by 0' + return 'Cannot divide by 0' return x * 1.0 / y \ No newline at end of file From 651da80169dff9d19a1e58c1d075d31cf9053a51 Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:37:42 +0000 Subject: [PATCH 14/16] step4: add smiles --- .github/workflows/api.yml | 11 +++++------ api/smiles/__init__.py | 0 api/smiles/smiles.py | 5 +++++ api/smiles/test_smiles.py | 4 ++++ 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 api/smiles/__init__.py create mode 100644 api/smiles/smiles.py create mode 100644 api/smiles/test_smiles.py diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 8309a931..bef7f510 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -13,10 +13,9 @@ jobs: python-version: '3.11' - name: Install requirements run: pip install -r api/requirements.txt - - name: Run tests and collect coverage - run: pytest --cov=api.calculator --cov-report=xml + - name: Run tests and collect coverage for calculator + run: pytest --cov=api.calculator --cov-report=xml:calculator-coverage.xml + - name: Run tests and collect coverage for smiles + run: pytest --cov=api.smiles --cov-report=xml:smiles-coverage.xml - name: Upload coverage reports to Codecov with GitHub Action - uses: codecov/codecov-action@v3 - - - + uses: codecov/codecov-action@v3 \ No newline at end of file diff --git a/api/smiles/__init__.py b/api/smiles/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/smiles/smiles.py b/api/smiles/smiles.py new file mode 100644 index 00000000..ebdbb666 --- /dev/null +++ b/api/smiles/smiles.py @@ -0,0 +1,5 @@ +class Smiles: + def smile(): + return ":)" + def frown(): + return ":(" \ No newline at end of file diff --git a/api/smiles/test_smiles.py b/api/smiles/test_smiles.py new file mode 100644 index 00000000..4c3b8fa8 --- /dev/null +++ b/api/smiles/test_smiles.py @@ -0,0 +1,4 @@ +from .smiles import Smiles + +def test_smile(): + assert Smiles.smile() == ":)" \ No newline at end of file From 0e3588f122d3ceba752693ae9da9756819fa5522 Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:45:36 +0000 Subject: [PATCH 15/16] step4: add Codecov Component --- codecov.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/codecov.yml b/codecov.yml index 045842d2..eaf8b712 100644 --- a/codecov.yml +++ b/codecov.yml @@ -4,3 +4,12 @@ coverage: default: target: 100% threshold: 1% +comment: + layout: "header, diff, flags, components" + +component_management: + individual_components: + - component_id: api # this is an identifier that should not be changed + name: api # this is a display name, and can be changed freely + paths: + - api \ No newline at end of file From ae3c6a55ccf67a79411062216e1559a2bb18bcd5 Mon Sep 17 00:00:00 2001 From: Nassim CHERFAOUI <99206668+NCherfaoui@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:49:00 +0000 Subject: [PATCH 16/16] step4: aggregate tests and split Component --- .github/workflows/api.yml | 6 ++---- codecov.yml | 12 +++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index bef7f510..f6b808c5 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -13,9 +13,7 @@ jobs: python-version: '3.11' - name: Install requirements run: pip install -r api/requirements.txt - - name: Run tests and collect coverage for calculator - run: pytest --cov=api.calculator --cov-report=xml:calculator-coverage.xml - - name: Run tests and collect coverage for smiles - run: pytest --cov=api.smiles --cov-report=xml:smiles-coverage.xml + - name: Run tests and collect coverage + run: pytest --cov - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v3 \ No newline at end of file diff --git a/codecov.yml b/codecov.yml index eaf8b712..bc65af09 100644 --- a/codecov.yml +++ b/codecov.yml @@ -12,4 +12,14 @@ component_management: - component_id: api # this is an identifier that should not be changed name: api # this is a display name, and can be changed freely paths: - - api \ No newline at end of file + - api + component_management: + individual_components: + - component_id: api-calculator # this is an identifier that should not be changed + name: calculator # this is a display name, and can be changed freely + paths: + - api/calculator/ + - component_id: api-smiles # this is an identifier that should not be changed + name: smiles # this is a display name, and can be changed freely + paths: + - api/smiles/ \ No newline at end of file