Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 31 additions & 139 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 11 additions & 33 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -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
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]
6 changes: 4 additions & 2 deletions fitbit_client/resources/nutrition.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@
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)

Check warning on line 109 in fitbit_client/resources/nutrition.py

View check run for this annotation

Codecov / codecov/patch

fitbit_client/resources/nutrition.py#L109

Added line #L109 was not covered by tests
else:
params[key.value] = float(value)
else:
params[str(key)] = float(value)

Expand Down