diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9963569..78aa91e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,145 +8,37 @@ on: jobs: test: + name: test runs-on: ubuntu-latest - steps: - - name: Check out repository - uses: actions/checkout@v3 - - - name: Set up Python 3.13 - uses: actions/setup-python@v4 - with: - python-version: "3.13" - - - name: Install PDM - run: | - python -m pip install --upgrade pip - pip install pdm - - - name: Install dependencies - run: | - pdm install -G:all - - - name: Run tests with coverage - run: | - pdm run pytest --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.xml - fail_ci_if_error: false - - format: - runs-on: ubuntu-latest - - steps: - - name: Check out repository - uses: actions/checkout@v3 - - - name: Set up Python 3.13 - uses: actions/setup-python@v4 - with: - python-version: "3.13" - - - name: Install PDM - run: | - python -m pip install --upgrade pip - pip install pdm - - - name: Install dependencies - run: | - pdm install -G:all - - - name: Check Black formatting - run: | - pdm run black --check - - - name: Check isort - run: | - pdm run isort --check - - - name: Check unused imports with autoflake - run: | - pdm run autoflake - - type-check: - runs-on: ubuntu-latest - - steps: - - name: Check out repository - uses: actions/checkout@v3 - - - name: Set up Python 3.13 - uses: actions/setup-python@v4 - with: - python-version: "3.13" - - - name: Install PDM - run: | - python -m pip install --upgrade pip - pip install pdm - - - name: Install dependencies - run: | - pdm install -G:all - - - name: Run mypy - run: | - pdm run mypy - - docs: - runs-on: ubuntu-latest - - steps: - - name: Check out repository - uses: actions/checkout@v3 - - - name: Set up Python 3.13 - uses: actions/setup-python@v4 - with: - python-version: "3.13" - - - name: Install PDM - run: | - python -m pip install --upgrade pip - pip install pdm - - - name: Install dependencies - run: | - pdm install -G:all - - - name: Check markdown formatting - run: | - echo "Markdown format checking temporarily disabled" - exit 0 + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python 3.13 + uses: actions/setup-python@v4 + with: + python-version: "3.13" + + - name: Install PDM + run: | + python -m pip install --upgrade pip + pip install pdm + + - name: Install dependencies + run: | + pdm install -G:all + + - name: Run tests with coverage + run: | + pdm run pytest --cov=fitbit_client --cov-report=xml:coverage.xml - # todo: https://github.com/ydah/mdformat-action - - # build: - # runs-on: ubuntu-latest - # needs: [test, format, type-check, docs] - - # steps: - # - name: Check out repository - # uses: actions/checkout@v3 - - # - name: Set up Python 3.13 - # uses: actions/setup-python@v4 - # with: - # python-version: "3.13" - - # - name: Install PDM - # run: | - # python -m pip install --upgrade pip - # pip install pdm - - # - name: Install dependencies - # run: | - # pdm install -G:all - - # - name: Build package - # run: | - # pdm build \ No newline at end of file + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml + # fail_ci_if_error: false + name: codecov-umbrella + verbose: true \ No newline at end of file diff --git a/README.md b/README.md index ae7c895..7aab7d4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # Fitbit Client [![CI](https://github.com/jpstroop/fitbit-client/actions/workflows/ci.yml/badge.svg)](https://github.com/jpstroop/fitbit-client/actions/workflows/ci.yml) -[![codecov](https://codecov.io/gh/jpstroop/fitbit-client/branch/main/graph/badge.svg)](https://codecov.io/gh/jpstroop/fitbit-client) +[![codecov](https://codecov.io/gh/jpstroop/fitbit-client-python/graph/badge.svg?token=DM0JD8VKZ4)](https://codecov.io/gh/jpstroop/fitbit-client-python) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Python 3.13+](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/downloads/release/python-3130/) [![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) diff --git a/TODO.md b/TODO.md index df86bf9..ec98ffa 100644 --- a/TODO.md +++ b/TODO.md @@ -45,6 +45,19 @@ if not food_id and not (food_name and calories): params[str(key)] = float(value) ``` +It needs to change to: + +```python + for key, value in nutritional_values.items(): + if isinstance(key, NutritionalValue): + if key == NutritionalValue.CALORIES_FROM_FAT: + params[key.value] = int(value) + else: + params[key.value] = float(value) + else: + params[str(key)] = float(value) +``` + see: test_create_food_calories_from_fat_must_be_integer(nutrition_resource) - exceptions.py diff --git a/codecov.yml b/codecov.yml index c1ca2f7..65cc730 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,44 +1,22 @@ codecov: require_ci_to_pass: yes strict_yaml_branch: main + notify: + wait_for_ci: false + after_n_builds: 1 coverage: - precision: 2 - round: down - range: "95...100" status: - project: + project: #add everything under here, more options at https://docs.codecov.com/docs/commit-status default: target: 100% threshold: 0% - base: auto - branches: - - main - if_not_found: failure - if_ci_failed: error - informational: false - only_pulls: false - patch: - default: - target: 100% - threshold: 0% - base: auto - branches: - - main - if_not_found: failure - if_ci_failed: error - informational: false - only_pulls: false - -parsers: - gcov: - branch_detection: - conditional: yes - loop: yes - method: no - macro: no + base: auto -comment: - layout: "reach,diff,flags,files,footer" +comment: #this is a top-level key + layout: " diff, flags, files" behavior: default - require_changes: no \ No newline at end of file + require_changes: false # if true: only post the comment if coverage changes + require_base: false # [true :: must have a base report to post] + require_head: true # [true :: must have a head report to post] + hide_project_coverage: false # [true :: only show coverage on the git diff aka patch coverage] diff --git a/fitbit_client/resources/nutrition.py b/fitbit_client/resources/nutrition.py index 3999d28..7a2cc14 100644 --- a/fitbit_client/resources/nutrition.py +++ b/fitbit_client/resources/nutrition.py @@ -103,10 +103,12 @@ def create_food( error_type="client_validation", field_name="CALORIES_FROM_FAT", ) - # Handle both enum and string nutritional values for key, value in nutritional_values.items(): if isinstance(key, NutritionalValue): - params[key.value] = float(value) + if key == NutritionalValue.CALORIES_FROM_FAT: + params[key.value] = int(value) + else: + params[key.value] = float(value) else: params[str(key)] = float(value)